[vlc-devel] [RFC PATCH] decoder: fix input_DecoderWait not waiting for new data

Thomas Guillem thomas at gllm.fr
Tue Jul 19 16:58:40 CEST 2016


When an output data was played just after input_DecoderStartWait(), b_has_data
was immediately set to true. Consequently, input_DecoderWait() returned
immediately (since it waited for an old output data). This could cause the
input thread to stop waiting for the decoder while it didn't start to process
any input data.

To fix this issue, notify the input thread only when a new data (just after
decoder creation or after a flush) is played.
---
 src/input/decoder.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index 06e569d..b4944ee 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -108,6 +108,7 @@ struct decoder_owner_sys_t
     bool b_waiting;
     bool b_first;
     bool b_has_data;
+    bool b_new_data;
 
     /* Flushing */
     bool flushing;
@@ -707,9 +708,10 @@ static int DecoderPlaySout( decoder_t *p_dec, block_t *p_sout_block )
 
     vlc_mutex_lock( &p_owner->lock );
 
-    if( p_owner->b_waiting )
+    if( p_owner->b_waiting && p_owner->b_new_data )
     {
         p_owner->b_has_data = true;
+        p_owner->b_new_data = false;
         vlc_cond_signal( &p_owner->wait_acknowledge );
     }
 
@@ -871,9 +873,10 @@ static int DecoderPlayVideo( decoder_t *p_dec, picture_t *p_picture,
     /* */
     vlc_mutex_lock( &p_owner->lock );
 
-    if( p_owner->b_waiting && !p_owner->b_first )
+    if( p_owner->b_waiting && !p_owner->b_first && p_owner->b_new_data )
     {
         p_owner->b_has_data = true;
+        p_owner->b_new_data = false;
         vlc_cond_signal( &p_owner->wait_acknowledge );
     }
     bool b_first_after_wait = p_owner->b_waiting && p_owner->b_has_data;
@@ -1079,9 +1082,10 @@ static int DecoderPlayAudio( decoder_t *p_dec, block_t *p_audio,
 
     /* */
     vlc_mutex_lock( &p_owner->lock );
-    if( p_owner->b_waiting )
+    if( p_owner->b_waiting && p_owner->b_new_data )
     {
         p_owner->b_has_data = true;
+        p_owner->b_new_data = false;
         vlc_cond_signal( &p_owner->wait_acknowledge );
     }
 
@@ -1398,6 +1402,7 @@ static void DecoderProcessFlush( decoder_t *p_dec )
 
     vlc_mutex_lock( &p_owner->lock );
     p_owner->i_preroll_end = INT64_MIN;
+    p_owner->b_new_data = true;
     vlc_mutex_unlock( &p_owner->lock );
 }
 
@@ -1562,6 +1567,7 @@ static decoder_t * CreateDecoder( vlc_object_t *p_parent,
     p_owner->b_waiting = false;
     p_owner->b_first = true;
     p_owner->b_has_data = false;
+    p_owner->b_new_data = true;
 
     p_owner->flushing = false;
     p_owner->b_draining = false;
-- 
2.8.1



More information about the vlc-devel mailing list