[vlc-devel] [PATCH] dec: lock p_vout/p_aout when read from the DecoderThread

Rémi Denis-Courmont remi at remlab.net
Thu May 17 15:11:28 CEST 2018


I agree that there is a problem at least in principles, but this seems too naive solution.

For instance, aout does not allow queuing while paused.

Le 17 mai 2018 16:06:32 GMT+03:00, Thomas Guillem <thomas at gllm.fr> a écrit :
>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
>
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel

-- 
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20180517/b6fcd330/attachment.html>


More information about the vlc-devel mailing list