[MPlayer-dev-eng] [PATCH] Direct3D VO better handling of uncooperative video adapter

Georgi Petrov gogothebee at gmail.com
Tue Feb 3 10:41:10 CET 2009


> I think it might be because reconfigure_d3d has already released the device.
> In that case, you do not need that uncooperative variable but can just check for
> if (!priv->d3d_device) ...

Great. I submit much simpler patch, which works very well and changes
only a few lines to to the same. I check exactly for
!priv->d3d_device. Please, take a look.
-------------- next part --------------
Index: libvo/vo_direct3d.c
===================================================================
--- libvo/vo_direct3d.c	(revision 28450)
+++ libvo/vo_direct3d.c	(working copy)
@@ -565,6 +565,11 @@
      * if (mpi->flags & MP_IMGFLAG_DIRECT) ...
      */
 
+    /* If the D3D device is uncooperative (not initialized), return success.
+       The device will be probed for reinitialization in the next flip_page() */
+    if (!priv->d3d_device)
+        return VO_TRUE;
+
     if (mpi->flags & MP_IMGFLAG_DRAW_CALLBACK)
         goto skip_upload;
 
@@ -857,21 +862,16 @@
 static void flip_page(void)
 {
     RECT rect = {0, 0, vo_dwidth, vo_dheight};
-    if (FAILED(IDirect3DDevice9_Present(priv->d3d_device, &rect, 0, 0, 0))) {
+    if (!priv->d3d_device ||
+        FAILED(IDirect3DDevice9_Present(priv->d3d_device, &rect, 0, 0, 0))) {
         mp_msg(MSGT_VO, MSGL_V,
-               "<vo_direct3d>Video adapter became uncooperative.\n");
-        mp_msg(MSGT_VO, MSGL_ERR, "<vo_direct3d>Trying to reinitialize it...\n");
+               "<vo_direct3d>Trying to reinitialize uncooperative video adapter.\n");
         if (!reconfigure_d3d()) {
-            mp_msg(MSGT_VO, MSGL_V, "<vo_direct3d>Reinitialization Failed.\n");
+            mp_msg(MSGT_VO, MSGL_V, "<vo_direct3d>Reinitialization failed.\n");
             return;
         }
-        if (FAILED(IDirect3DDevice9_Present(priv->d3d_device, &rect, 0, 0, 0))) {
-            mp_msg(MSGT_VO, MSGL_V, "<vo_direct3d>Reinitialization Failed.\n");
-            return;
-        }
         else
             mp_msg(MSGT_VO, MSGL_V, "<vo_direct3d>Video adapter reinitialized.\n");
-
     }
 }
 
@@ -914,6 +914,11 @@
     char *dst;      /**< Pointer to the destination image */
     int  uv_stride; /**< Stride of the U/V planes */
 
+    /* If the D3D device is uncooperative (not initialized), return success.
+       The device will be probed for reinitialization in the next flip_page() */
+    if (!priv->d3d_device)
+        return 0;
+
     /* Lock the offscreen surface if it's not already locked. */
     if (!priv->locked_rect.pBits) {
         if (FAILED(IDirect3DSurface9_LockRect(priv->d3d_surface,


More information about the MPlayer-dev-eng mailing list