mirror of https://github.com/mpv-player/mpv
Avoid memleaks when vo_direct3d initialization fails.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30191 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
f31ed10742
commit
3b34c55178
|
@ -674,7 +674,7 @@ static int preinit(const char *arg)
|
||||||
priv = calloc(1, sizeof(struct global_priv));
|
priv = calloc(1, sizeof(struct global_priv));
|
||||||
if (!priv) {
|
if (!priv) {
|
||||||
mp_msg(MSGT_VO, MSGL_ERR, "<vo_direct3d>Allocating private memory failed.\n");
|
mp_msg(MSGT_VO, MSGL_ERR, "<vo_direct3d>Allocating private memory failed.\n");
|
||||||
return -1;
|
goto err_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME
|
/* FIXME
|
||||||
|
@ -685,26 +685,26 @@ static int preinit(const char *arg)
|
||||||
priv->d3d9_dll = LoadLibraryA("d3d9.dll");
|
priv->d3d9_dll = LoadLibraryA("d3d9.dll");
|
||||||
if (!priv->d3d9_dll) {
|
if (!priv->d3d9_dll) {
|
||||||
mp_msg(MSGT_VO, MSGL_ERR, "<vo_direct3d>Unable to dynamically load d3d9.dll\n");
|
mp_msg(MSGT_VO, MSGL_ERR, "<vo_direct3d>Unable to dynamically load d3d9.dll\n");
|
||||||
return -1;
|
goto err_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->pDirect3DCreate9 = (void *)GetProcAddress(priv->d3d9_dll, "Direct3DCreate9");
|
priv->pDirect3DCreate9 = (void *)GetProcAddress(priv->d3d9_dll, "Direct3DCreate9");
|
||||||
if (!priv->pDirect3DCreate9) {
|
if (!priv->pDirect3DCreate9) {
|
||||||
mp_msg(MSGT_VO, MSGL_ERR, "<vo_direct3d>Unable to find entry point of Direct3DCreate9\n");
|
mp_msg(MSGT_VO, MSGL_ERR, "<vo_direct3d>Unable to find entry point of Direct3DCreate9\n");
|
||||||
return -1;
|
goto err_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->d3d_handle = priv->pDirect3DCreate9(D3D_SDK_VERSION);
|
priv->d3d_handle = priv->pDirect3DCreate9(D3D_SDK_VERSION);
|
||||||
if (!priv->d3d_handle) {
|
if (!priv->d3d_handle) {
|
||||||
mp_msg(MSGT_VO, MSGL_ERR, "<vo_direct3d>Initializing Direct3D failed.\n");
|
mp_msg(MSGT_VO, MSGL_ERR, "<vo_direct3d>Initializing Direct3D failed.\n");
|
||||||
return -1;
|
goto err_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FAILED(IDirect3D9_GetAdapterDisplayMode(priv->d3d_handle,
|
if (FAILED(IDirect3D9_GetAdapterDisplayMode(priv->d3d_handle,
|
||||||
D3DADAPTER_DEFAULT,
|
D3DADAPTER_DEFAULT,
|
||||||
&disp_mode))) {
|
&disp_mode))) {
|
||||||
mp_msg(MSGT_VO, MSGL_ERR, "<vo_direct3d>Reading display mode failed.\n");
|
mp_msg(MSGT_VO, MSGL_ERR, "<vo_direct3d>Reading display mode failed.\n");
|
||||||
return -1;
|
goto err_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Store in priv->desktop_fmt the user desktop's colorspace. Usually XRGB. */
|
/* Store in priv->desktop_fmt the user desktop's colorspace. Usually XRGB. */
|
||||||
|
@ -720,7 +720,7 @@ static int preinit(const char *arg)
|
||||||
D3DDEVTYPE_HAL,
|
D3DDEVTYPE_HAL,
|
||||||
&disp_caps))) {
|
&disp_caps))) {
|
||||||
mp_msg(MSGT_VO, MSGL_ERR, "<vo_direct3d>Reading display capabilities failed.\n");
|
mp_msg(MSGT_VO, MSGL_ERR, "<vo_direct3d>Reading display capabilities failed.\n");
|
||||||
return -1;
|
goto err_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Store relevant information reguarding caps of device */
|
/* Store relevant information reguarding caps of device */
|
||||||
|
@ -745,10 +745,14 @@ static int preinit(const char *arg)
|
||||||
*/
|
*/
|
||||||
if (!vo_w32_init()) {
|
if (!vo_w32_init()) {
|
||||||
mp_msg(MSGT_VO, MSGL_V, "<vo_direct3d>Configuring onscreen window failed.\n");
|
mp_msg(MSGT_VO, MSGL_V, "<vo_direct3d>Configuring onscreen window failed.\n");
|
||||||
return -1;
|
goto err_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
err_out:
|
||||||
|
uninit();
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -877,7 +881,9 @@ static void uninit(void)
|
||||||
|
|
||||||
uninit_d3d();
|
uninit_d3d();
|
||||||
vo_w32_uninit(); /* w32_common framework call */
|
vo_w32_uninit(); /* w32_common framework call */
|
||||||
FreeLibrary(priv->d3d9_dll);
|
if (priv->d3d9_dll)
|
||||||
|
FreeLibrary(priv->d3d9_dll);
|
||||||
|
priv->d3d9_dll = NULL;
|
||||||
free(priv);
|
free(priv);
|
||||||
priv = NULL;
|
priv = NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue