[vlc-commits] decoder: fix flush while paused with some async decoders

Thomas Guillem git at videolan.org
Tue Feb 4 15:04:38 CET 2020


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Jan 31 10:33:07 2020 +0100| [c201f7e6eb5232f0afa27c4290390eecd556733c] | committer: Thomas Guillem

decoder: fix flush while paused with some async decoders

This will allow to remove a hack on MediaCodec. Other asynchronous decoders
could benefit from it too.

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

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

diff --git a/src/input/decoder.c b/src/input/decoder.c
index 251be90592..bc279208ab 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -2337,6 +2337,26 @@ void input_DecoderFlush( decoder_t *p_dec )
     vlc_fifo_Signal( p_owner->p_fifo );
 
     vlc_fifo_Unlock( p_owner->p_fifo );
+
+    if( p_owner->paused )
+    {
+        /* The DecoderThread could be stuck in pf_decode(). This is likely the
+         * case with paused asynchronous decoder modules that have a limited
+         * input and output pool size. Indeed, with such decoders, you have to
+         * release an output buffer to get an input buffer. So, when paused and
+         * flushed, the DecoderThread could be waiting for an output buffer to
+         * be released (or rendered). In that case, the DecoderThread will
+         * never be flushed since it be never leave pf_decode(). To fix this
+         * issue, pre-flush the vout from here. The vout will have to be
+         * flushed again since the module could be outputting more buffers just
+         * after being unstuck. */
+
+        vlc_mutex_lock( &p_owner->lock );
+        if( p_dec->fmt_out.i_cat == VIDEO_ES
+         && p_owner->p_vout && p_owner->vout_thread_started )
+            vout_FlushAll( p_owner->p_vout );
+        vlc_mutex_unlock( &p_owner->lock );
+    }
 }
 
 void input_DecoderGetCcDesc( decoder_t *p_dec, decoder_cc_desc_t *p_desc )



More information about the vlc-commits mailing list