[MPlayer-dev-eng] [PATCH] Let vo directx survive screensaver

Zuxy Meng zuxy.meng at gmail.com
Mon Oct 23 07:05:48 CEST 2006


Hi,

Currently vo directx will crash with seg fault when a screensaver
starts, while vo gl, vo gl2, vo sdl work fine. The root cause is that
when this happens, the last line of flip_page() will set image = NULL.
This patch enables vo directx to survive a screensaver, a monitor off,
a standby and a hibernation, either full screen or windowed, active or
inactive. But there's still one situation that it can't handle: if
mplayer starts to play a file while the screensaver is running,
mplayer won't wake the computer up and once the screensaver exits,
mplayer will have a black window.

-- 
Zuxy
Beauty is truth,
While truth is beauty.
PGP KeyID: E8555ED6
-------------- next part --------------
Index: libvo/vo_directx.c
===================================================================
--- libvo/vo_directx.c	???????? 20315??
+++ libvo/vo_directx.c	????????????
@@ -679,7 +679,7 @@
         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 (image) vo_ontop = 1;
 	}
     else
     {
@@ -712,6 +712,8 @@
 	
 //    printf("overlay: %i %i %ix%i\n",rd.left,rd.top,rd.right - rd.left,rd.bottom - rd.top);
 	ddrval = g_lpddsOverlay->lpVtbl->UpdateOverlay(g_lpddsOverlay,&rs, g_lpddsPrimary, &rd, dwUpdateFlags, &ovfx);
+	if(!image)
+		return 0;
     if(FAILED(ddrval))
     {
         // one cause might be the driver lied about minimum stretch 
@@ -1154,6 +1157,12 @@
 		{
 			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");
@@ -1230,6 +1239,9 @@
 	uint32_t w = mpi->w;
 	uint32_t h = mpi->h;
 
+    if (!image)
+		return VO_TRUE;
+
     if (WinID != -1) Directx_ManageDisplay();
    
     if((mpi->flags&MP_IMGFLAG_DIRECT)||(mpi->flags&MP_IMGFLAG_DRAW_CALLBACK)) 


More information about the MPlayer-dev-eng mailing list