[vlc-devel] [PATCH] lib: media: wait preparse end before release

Thomas Guillem thomas at gllm.fr
Thu Feb 11 18:36:12 UTC 2021



On Thu, Feb 11, 2021, at 19:07, Rémi Denis-Courmont wrote:
> Le torstaina 11. helmikuuta 2021, 18.23.48 EET Thomas Guillem a écrit :
> > > diff --git a/lib/media.c b/lib/media.c
> > > index 19283d4f44..fa9939e3d8 100644
> > > --- a/lib/media.c
> > > +++ b/lib/media.c
> > > @@ -432,7 +432,12 @@ static void input_item_preparse_ended(input_item_t
> > > *item,> 
> > >              return;
> > >      
> > >      }
> > >      send_parsed_changed( p_md, new_status );
> > > 
> > > -    libvlc_media_release( p_md );
> > > +
> > > +    vlc_mutex_lock(&p_md->parsed_lock);
> > > +    assert(p_md->worker_count > 0);
> > > +    p_md->worker_count--;
> > > +    vlc_mutex_unlock(&p_md->parsed_lock);
> > > +    vlc_cond_signal(&p_md->idle_cond);
> > 
> > signal while locked please.
> 
> Indeed signaling under the lock is cleaner.
> 
> However the current implementation of vlc_cond_t is pessimistic and protects 
> against signaling without the lock... We can remove the "inner" condition 
> variable lock if we assume that signaling/broadcasting is always done while 
> holding the associated mutex.

I agree but there may be few places in the vlc codebase where signal is called after the lock (should be easy to fix).
We should add an assert preventing unlocked signal if we do this change.

> 
> > 
> > >  }
> > >  
> > >  /**
> > > 
> 
> -- 
> 雷米‧德尼-库尔蒙
> http://www.remlab.net/
> 
> 
> 
> _______________________________________________
> 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