[vlc-devel] [PATCH 09/11] decoder: avoid unlock/lock when we don't need to

Steve Lhomme robux4 at ycbcr.xyz
Fri Aug 30 08:27:00 CEST 2019


The p_vout/p_aout are flushed under lock in other places and they are modified
under lock so need to be read under lock.
---
 src/input/decoder.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index b37d8b1c22..62eff2ef08 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -976,7 +976,6 @@ static void DecoderQueueCc( decoder_t *p_videodec, block_t *p_cc,
 static int DecoderPlayVideo( struct decoder_owner *p_owner, picture_t *p_picture )
 {
     decoder_t *p_dec = &p_owner->dec;
-    vout_thread_t  *p_vout = p_owner->p_vout;
 
     if( p_picture->date == VLC_TICK_INVALID )
         /* FIXME: VLC_TICK_INVALID -- verify video_output */
@@ -996,19 +995,16 @@ static int DecoderPlayVideo( struct decoder_owner *p_owner, picture_t *p_picture
     }
 
     p_owner->i_preroll_end = (vlc_tick_t)INT64_MIN;
-    vlc_mutex_unlock( &p_owner->lock );
 
     if( unlikely(prerolled) )
     {
         msg_Dbg( p_dec, "end of video preroll" );
 
-        if( p_vout )
-            vout_FlushAll( p_vout );
+        if( p_owner->p_vout )
+            vout_FlushAll( p_owner->p_vout );
     }
 
     /* */
-    vlc_mutex_lock( &p_owner->lock );
-
     if( p_owner->b_waiting && !p_owner->b_first )
     {
         p_owner->b_has_data = true;
@@ -1025,6 +1021,7 @@ static int DecoderPlayVideo( struct decoder_owner *p_owner, picture_t *p_picture
         p_picture->b_force = true;
     }
 
+    vout_thread_t  *p_vout = p_owner->p_vout;
     vlc_mutex_unlock( &p_owner->lock );
 
     /* FIXME: The *input* FIFO should not be locked here. This will not work
@@ -1128,7 +1125,6 @@ static int DecoderPlayAudio( struct decoder_owner *p_owner, block_t *p_audio )
     }
 
     p_owner->i_preroll_end = (vlc_tick_t)INT64_MIN;
-    vlc_mutex_unlock( &p_owner->lock );
 
     if( unlikely(prerolled) )
     {
@@ -1139,8 +1135,6 @@ static int DecoderPlayAudio( struct decoder_owner *p_owner, block_t *p_audio )
     }
 
     /* */
-    /* */
-    vlc_mutex_lock( &p_owner->lock );
     if( p_owner->b_waiting )
     {
         p_owner->b_has_data = true;
@@ -1149,9 +1143,9 @@ static int DecoderPlayAudio( struct decoder_owner *p_owner, block_t *p_audio )
 
     /* */
     DecoderWaitUnblock( p_owner );
-    vlc_mutex_unlock( &p_owner->lock );
 
     audio_output_t *p_aout = p_owner->p_aout;
+    vlc_mutex_unlock( &p_owner->lock );
 
     if( p_aout != NULL )
     {
-- 
2.17.1



More information about the vlc-devel mailing list