]> git.sesse.net Git - vlc/commitdiff
drawable: handle the case that drawable is per-input
authorRémi Denis-Courmont <rdenis@simphalempin.com>
Sat, 7 Feb 2009 08:47:45 +0000 (10:47 +0200)
committerRémi Denis-Courmont <rdenis@simphalempin.com>
Sat, 7 Feb 2009 08:49:55 +0000 (10:49 +0200)
It only works -properly- if there is only one video output. This is no
worse than earlier releases.

Pointed-out-by: brezhoneg1
modules/video_output/drawable.c

index 113ddb130bea79fc764018aaf99f16e4665ffdbd..b904ff9b9ebd15ecac4cf1f01e5e27c0f691f7b6 100644 (file)
@@ -63,22 +63,37 @@ static int Open (vlc_object_t *obj, const char *varname, bool ptr)
 {
     static vlc_mutex_t serializer = VLC_STATIC_MUTEX;
     vout_window_t *wnd = (vout_window_t *)obj;
-    vlc_value_t val;
+    vlc_value_t val, globval;
 
-    if (var_Create (obj->p_libvlc, "drawable-busy", VLC_VAR_BOOL))
+    if (var_Create (obj->p_libvlc, "drawable-busy", VLC_VAR_BOOL)
+     || var_Create (obj, varname, VLC_VAR_DOINHERIT
+                                  | (ptr ? VLC_VAR_ADDRESS : VLC_VAR_INTEGER)))
         return VLC_ENOMEM;
+    var_Get (obj, varname, &val);
 
     vlc_mutex_lock (&serializer);
     /* Note: We cannot simply clear the drawable variable.
      * It would break libvlc_video_get_parent(). */
-    if (!var_GetBool (obj->p_libvlc, "drawable-busy"))
+    var_Get (obj->p_libvlc, varname, &globval);
+    if (ptr ? (val.p_address == globval.p_address)
+            : (val.i_int == globval.i_int))
     {
-        var_Get (obj->p_libvlc, varname, &val);
-        if (ptr ? (val.p_address != NULL): (val.i_int == 0))
+        if (var_GetBool (obj->p_libvlc, "drawable-busy"))
+        {   /* LibVLC-wide drawable already in use */
+            if (ptr)
+                val.p_address = NULL;
+            else
+                val.i_int = 0;
+        }
+        else
             var_SetBool (obj->p_libvlc, "drawable-busy", true);
     }
+    /* If we got a drawable _not_ from the root object (from the input?),
+     * We assume it is not busy. This is a bug. */
     vlc_mutex_unlock (&serializer);
 
+    var_Destroy (obj, varname);
+
     if (ptr ? (val.p_address == NULL) : (val.i_int == 0))
     {
         var_Destroy (obj->p_libvlc, "drawable-busy");