[vlc-commits] playlist: make LoopInput() an actual loop

Rémi Denis-Courmont git at videolan.org
Sun Nov 5 09:11:40 CET 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Nov  5 10:06:02 2017 +0200| [cb7499ec4ed8c605149f3e749d9b8cd7dad0f0c0] | committer: Rémi Denis-Courmont

playlist: make LoopInput() an actual loop

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

 src/playlist/thread.c | 51 ++++++++++++++++++++++++---------------------------
 1 file changed, 24 insertions(+), 27 deletions(-)

diff --git a/src/playlist/thread.c b/src/playlist/thread.c
index 1004757ac6..e37d70533a 100644
--- a/src/playlist/thread.c
+++ b/src/playlist/thread.c
@@ -426,32 +426,33 @@ static void LoopInput( playlist_t *p_playlist )
 
     assert( p_input != NULL );
 
-    if( p_sys->request.b_request || p_sys->killed )
+    /* Wait for input to end or be stopped */
+    while( !p_sys->request.input_dead )
     {
-        PL_DEBUG( "incoming request - stopping current input" );
-        input_Stop( p_input );
+        if( p_sys->request.b_request || p_sys->killed )
+        {
+            PL_DEBUG( "incoming request - stopping current input" );
+            input_Stop( p_input );
+        }
+        vlc_cond_wait( &p_sys->signal, &p_sys->lock );
     }
 
-    if( p_sys->request.input_dead )
-    {   /* This input is dead. Remove it ! */
-        p_sys->p_input = NULL;
-        p_sys->request.input_dead = false;
-        PL_DEBUG( "dead input" );
-        PL_UNLOCK;
+    /* This input is dead. Remove it ! */
+    PL_DEBUG( "dead input" );
+    p_sys->p_input = NULL;
+    p_sys->request.input_dead = false;
+    PL_UNLOCK;
 
-        var_SetAddress( p_playlist, "input-current", NULL );
+    var_SetAddress( p_playlist, "input-current", NULL );
 
-        /* WARNING: Input resource manipulation and callback deletion are
-         * incompatible with the playlist lock. */
-        if( !var_InheritBool( p_input, "sout-keep" ) )
-            input_resource_TerminateSout( p_sys->p_input_resource );
-        var_DelCallback( p_input, "intf-event", InputEvent, p_playlist );
+    /* WARNING: Input resource manipulation and callback deletion are
+     * incompatible with the playlist lock. */
+    if( !var_InheritBool( p_input, "sout-keep" ) )
+        input_resource_TerminateSout( p_sys->p_input_resource );
+    var_DelCallback( p_input, "intf-event", InputEvent, p_playlist );
 
-        input_Close( p_input );
-        PL_LOCK;
-    }
-    else
-        vlc_cond_wait( &p_sys->signal, &p_sys->lock );
+    input_Close( p_input );
+    PL_LOCK;
 }
 
 static bool Next( playlist_t *p_playlist )
@@ -485,15 +486,11 @@ static void *Thread ( void *data )
             continue;
         }
 
+        /* Playlist in running state */
         while( !p_sys->killed && Next( p_playlist ) )
-        {   /* Playlist in running state */
-            assert(p_sys->p_input != NULL);
-
-            do
-                LoopInput( p_playlist );
-            while( p_sys->p_input != NULL );
-        }
+            LoopInput( p_playlist );
 
+        /* Playlist stopping */
         msg_Dbg( p_playlist, "nothing to play" );
         if( var_InheritBool( p_playlist, "play-and-exit" ) )
         {



More information about the vlc-commits mailing list