[vlc-commits] direct3d11: use vlc_obj_calloc() to allocate the vout_display_sys_t
Steve Lhomme
git at videolan.org
Tue Nov 20 09:18:12 CET 2018
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Nov 19 14:19:58 2018 +0100| [c231750e0fd82b4da3fd18aa31dc65e581c800c6] | committer: Steve Lhomme
direct3d11: use vlc_obj_calloc() to allocate the vout_display_sys_t
This will make the code more readable.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c231750e0fd82b4da3fd18aa31dc65e581c800c6
---
modules/video_output/win32/direct3d11.c | 33 ++++++++++++++-------------------
1 file changed, 14 insertions(+), 19 deletions(-)
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 1775fd7d13..c377eb8585 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -180,11 +180,7 @@ static void Direct3D11UnmapPoolTexture(picture_t *picture)
#if !VLC_WINSTORE_APP
static int OpenHwnd(vout_display_t *vd)
{
- vout_display_sys_t *sys = vd->sys = calloc(1, sizeof(vout_display_sys_t));
- if (!sys)
- return VLC_ENOMEM;
-
- return D3D11_Create(vd, &sys->hd3d, true);
+ return D3D11_Create(vd, &vd->sys->hd3d, true);
}
#else
static int OpenCoreW(vout_display_t *vd)
@@ -200,10 +196,6 @@ static int OpenCoreW(vout_display_t *vd)
if (!d3ddevice)
return VLC_EGENERIC;
- vout_display_sys_t *sys = vd->sys = calloc(1, sizeof(vout_display_sys_t));
- if (!sys)
- return VLC_ENOMEM;
-
sys->dxgiswapChain = dxgiswapChain;
sys->d3d_dev.d3ddevice = d3ddevice;
sys->d3d_dev.d3dcontext = d3dcontext;
@@ -370,6 +362,10 @@ static int Open(vlc_object_t *object)
}
#endif
+ vout_display_sys_t *sys = vd->sys = vlc_obj_calloc(object, 1, sizeof(vout_display_sys_t));
+ if (!sys)
+ return VLC_ENOMEM;
+
#if !VLC_WINSTORE_APP
int ret = OpenHwnd(vd);
#else
@@ -383,10 +379,10 @@ static int Open(vlc_object_t *object)
goto error;
#if VLC_WINSTORE_APP
- vd->sys->sys.pf_GetRect = GetRect;
+ sys->sys.pf_GetRect = GetRect;
#endif
- vd->sys->sys.pf_GetPictureWidth = GetPictureWidth;
- vd->sys->sys.pf_GetPictureHeight = GetPictureHeight;
+ sys->sys.pf_GetPictureWidth = GetPictureWidth;
+ sys->sys.pf_GetPictureHeight = GetPictureHeight;
if (Direct3D11Open(vd)) {
msg_Err(vd, "Direct3D11 could not be opened");
@@ -394,8 +390,8 @@ static int Open(vlc_object_t *object)
}
#if !VLC_WINSTORE_APP
- if (!vd->sys->sys.b_windowless)
- EventThreadUpdateTitle(vd->sys->sys.event, VOUT_TITLE " (Direct3D11 output)");
+ if (!sys->sys.b_windowless)
+ EventThreadUpdateTitle(sys->sys.event, VOUT_TITLE " (Direct3D11 output)");
#endif
msg_Dbg(vd, "Direct3D11 device adapter successfully initialized");
@@ -403,11 +399,11 @@ static int Open(vlc_object_t *object)
vd->info.has_pictures_invalid = vd->info.is_slow;
if (var_InheritBool(vd, "direct3d11-hw-blending") &&
- vd->sys->regionQuad.textureFormat != NULL)
+ sys->regionQuad.textureFormat != NULL)
{
- vd->sys->pSubpictureChromas[0] = vd->sys->regionQuad.textureFormat->fourcc;
- vd->sys->pSubpictureChromas[1] = 0;
- vd->info.subpicture_chromas = vd->sys->pSubpictureChromas;
+ sys->pSubpictureChromas[0] = sys->regionQuad.textureFormat->fourcc;
+ sys->pSubpictureChromas[1] = 0;
+ vd->info.subpicture_chromas = sys->pSubpictureChromas;
}
else
vd->info.subpicture_chromas = NULL;
@@ -433,7 +429,6 @@ static void Close(vlc_object_t *object)
Direct3D11Close(vd);
CommonClean(vd);
Direct3D11Destroy(vd);
- free(vd->sys);
}
static picture_pool_t *Pool(vout_display_t *vd, unsigned pool_size)
More information about the vlc-commits
mailing list