[vlc-commits] [Git][videolan/vlc][master] 2 commits: screen: don't force the type of internal data
Steve Lhomme (@robUx4)
gitlab at videolan.org
Fri Aug 25 10:00:22 UTC 2023
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
9dd1af4f by Steve Lhomme at 2023-08-25T09:07:41+00:00
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.
- - - - -
ed8c34ec by Steve Lhomme at 2023-08-25T09:07:41+00:00
screen/dxgi: fix potential null pointer dereference
- - - - -
4 changed files:
- modules/access/screen/dxgi.cpp
- modules/access/screen/mac.c
- modules/access/screen/screen.h
- modules/access/screen/win32.c
Changes:
=====================================
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;
@@ -246,7 +249,7 @@ int screen_InitCaptureDXGI(demux_t *p_demux)
p_data->duplication->GetDesc(&outDesc);
p_data->output_format = D3D11_RenderFormat(outDesc.ModeDesc.Format ,true);
- if (unlikely(!p_data->output_format->name))
+ if (unlikely(!p_data->output_format))
{
msg_Err(p_demux, "Unknown texture format %d", outDesc.ModeDesc.Format);
goto error;
=====================================
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);
=====================================
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;
=====================================
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)
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c67dec41df363393c84120563cc1faedd7799c8f...ed8c34ec282f7b3e86122be7a0c9f27595cdedd9
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c67dec41df363393c84120563cc1faedd7799c8f...ed8c34ec282f7b3e86122be7a0c9f27595cdedd9
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list