[vlc-devel] [PATCH] dec: lock p_vout/p_aout when read from the DecoderThread
Thomas Guillem
thomas at gllm.fr
Thu May 17 15:06:32 CEST 2018
Since these variables can be written from any thread from format_update()
callbacks.
---
src/input/decoder.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/input/decoder.c b/src/input/decoder.c
index 1fdc4fb7ed..f80a799723 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -103,10 +103,10 @@ struct decoder_owner
vlc_cond_t wait_fifo; /* TODO: merge with wait_acknowledge */
vlc_cond_t wait_timed;
- /* -- These variables need locking on write(only) -- */
+ /* These variables are written from the format_update() callbacks threads.
+ * They need locking when they are read from the DecoderThread. */
audio_output_t *p_aout;
-
- vout_thread_t *p_vout;
+ vout_thread_t *p_vout;
/* -- Theses variables need locking on read *and* write -- */
/* Preroll */
@@ -1535,6 +1535,7 @@ static void *DecoderThread( void *p_data )
/* NOTE: Only the audio and video outputs care about pause. */
msg_Dbg( p_dec, "toggling %s", paused ? "resume" : "pause" );
+ vlc_mutex_lock( &p_owner->lock );
switch( p_dec->fmt_out.i_cat )
{
case VIDEO_ES:
@@ -1550,6 +1551,7 @@ static void *DecoderThread( void *p_data )
default:
vlc_assert_unreachable();
}
+ vlc_mutex_unlock( &p_owner->lock );
vlc_restorecancel( canc );
vlc_fifo_Lock( p_owner->p_fifo );
@@ -1569,8 +1571,10 @@ static void *DecoderThread( void *p_data )
case VIDEO_ES:
break;
case AUDIO_ES:
+ vlc_mutex_lock( &p_owner->lock );
if( p_owner->p_aout != NULL )
aout_DecChangeRate( p_owner->p_aout, rate );
+ vlc_mutex_unlock( &p_owner->lock );
break;
case SPU_ES:
break;
--
2.17.0
More information about the vlc-devel
mailing list