<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 26, 2017 at 11:20 PM, Rémi Denis-Courmont <span dir="ltr"><<a href="mailto:remi@remlab.net" target="_blank">remi@remlab.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">Le keskiviikkona 26. heinäkuuta 2017, 23.08.21 EEST Zhao Zhili a écrit :<br>
> On Wed, Jul 26, 2017 at 10:38 PM, Rémi Denis-Courmont <<a href="mailto:remi@remlab.net">remi@remlab.net</a>><br>
><br>
> wrote:<br>
> > Le keskiviikkona 26. heinäkuuta 2017, 19.43.34 EEST Zhao Zhili a écrit :<br>
> > > ---<br>
> > ><br>
> > >  modules/demux/adaptive/<wbr>PlaylistManager.cpp | 3 +--<br>
> > >  1 file changed, 1 insertion(+), 2 deletions(-)<br>
> > ><br>
> > > diff --git a/modules/demux/adaptive/<wbr>PlaylistManager.cpp<br>
> > > b/modules/demux/adaptive/<wbr>PlaylistManager.cpp<br>
> > > index f560d0f..f489a18f 100644<br>
> > > --- a/modules/demux/adaptive/<wbr>PlaylistManager.cpp<br>
> > > +++ b/modules/demux/adaptive/<wbr>PlaylistManager.cpp<br>
> > > @@ -664,8 +664,7 @@ void PlaylistManager::Run()<br>
> > ><br>
> > >              vlc_mutex_unlock(&demux.lock);<br>
> > ><br>
> > >              mutex_cleanup_push(&lock);<br>
> > ><br>
> > > -            while(vlc_cond_timedwait(&<wbr>waitcond, &lock, i_deadline) == 0<br>
> > > -                 && i_deadline < mdate());<br>
> > > +            vlc_cond_timedwait(&waitcond, &lock, i_deadline);<br>
> > ><br>
> > >              vlc_cleanup_pop();<br>
> > ><br>
> > >          }<br>
> > ><br>
> > >      }<br>
> ><br>
> > The existing code is an obtuse and inefficient emulation of mwait(). It<br>
> > does<br>
> > not make much sense. But the patch is also wrong due to spurious wake-ups.<br>
><br>
> I think it's more similar to ControlPop() than mwait().<br>
<br>
</span>No. The second part of the loop predicate is a no-op since<br>
vlc_cond_timedwait() will only return non-zero after the deadline is reached.<br>
So the code is equivalent to:<br>
<br>
    mutex_cleanup_push(&lock);<br>
<br>
    while (vlc_cond_timedwait(&waitcond, &lock, i_deadline) == 0);<br>
<br>
    vlc_cleanup_pop();<br>
<br>
The predicate for the condition variable is always false. So that is obviously<br>
equivalent to a simple sleep:<br>
<br>
    mutex_cleanup_push(&lock);<br>
<br>
    vlc_mutex_unlock(&lock);<br>
    vlc_cleanup_push(vlc_mutex_<wbr>lock, &lock);<br>
    mwait(i_deadline);<br>
    vlc_cleanup_pop();<br>
    vlc_mutex_lock(&lock);<br>
<br>
    vlc_cleanup_pop();<br>
<br>
The cleanup handlers obviously cancel out one another, so the code can<br>
trivially be further simplified:<br>
<br>
    vlc_mutex_unlock(&lock);<br>
    mwait(i_deadline);<br>
    vlc_mutex_lock(&lock);<br>
<div class="gmail-HOEnZb"><div class="gmail-h5"><br></div></div></blockquote><div><br></div><div>The logic of the original code is like this, but it should wakeup immediately in case <br>of setBufferingRunState(true). For example, it should start bufferize after<br>SET_TIME/SET_POSITION.<br></div><div><br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-HOEnZb"><div class="gmail-h5">
<br>
--<br>
雷米‧德尼-库尔蒙<br>
<a href="https://www.remlab.net/" rel="noreferrer" target="_blank">https://www.remlab.net/</a><br>
<br>
______________________________<wbr>_________________<br>
vlc-devel mailing list<br>
To unsubscribe or modify your subscription options:<br>
<a href="https://mailman.videolan.org/listinfo/vlc-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/<wbr>listinfo/vlc-devel</a></div></div></blockquote></div><br></div></div>