Index: libvo/vo_direct3d.c =================================================================== --- libvo/vo_direct3d.c (revision 28284) +++ libvo/vo_direct3d.c (working copy) @@ -92,6 +92,9 @@ int osd_height; /**< current height of the OSD */ int osd_texture_width; /**< current width of the OSD texture */ int osd_texture_height; /**< current height of the OSD texture */ + int vo_uncooperative; /**< 1 = The video adapter is currently + uncooperative. Don't render, but + try to reset it on every frame */ } *priv; typedef struct { @@ -498,6 +501,22 @@ * if (mpi->flags & MP_IMGFLAG_DIRECT) ... */ + if (priv->vo_uncooperative) { + mp_msg(MSGT_VO, MSGL_V, "Trying to reinitialize the video adapter.\n"); + if (!reconfigure_d3d() || + FAILED(IDirect3DDevice9_TestCooperativeLevel(priv->d3d_device))) { + mp_msg(MSGT_VO, MSGL_V, "Reinitialization Failed.\n"); + return VO_TRUE; /* Behave like the frame is rendered. This prevents + MPlayer from quiting. Another reset will be tried + at every further call to this function. */ + } + else + { + mp_msg(MSGT_VO, MSGL_ERR, "Video adapter reinitialized.\n"); + priv->vo_uncooperative = 0; + } + } + if (mpi->flags & MP_IMGFLAG_DRAW_CALLBACK) goto skip_upload; @@ -787,21 +806,11 @@ */ static void flip_page(void) { - if (FAILED(IDirect3DDevice9_Present(priv->d3d_device, 0, 0, 0, 0))) { - mp_msg(MSGT_VO, MSGL_V, + if (!priv->vo_uncooperative && + FAILED(IDirect3DDevice9_Present(priv->d3d_device, 0, 0, 0, 0))) { + priv->vo_uncooperative = 1; + mp_msg(MSGT_VO, MSGL_ERR, "Video adapter became uncooperative.\n"); - mp_msg(MSGT_VO, MSGL_ERR, "Trying to reinitialize it...\n"); - if (!reconfigure_d3d()) { - mp_msg(MSGT_VO, MSGL_V, "Reinitialization Failed.\n"); - return; - } - if (FAILED(IDirect3DDevice9_Present(priv->d3d_device, 0, 0, 0, 0))) { - mp_msg(MSGT_VO, MSGL_V, "Reinitialization Failed.\n"); - return; - } - else - mp_msg(MSGT_VO, MSGL_V, "Video adapter reinitialized.\n"); - } } @@ -844,6 +853,11 @@ char *dst; /**< Pointer to the destination image */ int uv_stride; /**< Stride of the U/V planes */ + /* If the video adapter is currently uncooperative, behave like the current + slice is rendered and move on. */ + if (priv->vo_uncooperative) + return 0; /* Success */ + /* Lock the offscreen surface if it's not already locked. */ if (!priv->locked_rect.pBits) { if (FAILED(IDirect3DSurface9_LockRect(priv->d3d_surface,