Browse Source

screen: don't force the type of internal data

The win32 uses 2 different types with the same name. In C++ this breaks the
One Definition Rule.
pull/162/head
Steve Lhomme 3 years ago
parent
commit
9dd1af4f59
  1. 15
      modules/access/screen/dxgi.cpp
  2. 9
      modules/access/screen/mac.c
  3. 6
      modules/access/screen/screen.h
  4. 9
      modules/access/screen/win32.c

15
modules/access/screen/dxgi.cpp

@ -37,7 +37,8 @@
#include <wrl/client.h>
using Microsoft::WRL::ComPtr;
struct screen_data_t
namespace {
struct dxgi_screen
{
const d3d_format_t *output_format = nullptr;
vlc_video_context *vctx = nullptr;
@ -47,12 +48,13 @@ struct screen_data_t
ComPtr<IDXGIOutputDuplication> duplication;
~screen_data_t()
~dxgi_screen()
{
if (vctx)
vlc_video_context_Release(vctx);
}
};
} // namespace
static void CaptureBlockRelease( block_t *p_block )
{
@ -64,7 +66,7 @@ static void CaptureBlockRelease( block_t *p_block )
static block_t *screen_Capture(demux_t *p_demux)
{
demux_sys_t *p_sys = static_cast<demux_sys_t*>(p_demux->p_sys);
screen_data_t *p_data = p_sys->p_data;
dxgi_screen *p_data = static_cast<dxgi_screen *>(p_sys->p_data);
block_sys_d3d11_t *d3d11_block = new (std::nothrow) block_sys_d3d11_t();
ComPtr<IDXGIResource> resource;
ComPtr<ID3D11Resource> d3d11res;
@ -151,15 +153,16 @@ error:
return nullptr;
}
static void screen_CloseCapture(screen_data_t *p_data)
static void screen_CloseCapture(void *opaque)
{
dxgi_screen *p_data = static_cast<dxgi_screen*>(opaque);
delete p_data;
}
int screen_InitCaptureDXGI(demux_t *p_demux)
{
demux_sys_t *p_sys = static_cast<demux_sys_t*>(p_demux->p_sys);
screen_data_t *p_data;
dxgi_screen *p_data;
vlc_decoder_device *dec_dev;
HRESULT hr;
@ -185,7 +188,7 @@ int screen_InitCaptureDXGI(demux_t *p_demux)
}
#endif // !WINAPI_PARTITION_DESKTOP
p_data = new (std::nothrow) screen_data_t();
p_data = new (std::nothrow) dxgi_screen();
if (unlikely(p_data == nullptr))
return VLC_ENOMEM;

9
modules/access/screen/mac.c

@ -42,11 +42,11 @@
extern int CGSMainConnectionID();
extern CGImageRef CGSCreateRegisteredCursorImage(int, char*, CGPoint*);
static void screen_CloseCapture(screen_data_t *);
static void screen_CloseCapture(void *);
static block_t *screen_Capture(demux_t *);
struct screen_data_t
typedef struct
{
block_t *p_block;
@ -66,7 +66,7 @@ struct screen_data_t
CGRect offscreen_rect;
void *offscreen_bitmap;
size_t offscreen_bitmap_size;
};
} screen_data_t;
int screen_InitCapture(demux_t *p_demux)
{
@ -148,8 +148,9 @@ int screen_InitCapture(demux_t *p_demux)
return VLC_SUCCESS;
}
static void screen_CloseCapture(screen_data_t *p_data)
static void screen_CloseCapture(void *opaque)
{
screen_data_t *p_data = opaque;
if (p_data->offscreen_context)
CFRelease(p_data->offscreen_context);

6
modules/access/screen/screen.h

@ -34,12 +34,10 @@
extern "C" {
#endif
typedef struct screen_data_t screen_data_t;
struct screen_capture_operations
{
block_t* (*capture)( demux_t * );
void (*close)( screen_data_t * );
void (*close)( void * );
};
typedef struct
@ -69,7 +67,7 @@ typedef struct
picture_t dst;
#endif
screen_data_t *p_data;
void *p_data;
const struct screen_capture_operations *ops;
} demux_sys_t;

9
modules/access/screen/win32.c

@ -38,10 +38,10 @@
#include <windows.h>
static void screen_CloseCapture(screen_data_t *);
static void screen_CloseCapture(void *);
static block_t *screen_Capture(demux_t *);
struct screen_data_t
typedef struct
{
HDC hdc_src;
HDC hdc_dst;
@ -57,7 +57,7 @@ struct screen_data_t
#ifdef SCREEN_MOUSE
filter_t *p_blend;
#endif
};
} screen_data_t;
#if defined(SCREEN_SUBSCREEN) || defined(SCREEN_MOUSE)
/*
@ -162,8 +162,9 @@ int screen_InitCaptureGDI( demux_t *p_demux )
return VLC_SUCCESS;
}
void screen_CloseCapture( screen_data_t *p_data )
void screen_CloseCapture( void *opaque )
{
screen_data_t *p_data = opaque;
if( p_data->p_block ) block_Release( p_data->p_block );
if( p_data->hgdi_backup)

Loading…
Cancel
Save