[vlc-devel] [PATCH 2/4] direct3d9: handle the wallpaper mode through a control call

Steve Lhomme robux4 at ycbcr.xyz
Fri Aug 17 11:08:50 CEST 2018


---
 modules/video_output/win32/direct3d9.c | 60 +++++---------------------
 1 file changed, 10 insertions(+), 50 deletions(-)

diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c
index d3def81868..0e4d6821eb 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -161,9 +161,6 @@ struct vout_display_sys_t
     bool                    lost_not_ready;
     bool                    clear_scene;
 
-    /* It protects the following variables */
-    vlc_mutex_t    lock;
-    bool           ch_desktop;
     bool           desktop_requested;
 };
 
@@ -211,9 +208,6 @@ static void Direct3D9ImportSubpicture(vout_display_t *vd, int *, d3d_region_t **
 
 static void Direct3D9RenderScene(vout_display_t *vd, d3d_region_t *, int, d3d_region_t *);
 
-/* */
-static int DesktopCallback(vlc_object_t *, char const *, vlc_value_t, vlc_value_t, void *);
-
 static bool is_d3d9_opaque(vlc_fourcc_t chroma)
 {
     switch (chroma)
@@ -281,7 +275,7 @@ static int Open(vlc_object_t *object)
     if (!sys->hxdll)
         msg_Warn(object, "cannot load Direct3D9 Shader Library; HLSL pixel shading will be disabled.");
 
-    sys->sys.use_desktop = var_CreateGetBool(vd, "video-wallpaper");
+    sys->sys.use_desktop = var_InheritBool(vd, "video-wallpaper");
     sys->reset_device = false;
     sys->reopen_device = false;
     sys->lost_not_ready = false;
@@ -320,12 +314,8 @@ static int Open(vlc_object_t *object)
         info.subpicture_chromas = NULL;
 
     /* Interaction */
-    vlc_mutex_init(&sys->lock);
-    sys->ch_desktop = false;
     sys->desktop_requested = sys->sys.use_desktop;
-
     var_Change(vd, "video-wallpaper", VLC_VAR_SETTEXT, _("Desktop"));
-    var_AddCallback(vd, "video-wallpaper", DesktopCallback, NULL);
 
     /* Setup vout_display now that everything is fine */
     video_format_Clean(&vd->fmt);
@@ -357,9 +347,6 @@ static void Close(vlc_object_t *object)
 {
     vout_display_t * vd = (vout_display_t *)object;
 
-    var_DelCallback(vd, "video-wallpaper", DesktopCallback, NULL);
-    vlc_mutex_destroy(&vd->sys->lock);
-
     Direct3D9Close(vd);
 
     CommonClean(vd);
@@ -634,10 +621,7 @@ static int ControlReopenDevice(vout_display_t *vd)
     EventThreadStop(sys->sys.event);
 
     /* */
-    vlc_mutex_lock(&sys->lock);
     sys->sys.use_desktop = sys->desktop_requested;
-    sys->ch_desktop = false;
-    vlc_mutex_unlock(&sys->lock);
 
     /* */
     event_cfg_t cfg;
@@ -708,6 +692,15 @@ static int Control(vout_display_t *vd, int query, va_list args)
             sys->reopen_device = false;
         }
         return VLC_SUCCESS;
+    case VOUT_DISPLAY_EVENT_SET_WALLPAPER:
+        if (sys->desktop_requested != *va_arg(args, bool *))
+        {
+            sys->desktop_requested = !sys->desktop_requested;
+            sys->reopen_device = true;
+            if (vd->info.has_pictures_invalid)
+                vout_display_SendEventPicturesInvalid(vd);
+        }
+        return VLC_SUCCESS;
     default:
         return CommonControl(vd, query, args);
     }
@@ -718,18 +711,6 @@ static void Manage (vout_display_t *vd)
 
     CommonManage(vd);
 
-    /* Desktop mode change */
-    vlc_mutex_lock(&sys->lock);
-    const bool ch_desktop = sys->ch_desktop;
-    sys->ch_desktop = false;
-    vlc_mutex_unlock(&sys->lock);
-
-    if (ch_desktop) {
-        sys->reopen_device = true;
-        if (vd->info.has_pictures_invalid)
-            vout_display_SendEventPicturesInvalid(vd);
-    }
-
     /* Position Change */
     if (sys->sys.changes & DX_POSITION_CHANGE) {
 #if 0 /* need that when bicubic filter is available */
@@ -1750,27 +1731,6 @@ static void Direct3D9RenderScene(vout_display_t *vd,
     }
 }
 
-/*****************************************************************************
- * DesktopCallback: desktop mode variable callback
- *****************************************************************************/
-static int DesktopCallback(vlc_object_t *object, char const *psz_cmd,
-                            vlc_value_t oldval, vlc_value_t newval,
-                            void *p_data)
-{
-    vout_display_t *vd = (vout_display_t *)object;
-    vout_display_sys_t *sys = vd->sys;
-    VLC_UNUSED(psz_cmd);
-    VLC_UNUSED(oldval);
-    VLC_UNUSED(p_data);
-
-    vlc_mutex_lock(&sys->lock);
-    const bool ch_desktop = !sys->desktop_requested != !newval.b_bool;
-    sys->ch_desktop |= ch_desktop;
-    sys->desktop_requested = newval.b_bool;
-    vlc_mutex_unlock(&sys->lock);
-    return VLC_SUCCESS;
-}
-
 typedef struct
 {
     char **values;
-- 
2.17.0



More information about the vlc-devel mailing list