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

Rémi Denis-Courmont remi at remlab.net
Thu Feb 11 18:07:14 UTC 2021


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.

> 
> >  }
> >  
> >  /**
> > 

-- 
雷米‧德尼-库尔蒙
http://www.remlab.net/





More information about the vlc-devel mailing list