[vlc-devel] [PATCH] [RFC] apply the same flush on the sout than on aout/vout

Steve Lhomme robux4 at videolabs.io
Tue Nov 10 16:47:37 CET 2015


When seeking during a sout session, we send discontinuities to the receiver(s),
resulting in apps possibly stopping because of incoherent data.

There remains the question of pre-roll when seeking. Should we send it to the
receiver(s) or not ?
---
 src/input/decoder.c               | 39 ++++++++++++++++++++++-----------------
 src/stream_output/stream_output.c | 11 ++++++++++-
 2 files changed, 32 insertions(+), 18 deletions(-)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index 8da034a..d32ea9b 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -707,7 +707,7 @@ static int DecoderPlaySout( decoder_t *p_dec, block_t *p_sout_block )
 
 /* This function process a block for sout
  */
-static void DecoderProcessSout( decoder_t *p_dec, block_t *p_block )
+static void DecoderProcessSout( decoder_t *p_dec, block_t *p_block, bool b_flush )
 {
     decoder_owner_sys_t *p_owner = (decoder_owner_sys_t *)p_dec->p_owner;
     block_t *p_sout_block;
@@ -764,6 +764,14 @@ static void DecoderProcessSout( decoder_t *p_dec, block_t *p_block )
             p_sout_block = p_next;
         }
     }
+    /* The packetizer does not output a block that tell the decoder to flush
+     * do it ourself */
+    if( b_flush )
+    {
+        block_t *p_null = DecoderBlockFlushNew();
+        if( p_null )
+            DecoderPlaySout( p_dec, p_null );
+    }
 }
 #endif
 
@@ -1269,29 +1277,26 @@ static void DecoderProcess( decoder_t *p_dec, block_t *p_block )
         return;
     }
 
+    bool b_flush = false;
+
+    if( p_block )
+    {
+        const bool b_flushing = p_owner->i_preroll_end == INT64_MAX;
+        DecoderUpdatePreroll( &p_owner->i_preroll_end, p_block );
+
+        b_flush = !b_flushing && b_flush_request;
+
+        p_block->i_flags &= ~BLOCK_FLAG_CORE_PRIVATE_MASK;
+    }
+
 #ifdef ENABLE_SOUT
     if( p_owner->b_packetizer )
     {
-        if( p_block )
-            p_block->i_flags &= ~BLOCK_FLAG_CORE_PRIVATE_MASK;
-
-        DecoderProcessSout( p_dec, p_block );
+        DecoderProcessSout( p_dec, p_block, b_flush );
     }
     else
 #endif
     {
-        bool b_flush = false;
-
-        if( p_block )
-        {
-            const bool b_flushing = p_owner->i_preroll_end == INT64_MAX;
-            DecoderUpdatePreroll( &p_owner->i_preroll_end, p_block );
-
-            b_flush = !b_flushing && b_flush_request;
-
-            p_block->i_flags &= ~BLOCK_FLAG_CORE_PRIVATE_MASK;
-        }
-
         if( p_dec->fmt_out.i_cat == AUDIO_ES )
         {
             DecoderProcessAudio( p_dec, p_block, b_flush );
diff --git a/src/stream_output/stream_output.c b/src/stream_output/stream_output.c
index 3d87b9b..62e2749 100644
--- a/src/stream_output/stream_output.c
+++ b/src/stream_output/stream_output.c
@@ -515,7 +515,16 @@ int sout_MuxSendBuffer( sout_mux_t *p_mux, sout_input_t *p_input,
                          block_t *p_buffer )
 {
     mtime_t i_dts = p_buffer->i_dts;
-    block_FifoPut( p_input->p_fifo, p_buffer );
+
+    if ( p_buffer->i_flags & BLOCK_FLAG_DISCONTINUITY)
+    {
+        msg_Dbg(p_mux, "discontinuity, flush the FIFO");
+        block_FifoEmpty( p_input->p_fifo );
+    }
+    else
+    {
+        block_FifoPut( p_input->p_fifo, p_buffer );
+    }
 
     if( p_mux->p_sout->i_out_pace_nocontrol )
     {
-- 
2.6.2



More information about the vlc-devel mailing list