[vlc-devel] [RFC PATCH 3/3] decoder: protect vout and aout during read

Rémi Denis-Courmont remi at remlab.net
Wed Apr 1 16:36:42 CEST 2015


Le 2015-04-01 17:13, Thomas Guillem a écrit :
> ---
>  src/input/decoder.c | 72
> ++++++++++++++++++++++++++++++++++++++++++-----------
>  1 file changed, 58 insertions(+), 14 deletions(-)
>
> diff --git a/src/input/decoder.c b/src/input/decoder.c
> index 1fd5b90..4f0e5f8 100644
> --- a/src/input/decoder.c
> +++ b/src/input/decoder.c
> @@ -89,12 +89,11 @@ struct decoder_owner_sys_t
>      vlc_mutex_t lock;
>      vlc_cond_t  wait;
>
> -    /* -- These variables need locking on write(only) -- */
> +    /* -- Theses variables need locking on read *and* write -- */
>      audio_output_t *p_aout;
>
>      vout_thread_t   *p_vout;
>
> -    /* -- Theses variables need locking on read *and* write -- */
>      /* Pause */
>      bool b_paused;
>      struct
> @@ -182,6 +181,28 @@ static block_t *DecoderBlockFlushNew()
>      return p_null;
>  }
>
> +static audio_output_t *DecoderGetAout( decoder_t *p_dec )
> +{
> +    decoder_owner_sys_t *p_owner = p_dec->p_owner;
> +    audio_output_t *p_aout;
> +
> +    vlc_mutex_lock( &p_owner->lock );
> +    p_aout = p_owner->p_aout;
> +    vlc_mutex_unlock( &p_owner->lock );
> +    return p_aout;
> +}
> +
> +static vout_thread_t *DecoderGetVout( decoder_t *p_dec )
> +{
> +    decoder_owner_sys_t *p_owner = p_dec->p_owner;
> +    vout_thread_t *p_vout;
> +
> +    vlc_mutex_lock( &p_owner->lock );
> +    p_vout = p_owner->p_vout;
> +    vlc_mutex_unlock( &p_owner->lock );
> +    return p_vout;
> +}

If you want to check that the pointer is non-NULL, return a boolean. 
And otherwise, this is obviously nonsensical.

-- 
Rémi Denis-Courmont



More information about the vlc-devel mailing list