[vlc-devel] [PATCH] decoder: fix mistake old picture and audio block for the first one

Zhao Zhili quinkblack at foxmail.com
Tue Jan 2 16:45:07 CET 2018


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

diff --git a/src/input/decoder.c b/src/input/decoder.c
index b94d6da169..849ff26458 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -987,6 +987,7 @@ static int DecoderPlayVideo( decoder_t *p_dec, picture_t *p_picture,
 {
     decoder_owner_sys_t *p_owner = p_dec->p_owner;
     vout_thread_t  *p_vout = p_owner->p_vout;
+    bool flushing;
     bool prerolled;
 
     vlc_mutex_lock( &p_owner->lock );
@@ -1029,6 +1030,16 @@ static int DecoderPlayVideo( decoder_t *p_dec, picture_t *p_picture,
 
     if( p_owner->b_waiting )
     {
+        vlc_fifo_Lock( p_owner->p_fifo );
+        flushing = p_owner->flushing;
+        vlc_fifo_Unlock( p_owner->p_fifo );
+        if( flushing )
+        {
+            vlc_mutex_unlock( &p_owner->lock );
+            picture_Release( p_picture );
+            return -1;
+        }
+
         assert( p_owner->b_first );
         msg_Dbg( p_dec, "Received first picture" );
         p_owner->b_first = false;
@@ -1127,6 +1138,7 @@ static int DecoderPlayAudio( decoder_t *p_dec, block_t *p_audio,
                              unsigned *restrict pi_lost_sum )
 {
     decoder_owner_sys_t *p_owner = p_dec->p_owner;
+    bool flushing;
     bool prerolled;
 
     assert( p_audio != NULL );
@@ -1164,6 +1176,16 @@ static int DecoderPlayAudio( decoder_t *p_dec, block_t *p_audio,
     vlc_mutex_lock( &p_owner->lock );
     if( p_owner->b_waiting )
     {
+        vlc_fifo_Lock( p_owner->p_fifo );
+        flushing = p_owner->flushing;
+        vlc_fifo_Unlock( p_owner->p_fifo );
+        if( flushing )
+        {
+            vlc_mutex_unlock( &p_owner->lock );
+            block_Release( p_audio );
+            return -1;
+        }
+
         p_owner->b_has_data = true;
         vlc_cond_signal( &p_owner->wait_acknowledge );
     }
-- 
2.14.2





More information about the vlc-devel mailing list