[MPlayer-dev-eng] Re: [PATCH] Let vo directx survive screensaver
Zuxy Meng
zuxy.meng at gmail.com
Sat Nov 18 15:50:28 CET 2006
Hi,
2006/11/18, Sascha Sommer <saschasommer at freenet.de>:
> Hi,
>
> Not from my side.
> Please add the image == NULL checks to the other functions, too.
>
Like this?
--
Zuxy
Beauty is truth,
While truth is beauty.
PGP KeyID: E8555ED6
-------------- next part --------------
Index: libvo/vo_directx.c
===================================================================
--- libvo/vo_directx.c ???????? 21020??
+++ libvo/vo_directx.c ????????????
@@ -147,6 +147,8 @@
static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src,
unsigned char *srca, int stride)
{
+ if (!image)
+ return;
switch(image_format) {
case IMGFMT_YV12 :
case IMGFMT_I420 :
@@ -679,7 +681,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 +714,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
@@ -1122,6 +1126,9 @@
uint8_t *s;
uint8_t *d;
uint32_t i=0, uvstride=dstride/2;
+
+ if (!image)
+ return 0;
// copy Y
d=image+dstride*y+x;
s=src[0];
@@ -1155,6 +1162,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");
@@ -1179,12 +1192,15 @@
static int draw_frame(uint8_t *src[])
{
- memcpy( image, *src, dstride * image_height );
+ if (image)
+ memcpy( image, *src, dstride * image_height );
return 0;
}
static uint32_t get_image(mp_image_t *mpi)
{
+ if (!image)
+ return VO_TRUE;
if(mpi->flags&MP_IMGFLAG_READABLE) {mp_msg(MSGT_VO, MSGL_V,"<vo_directx><ERROR>slow video ram\n");return VO_FALSE;}
if(mpi->type==MP_IMGTYPE_STATIC) {mp_msg(MSGT_VO, MSGL_V,"<vo_directx><ERROR>not static\n");return VO_FALSE;}
if((mpi->width==dstride) || (mpi->flags&(MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_ACCEPT_WIDTH)))
@@ -1231,6 +1247,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