[vlc-commits] playlist: fix signaling dead input

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


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Nov  5 09:44:57 2017 +0200| [c470bfaef181d3bb241c780aadc4f058d40b3474] | committer: Rémi Denis-Courmont

playlist: fix signaling dead input

This ensures that the dead event input is not missed. The condition
variable was not used properly.

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

 src/playlist/engine.c            |  1 +
 src/playlist/playlist_internal.h |  1 +
 src/playlist/thread.c            | 19 +++++++++----------
 3 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/playlist/engine.c b/src/playlist/engine.c
index 680366cd09..7302a2ef1b 100644
--- a/src/playlist/engine.c
+++ b/src/playlist/engine.c
@@ -251,6 +251,7 @@ playlist_t *playlist_Create( vlc_object_t *p_parent )
     pl_priv(p_playlist)->status.p_item = NULL;
     pl_priv(p_playlist)->status.p_node = p_playlist->p_playing;
     pl_priv(p_playlist)->request.b_request = false;
+    p->request.input_dead = false;
 
     if (ml != NULL)
         playlist_MLLoad( p_playlist );
diff --git a/src/playlist/playlist_internal.h b/src/playlist/playlist_internal.h
index 3515a898bd..ae48c75e87 100644
--- a/src/playlist/playlist_internal.h
+++ b/src/playlist/playlist_internal.h
@@ -76,6 +76,7 @@ typedef struct playlist_private_t
         bool          b_request;/**< Set to true by the requester
                                            The playlist sets it back to false
                                            when processing the request */
+        bool input_dead; /**< Set when input has finished. */
     } request;
 
     vlc_thread_t thread; /**< engine thread */
diff --git a/src/playlist/thread.c b/src/playlist/thread.c
index 8f1ad96821..1004757ac6 100644
--- a/src/playlist/thread.c
+++ b/src/playlist/thread.c
@@ -99,9 +99,11 @@ static int InputEvent( vlc_object_t *p_this, char const *psz_cmd,
 
     if( newval.i_int == INPUT_EVENT_DEAD )
     {
+        playlist_private_t *sys = pl_priv(p_playlist);
+
         PL_LOCK;
-        /* XXX: signaling while not changing any parameter... suspicious... */
-        vlc_cond_signal( &pl_priv(p_playlist)->signal );
+        sys->request.input_dead = true;
+        vlc_cond_signal( &sys->signal );
         PL_UNLOCK;
     }
     return VLC_SUCCESS;
@@ -430,12 +432,10 @@ static void LoopInput( playlist_t *p_playlist )
         input_Stop( p_input );
     }
 
-    switch( var_GetInteger( p_input, "state" ) )
-    {
-    case END_S:
-    case ERROR_S:
-    /* This input is dead. Remove it ! */
+    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;
 
@@ -449,10 +449,9 @@ static void LoopInput( playlist_t *p_playlist )
 
         input_Close( p_input );
         PL_LOCK;
-        break;
-    default:
-        vlc_cond_wait( &p_sys->signal, &p_sys->lock );
     }
+    else
+        vlc_cond_wait( &p_sys->signal, &p_sys->lock );
 }
 
 static bool Next( playlist_t *p_playlist )



More information about the vlc-commits mailing list