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

Thomas Guillem thomas at gllm.fr
Wed Apr 1 17:39:29 CEST 2015



On Wed, Apr 1, 2015, at 16:36, Rémi Denis-Courmont wrote:
> 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.

I don't get it, the pointer can be set to NULL by an other thread
between the check of non-NULL and the actual usage of the vout/aout.

> 
> -- 
> Rémi Denis-Courmont
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel



More information about the vlc-devel mailing list