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

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


---
 modules/video_output/win32/directdraw.c | 54 +++++--------------------
 1 file changed, 9 insertions(+), 45 deletions(-)

diff --git a/modules/video_output/win32/directdraw.c b/modules/video_output/win32/directdraw.c
index 121c0563e9..59d51729f6 100644
--- a/modules/video_output/win32/directdraw.c
+++ b/modules/video_output/win32/directdraw.c
@@ -157,9 +157,6 @@ struct vout_display_sys_t
 
     picture_sys_t        *picsys;
 
-    /* It protects the following variables */
-    vlc_mutex_t    lock;
-    bool           ch_wallpaper;
     bool           wallpaper_requested;
 };
 
@@ -169,9 +166,6 @@ static int            Control(vout_display_t *, int, va_list);
 static void           Manage (vout_display_t *);
 
 /* */
-static int WallpaperCallback(vlc_object_t *, char const *,
-                             vlc_value_t, vlc_value_t, void *);
-
 static int  DirectXOpen(vout_display_t *, video_format_t *fmt);
 static void DirectXClose(vout_display_t *);
 
@@ -203,7 +197,7 @@ static int Open(vlc_object_t *object)
     }
 
     /* */
-    sys->use_wallpaper = var_CreateGetBool(vd, "video-wallpaper");
+    sys->use_wallpaper = var_InheritBool(vd, "video-wallpaper");
     /* FIXME */
     sys->sys.use_overlay = false;//var_CreateGetBool(vd, "overlay"); /* FIXME */
     sys->restore_overlay = false;
@@ -226,13 +220,10 @@ static int Open(vlc_object_t *object)
     info.has_pictures_invalid = true;
 
     /* Interaction TODO support starting with wallpaper mode */
-    vlc_mutex_init(&sys->lock);
-    sys->ch_wallpaper = sys->use_wallpaper;
     sys->wallpaper_requested = sys->use_wallpaper;
     sys->use_wallpaper = false;
 
     var_Change(vd, "video-wallpaper", VLC_VAR_SETTEXT, _("Wallpaper"));
-    var_AddCallback(vd, "video-wallpaper", WallpaperCallback, NULL);
 
     /* Setup vout_display now that everything is fine */
     video_format_Clean(&vd->fmt);
@@ -261,9 +252,6 @@ static void Close(vlc_object_t *object)
     vout_display_t *vd = (vout_display_t *)object;
     vout_display_sys_t *sys = vd->sys;
 
-    var_DelCallback(vd, "video-wallpaper", WallpaperCallback, NULL);
-    vlc_mutex_destroy(&sys->lock);
-
     /* Make sure the wallpaper is restored */
     WallpaperChange(vd, false);
 
@@ -352,16 +340,18 @@ static int Control(vout_display_t *vd, int query, va_list args)
         DirectXClose(vd);
         /* Make sure the wallpaper is restored */
         if (sys->use_wallpaper) {
-            vlc_mutex_lock(&sys->lock);
-            if (!sys->ch_wallpaper) {
-                sys->ch_wallpaper = true;
-                sys->wallpaper_requested = true;
-            }
-            vlc_mutex_unlock(&sys->lock);
+            sys->wallpaper_requested = true;
 
             WallpaperChange(vd, false);
         }
         return DirectXOpen(vd, &vd->fmt);
+    case VOUT_DISPLAY_EVENT_SET_WALLPAPER:
+        if (sys->wallpaper_requested != *va_arg(args, bool *))
+        {
+            sys->wallpaper_requested = !sys->wallpaper_requested;
+            WallpaperChange(vd, sys->wallpaper_requested);
+        }
+        return VLC_SUCCESS;
     default:
         return CommonControl(vd, query, args);
     }
@@ -386,16 +376,6 @@ static void Manage(vout_display_t *vd)
         sys->sys.changes &= ~DX_POSITION_CHANGE;
     }
 
-    /* Wallpaper mode change */
-    vlc_mutex_lock(&sys->lock);
-    const bool ch_wallpaper = sys->ch_wallpaper;
-    const bool wallpaper_requested = sys->wallpaper_requested;
-    sys->ch_wallpaper = false;
-    vlc_mutex_unlock(&sys->lock);
-
-    if (ch_wallpaper)
-        WallpaperChange(vd, wallpaper_requested);
-
     /* */
     if (sys->restore_overlay)
         DirectXUpdateOverlay(vd, NULL);
@@ -1428,22 +1408,6 @@ static void WallpaperChange(vout_display_t *vd, bool use_wallpaper)
       DirectXUpdateOverlay(vd, NULL);
 }
 
-/* */
-static int WallpaperCallback(vlc_object_t *object, char const *cmd,
-                             vlc_value_t oldval, vlc_value_t newval, void *data)
-{
-    vout_display_t *vd = (vout_display_t *)object;
-    vout_display_sys_t *sys = vd->sys;
-    VLC_UNUSED(cmd); VLC_UNUSED(oldval); VLC_UNUSED(data);
-
-    vlc_mutex_lock(&sys->lock);
-    const bool ch_wallpaper = !sys->wallpaper_requested != !newval.b_bool;
-    sys->ch_wallpaper |= ch_wallpaper;
-    sys->wallpaper_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