[vlc-devel] [RFC PATCH] playlist: don't open failing items in loop

Thomas Guillem thomas at gllm.fr
Tue May 24 10:20:45 CEST 2016


If "Repeat All" or "Repeat current Item" option are set. The same failing item
will be opened in loop.

This is not fixing every case: In general, EsOut will fail because of an
unknown/bad codec and the "state" event will be END_S (and not ERROR_S).

This may be linked to my previous attempt to send an error status from the
Decoder or from the EsOut. This future error status should also be handled in
the playlist.
---
 include/vlc_playlist.h |  1 +
 src/playlist/engine.c  |  1 +
 src/playlist/item.c    |  1 +
 src/playlist/thread.c  | 15 ++++++++++++---
 4 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/include/vlc_playlist.h b/include/vlc_playlist.h
index 4363405..0b95ee8 100644
--- a/include/vlc_playlist.h
+++ b/include/vlc_playlist.h
@@ -142,6 +142,7 @@ struct playlist_item_t
     uint8_t                i_flags;     /**< Flags \see playlist_item_flags_e */
 
     playlist_t            *p_playlist;  /**< Parent playlist */
+    bool                   b_error;     /**< Item already opened with an error */
 };
 
 typedef enum {
diff --git a/src/playlist/engine.c b/src/playlist/engine.c
index 97f9e11..10506af 100644
--- a/src/playlist/engine.c
+++ b/src/playlist/engine.c
@@ -417,6 +417,7 @@ void set_current_status_item( playlist_t * p_playlist,
         /* It's unsafe given current design to delete a playlist item :(
         playlist_ItemDelete( pl_priv(p_playlist)->status.p_item ); */
     }
+    p_item->b_error = false;
     pl_priv(p_playlist)->status.p_item = p_item;
 }
 
diff --git a/src/playlist/item.c b/src/playlist/item.c
index a96a15e..10b0433 100644
--- a/src/playlist/item.c
+++ b/src/playlist/item.c
@@ -256,6 +256,7 @@ playlist_item_t *playlist_ItemNewFromInput( playlist_t *p_playlist,
     p_item->i_nb_played = 0;
     p_item->i_flags = 0;
     p_item->p_playlist = p_playlist;
+    p_item->b_error = false;
 
     install_input_item_observer( p_item );
 
diff --git a/src/playlist/thread.c b/src/playlist/thread.c
index 2d54850..625f95a 100644
--- a/src/playlist/thread.c
+++ b/src/playlist/thread.c
@@ -423,7 +423,8 @@ static playlist_item_t *NextItem( playlist_t *p_playlist )
 
         p_new = ARRAY_VAL( p_playlist->current, p_playlist->i_current_index );
         /* The new item can't be autoselected  */
-        if( p_new != NULL && p_new->i_flags & PLAYLIST_SKIP_FLAG )
+        if( p_new != NULL
+         && ( p_new->i_flags & PLAYLIST_SKIP_FLAG || p_new->b_error ) )
             return NULL;
     }
     return p_new;
@@ -442,13 +443,21 @@ static void LoopInput( playlist_t *p_playlist )
         input_Stop( p_input );
     }
 
-    switch( var_GetInteger( p_input, "state" ) )
+    int i_state = var_GetInteger( p_input, "state" );
+    switch( i_state )
     {
     case END_S:
     case ERROR_S:
     /* This input is dead. Remove it ! */
         p_sys->p_input = NULL;
-        PL_DEBUG( "dead input" );
+        if( i_state == ERROR_S )
+        {
+            p_sys->status.p_item->b_error = true;
+            PL_DEBUG( "dead input (error)" );
+        }
+        else
+            PL_DEBUG( "dead input" );
+
         PL_UNLOCK;
 
         var_SetAddress( p_playlist, "input-current", NULL );
-- 
2.8.1



More information about the vlc-devel mailing list