[vlc-commits] decoder: fix slow video flush

Thomas Guillem git at videolan.org
Mon Nov 30 09:41:11 CET 2020


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Nov 27 16:18:44 2020 +0100| [9602cf7e738c5d3cc4f0b0156017110c844cdfb3] | committer: Thomas Guillem

decoder: fix slow video flush

Video flush was taking between 1 seconds to 10 seconds because the flush
request was not processed by the DecoderThread that was stuck in
pf_decode() callbacks waiting for new pictures.

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

 src/input/decoder.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index 8d67f7ea63..94e328f040 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -1470,6 +1470,11 @@ static void DecoderThread_Flush( vlc_input_decoder_t *p_owner )
     {
         if( p_owner->p_vout )
             vout_FlushAll( p_owner->p_vout );
+
+        /* Reset the pool cancel state, previously set by
+         * vlc_input_decoder_Flush() */
+        if( p_owner->out_pool != NULL )
+            picture_pool_Cancel( p_owner->out_pool, false );
     }
     else if( p_dec->fmt_out.i_cat == SPU_ES )
     {
@@ -2288,6 +2293,17 @@ void vlc_input_decoder_Flush( vlc_input_decoder_t *p_owner )
 
     vlc_fifo_Unlock( p_owner->p_fifo );
 
+    if ( p_owner->fmt.i_cat == VIDEO_ES )
+    {
+        /* Set the pool cancel state. This will unblock the module if it is
+         * waiting for new pictures (likely). This state will be reset back
+         * from the DecoderThread once the flush request is processed. */
+        vlc_mutex_lock( &p_owner->lock );
+        if( p_owner->out_pool != NULL )
+            picture_pool_Cancel( p_owner->out_pool, true );
+        vlc_mutex_unlock( &p_owner->lock );
+    }
+
     if( p_owner->paused )
     {
         /* The DecoderThread could be stuck in pf_decode(). This is likely the



More information about the vlc-commits mailing list