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

Steve Lhomme robux4 at ycbcr.xyz
Fri Aug 30 07:55:46 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 6c0411f751..f3b74f592f 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 )
     {
@@ -995,19 +994,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;
@@ -1024,6 +1020,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
@@ -1136,7 +1133,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) )
     {
@@ -1147,8 +1143,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;
@@ -1157,9 +1151,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