]> git.sesse.net Git - vlc/commitdiff
Fixed a deadlock between ressources freeing and playlist through gui.
authorLaurent Aimar <fenrir@videolan.org>
Sat, 24 Jan 2009 10:17:20 +0000 (11:17 +0100)
committerLaurent Aimar <fenrir@videolan.org>
Sat, 24 Jan 2009 10:27:39 +0000 (11:27 +0100)
src/playlist/thread.c

index b2ad6768f1841d504a0d548829594f2b1feba503..3005793f3960b7c4e3c7734774a5165492fa233b 100644 (file)
@@ -484,13 +484,17 @@ static int LoopInput( playlist_t *p_playlist )
         assert( p_sys->p_input_ressource == NULL );
 
         p_sys->p_input_ressource = input_DetachRessource( p_input );
+
+        PL_UNLOCK;
+        /* We can unlock as we return VLC_EGENERIC (no event will be lost) */
+
+        /* input_ressource_t must be manipulated without playlist lock */
         if( !var_CreateGetBool( p_input, "sout-keep" ) )
             input_ressource_TerminateSout( p_sys->p_input_ressource );
 
-        /* The DelCallback must be issued without playlist lock
-         * It is not a problem as we return VLC_EGENERIC */
-        PL_UNLOCK;
+        /* The DelCallback must be issued without playlist lock */
         var_DelCallback( p_input, "intf-event", InputEvent, p_playlist );
+
         PL_LOCK;
 
         p_sys->p_input = NULL;
@@ -533,12 +537,24 @@ static void LoopRequest( playlist_t *p_playlist )
     {
         p_sys->status.i_status = PLAYLIST_STOPPED;
 
-        if( p_sys->p_input_ressource )
+        if( p_sys->p_input_ressource &&
+            input_ressource_HasVout( p_sys->p_input_ressource ) )
+        {
+            /* XXX We can unlock if we don't issue the wait as we will be
+             * call again without anything else done between the calls */
+            PL_UNLOCK;
+
+            /* input_ressource_t must be manipulated without playlist lock */
             input_ressource_TerminateVout( p_sys->p_input_ressource );
 
-        if( vlc_object_alive( p_playlist ) )
-            vlc_cond_wait( &pl_priv(p_playlist)->signal,
-                           &vlc_internals(p_playlist)->lock );
+            PL_LOCK;
+        }
+        else
+        {
+            if( vlc_object_alive( p_playlist ) )
+                vlc_cond_wait( &pl_priv(p_playlist)->signal,
+                               &vlc_internals(p_playlist)->lock );
+        }
         return;
     }