[vlc-devel] [PATCH] demux: adaptive: signal buffering state change in both cases

Zhao Zhili wantlamy at gmail.com
Tue Aug 1 04:21:20 CEST 2017


On Mon, Jul 31, 2017 at 10:06 PM, Francois Cartegnie <fcvlcdev at free.fr>
wrote:

> Le 28/07/2017 à 10:49, Zhao Zhili a écrit :
> > @@ -614,8 +614,7 @@ void PlaylistManager::setBufferingRunState(bool b)
> >  {
> >      vlc_mutex_lock(&lock);
> >      b_buffering = b;
> > -    if(b_buffering)
> > -        vlc_cond_signal(&waitcond);
> > +    vlc_cond_signal(&waitcond);
> >      vlc_mutex_unlock(&lock);
> >  }
> >
> > @@ -665,8 +664,9 @@ void PlaylistManager::Run()
> >              vlc_mutex_unlock(&demux.lock);
> >
> >              mutex_cleanup_push(&lock);
> > -            while(vlc_cond_timedwait(&waitcond, &lock, i_deadline) == 0
> > -                 && i_deadline < mdate());
> > +            while(b_buffering &&
> > +                    vlc_cond_timedwait(&waitcond, &lock, i_deadline) ==
> 0
> > &&
> > +                    i_deadline > mdate());
> >              vlc_cleanup_pop();
> >          }
> >      }
>
>
> I don't know what you're trying to do but that's not going to work.
> The b_buffering is a buffering thread disable switch.
>
> If you trigger signal when disabling, you'll run the bufferize() and
> break any seek because it did not stop.
>
>
There are two point where setBufferingRunState() can get the lock and call
vlc_cond_signal():

Case 1.
        while(!b_buffering)
            vlc_cond_wait(&waitcond, &lock);

Case 2.
> +            while(b_buffering &&
> +                    vlc_cond_timedwait(&waitcond, &lock, i_deadline) == 0
> &&
> +                    i_deadline > mdate());

For the first case, signal when disabling won't do much other than wakeup
and wait again.

For the second case, signal when disabling will break the loop and step
into the first case.
Bufferize() won't get the chance to run.

Breakout the second case and step into the first case has a positive effect
since the first while loop
response to setBufferingRunState(true) quickly. The second while loop
doesn't breakout for
setBufferingRunState(true), which is not desirable.


> Francois
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20170801/b42cd905/attachment.html>


More information about the vlc-devel mailing list