[vlc-devel] [RFC PATCH 3.0.x] input: clear EOF flags of slave sources when select track

Zhao Zhili quinkblack at foxmail.com
Fri Nov 13 15:06:37 CET 2020


input-slave was broken for some demuxers like mp4. If no track is
selected, slave demuxer return EOF at the beginning. Selecting
a track of slave input doesn't work since the input source is
in the EOF status. For VLC users, seeking after select track is a
workaround solution, because seek will reset the EOF flag.

Since a video track can be enabled at random position and there is
no preroll, it can lead to corrupted frames.
---
 src/input/input.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/input/input.c b/src/input/input.c
index 1b8a2eb83d..dd4b487d20 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -1006,6 +1006,15 @@ static bool SlaveExists( input_item_slave_t **pp_slaves, int i_slaves,
     return false;
 }
 
+static void SlaveSetEof( input_thread_t *p_input, bool b_eof )
+{
+    for( int i = 0; i < input_priv(p_input)->i_slave; i++ )
+    {
+        input_source_t *in = input_priv(p_input)->slave[i];
+        in->b_eof = b_eof;
+    }
+}
+
 static void SetSubtitlesOptions( input_thread_t *p_input )
 {
     /* Get fps and set it if not already set */
@@ -2170,6 +2179,8 @@ static bool Control( input_thread_t *p_input,
                             ES_OUT_SET_ES_BY_ID, (int)val.i_int );
 
             demux_Control( input_priv(p_input)->master->p_demux, DEMUX_SET_ES, (int)val.i_int );
+            if( val.i_int >= 0 )
+                SlaveSetEof( p_input, false );
             break;
 
         case INPUT_CONTROL_RESTART_ES:
-- 
2.28.0



More information about the vlc-devel mailing list