[vlc-commits] Direct3D: add a new state handling when the device is lost but cannot be reset yet.

Felix Abecassis git at videolan.org
Wed Jan 22 11:21:30 CET 2014


vlc/vlc-2.1 | branch: master | Felix Abecassis <felix.abecassis at gmail.com> | Tue Jan 21 11:30:12 2014 +0100| [1e62e4d15a72e65d54ce69245a3ea50d459682d3] | committer: Jean-Baptiste Kempf

Direct3D: add a new state handling when the device is lost but cannot be reset yet.

In this state, do not call Direct3D functions and exit the "Display"
and "Prepare" functions early.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
(cherry picked from commit 7cbbe5646819afbf3f5618d5827e6c066dd5a04f)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.1.git/?a=commit;h=1e62e4d15a72e65d54ce69245a3ea50d459682d3
---

 modules/video_output/msw/common.h   |    1 +
 modules/video_output/msw/direct3d.c |   13 +++++++++++++
 2 files changed, 14 insertions(+)

diff --git a/modules/video_output/msw/common.h b/modules/video_output/msw/common.h
index 12a4f55..c5d3fbc 100644
--- a/modules/video_output/msw/common.h
+++ b/modules/video_output/msw/common.h
@@ -151,6 +151,7 @@ struct vout_display_sys_t
     /* */
     bool                    reset_device;
     bool                    reopen_device;
+    bool                    lost_not_ready;
     bool                    clear_scene;
 
     /* It protects the following variables */
diff --git a/modules/video_output/msw/direct3d.c b/modules/video_output/msw/direct3d.c
index e1dd62d..7920cd4 100644
--- a/modules/video_output/msw/direct3d.c
+++ b/modules/video_output/msw/direct3d.c
@@ -162,6 +162,7 @@ static int Open(vlc_object_t *object)
     sys->use_desktop = var_CreateGetBool(vd, "video-wallpaper");
     sys->reset_device = false;
     sys->reopen_device = false;
+    sys->lost_not_ready = false;
     sys->allow_hw_yuv = var_CreateGetBool(vd, "directx-hw-yuv");
     sys->desktop_save.is_fullscreen = vd->cfg->is_fullscreen;
     sys->desktop_save.is_on_top     = false;
@@ -284,6 +285,11 @@ static void Prepare(vout_display_t *vd, picture_t *picture, subpicture_t *subpic
         if (hr == D3DERR_DEVICENOTRESET && !sys->reset_device) {
             vout_display_SendEventPicturesInvalid(vd);
             sys->reset_device = true;
+            sys->lost_not_ready = false;
+        }
+        if (hr == D3DERR_DEVICELOST && !sys->lost_not_ready) {
+            /* Device is lost but not yet ready for reset. */
+            sys->lost_not_ready = true;
         }
         return;
     }
@@ -310,6 +316,13 @@ static void Display(vout_display_t *vd, picture_t *picture, subpicture_t *subpic
     vout_display_sys_t *sys = vd->sys;
     LPDIRECT3DDEVICE9 d3ddev = sys->d3ddev;
 
+    if (sys->lost_not_ready) {
+        picture_Release(picture);
+        if (subpicture)
+            subpicture_Delete(subpicture);
+        return;
+    }
+
     // Present the back buffer contents to the display
     // No stretching should happen here !
     const RECT src = sys->rect_dest_clipped;



More information about the vlc-commits mailing list