summaryrefslogtreecommitdiffstats
path: root/libvo
diff options
context:
space:
mode:
authorzuxy <zuxy@b3059339-0415-0410-9bf9-f77b7e298cf2>2007-10-27 12:24:08 +0000
committerzuxy <zuxy@b3059339-0415-0410-9bf9-f77b7e298cf2>2007-10-27 12:24:08 +0000
commite88e5849d3525cfeabf8da624bf052232eb26887 (patch)
treebe99147d42125789600514083d3cb71f4d9af57a /libvo
parentc9d49b63b15c6285da048dc4d6dabe737a7d095d (diff)
downloadmpv-e88e5849d3525cfeabf8da624bf052232eb26887.tar.bz2
mpv-e88e5849d3525cfeabf8da624bf052232eb26887.tar.xz
Avoid crash after recovering from screensaver
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@24861 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo')
-rw-r--r--libvo/vo_directx.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/libvo/vo_directx.c b/libvo/vo_directx.c
index cb36a2ba2b..953fee86e5 100644
--- a/libvo/vo_directx.c
+++ b/libvo/vo_directx.c
@@ -69,6 +69,7 @@ static HCURSOR mplayercursor = NULL; // Handle to mplayer cursor
static uint32_t image_width, image_height; //image width and height
static uint32_t d_image_width, d_image_height; //image width and height zoomed
static uint8_t *image=NULL; //image data
+static void* tmp_image = NULL;
static uint32_t image_format=0; //image format
static uint32_t primary_image_format;
static uint32_t vm_height=0;
@@ -679,7 +680,7 @@ static uint32_t Directx_ManageDisplay()
dwUpdateFlags = DDOVER_SHOW | DDOVER_DDFX;
/*if hardware can't do colorkeying set the window on top*/
if(capsDrv.dwCKeyCaps & DDCKEYCAPS_DESTOVERLAY) dwUpdateFlags |= DDOVER_KEYDESTOVERRIDE;
- else vo_ontop = 1;
+ else if (!tmp_image) vo_ontop = 1;
}
else
{
@@ -1155,6 +1156,12 @@ static void flip_page(void)
{
mp_msg(MSGT_VO, MSGL_ERR,"<vo_directx><ERROR><vo_directx><INFO>Restoring Surface\n");
g_lpddsBack->lpVtbl->Restore( g_lpddsBack );
+ // restore overlay and primary before calling
+ // Directx_ManageDisplay() to avoid error messages
+ g_lpddsOverlay->lpVtbl->Restore( g_lpddsOverlay );
+ g_lpddsPrimary->lpVtbl->Restore( g_lpddsPrimary );
+ // update overlay in case we return from screensaver
+ Directx_ManageDisplay();
dxresult = g_lpddsOverlay->lpVtbl->Flip( g_lpddsOverlay,NULL, DDFLIP_WAIT);
}
if(dxresult != DD_OK)mp_msg(MSGT_VO, MSGL_ERR,"<vo_directx><ERROR>can't flip page\n");
@@ -1167,14 +1174,21 @@ static void flip_page(void)
ddbltfx.dwSize = sizeof(DDBLTFX);
ddbltfx.dwDDFX = DDBLTFX_NOTEARING;
g_lpddsPrimary->lpVtbl->Blt(g_lpddsPrimary, &rd, g_lpddsBack, NULL, DDBLT_WAIT, &ddbltfx);
- }
- g_lpddsBack->lpVtbl->Lock(g_lpddsBack,NULL,&ddsdsf, DDLOCK_NOSYSLOCK | DDLOCK_WAIT , NULL);
+ }
+ if (g_lpddsBack->lpVtbl->Lock(g_lpddsBack,NULL,&ddsdsf, DDLOCK_NOSYSLOCK | DDLOCK_WAIT , NULL) == DD_OK) {
if(vo_directrendering && (dstride != ddsdsf.lPitch)){
mp_msg(MSGT_VO,MSGL_WARN,"<vo_directx><WARN>stride changed !!!! disabling direct rendering\n");
vo_directrendering=0;
}
+ if (tmp_image)
+ free(tmp_image);
+ tmp_image = NULL;
dstride = ddsdsf.lPitch;
image = ddsdsf.lpSurface;
+ } else if (!tmp_image) {
+ mp_msg(MSGT_VO, MSGL_WARN, "<vo_directx><WARN>Locking the surface failed, rendering to a hidden surface!\n");
+ tmp_image = image = calloc(1, image_height * dstride * 2);
+ }
}
static int draw_frame(uint8_t *src[])
@@ -1376,10 +1390,13 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
Directx_ManageDisplay();
memset(&ddsdsf, 0,sizeof(DDSURFACEDESC2));
ddsdsf.dwSize = sizeof (DDSURFACEDESC2);
- g_lpddsBack->lpVtbl->Lock(g_lpddsBack,NULL,&ddsdsf, DDLOCK_NOSYSLOCK | DDLOCK_WAIT, NULL);
+ if (g_lpddsBack->lpVtbl->Lock(g_lpddsBack,NULL,&ddsdsf, DDLOCK_NOSYSLOCK | DDLOCK_WAIT, NULL) == DD_OK) {
dstride = ddsdsf.lPitch;
image = ddsdsf.lpSurface;
return 0;
+ }
+ mp_msg(MSGT_VO, MSGL_V, "<vo_directx><ERROR>Initial Lock on the Surface failed.\n");
+ return 1;
}
//function to set color controls