[vlc-devel] [PATCH] decoder: re-order save/restore cancel

Thomas Guillem thomas at gllm.fr
Tue Sep 12 12:59:57 CEST 2017


Mainly to clarify and use the same order when locking/restoring and
saving/unlocking.

This doesn't change anything since the thread cancellation type is deferred.
---
 src/input/decoder.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index 109d5a2205..57273805d5 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -1531,7 +1531,6 @@ static void *DecoderThread( void *p_data )
         {   /* Flush before/regardless of pause. We do not want to resume just
              * for the sake of flushing (glitches could otherwise happen). */
             int canc = vlc_savecancel();
-
             vlc_fifo_Unlock( p_owner->p_fifo );
 
             /* Flush the decoder (and the output) */
@@ -1550,10 +1549,10 @@ static void *DecoderThread( void *p_data )
 
         if( paused != p_owner->paused )
         {   /* Update playing/paused status of the output */
-            int canc = vlc_savecancel();
             mtime_t date = p_owner->pause_date;
-
             paused = p_owner->paused;
+
+            int canc = vlc_savecancel();
             vlc_fifo_Unlock( p_owner->p_fifo );
 
             /* NOTE: Only the audio and video outputs care about pause. */
@@ -1563,8 +1562,8 @@ static void *DecoderThread( void *p_data )
             if( p_owner->p_aout != NULL )
                 aout_DecChangePause( p_owner->p_aout, paused, date );
 
-            vlc_restorecancel( canc );
             vlc_fifo_Lock( p_owner->p_fifo );
+            vlc_restorecancel( canc );
             continue;
         }
 
@@ -1593,9 +1592,9 @@ static void *DecoderThread( void *p_data )
              * drain. Pass p_block = NULL to decoder just once. */
         }
 
+        int canc = vlc_savecancel();
         vlc_fifo_Unlock( p_owner->p_fifo );
 
-        int canc = vlc_savecancel();
         DecoderProcess( p_dec, p_block );
 
         if( p_block == NULL )
@@ -1604,7 +1603,6 @@ static void *DecoderThread( void *p_data )
             if( p_owner->p_aout != NULL )
                 aout_DecFlush( p_owner->p_aout, true );
         }
-        vlc_restorecancel( canc );
 
         /* TODO? Wait for draining instead of polling. */
         vlc_mutex_lock( &p_owner->lock );
@@ -1616,6 +1614,8 @@ static void *DecoderThread( void *p_data )
         vlc_fifo_Lock( p_owner->p_fifo );
         vlc_cond_signal( &p_owner->wait_acknowledge );
         vlc_mutex_unlock( &p_owner->lock );
+
+        vlc_restorecancel( canc );
     }
     vlc_cleanup_pop();
     vlc_assert_unreachable();
-- 
2.11.0



More information about the vlc-devel mailing list