[vlc-commits] demux: adaptive: use a signaled boolean to test if the thread should stop
Steve Lhomme
git at videolan.org
Tue Feb 11 08:21:37 CET 2020
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Feb 10 16:23:41 2020 +0100| [4f094f796aad2cbc3bc41c7f7ccda042c11e819f] | committer: Steve Lhomme
demux: adaptive: use a signaled boolean to test if the thread should stop
Rather than using a cancelation point that may not work on some platforms.
Ref #23591
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4f094f796aad2cbc3bc41c7f7ccda042c11e819f
---
modules/demux/adaptive/PlaylistManager.cpp | 21 +++++++++++++--------
modules/demux/adaptive/PlaylistManager.h | 1 +
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/modules/demux/adaptive/PlaylistManager.cpp b/modules/demux/adaptive/PlaylistManager.cpp
index 9d065579c5..a8bce7aca1 100644
--- a/modules/demux/adaptive/PlaylistManager.cpp
+++ b/modules/demux/adaptive/PlaylistManager.cpp
@@ -64,6 +64,7 @@ PlaylistManager::PlaylistManager( demux_t *p_demux_,
failedupdates = 0;
b_thread = false;
b_buffering = false;
+ b_canceled = false;
nextPlaylistupdate = 0;
demux.i_nzpcr = VLC_TICK_INVALID;
demux.i_firstpcr = VLC_TICK_INVALID;
@@ -180,7 +181,11 @@ void PlaylistManager::stop()
{
if(b_thread)
{
- vlc_cancel(thread);
+ vlc_mutex_lock(&lock);
+ b_canceled = true;
+ vlc_cond_signal(&waitcond);
+ vlc_mutex_unlock(&lock);
+
vlc_join(thread, NULL);
b_thread = false;
}
@@ -614,11 +619,10 @@ void PlaylistManager::Run()
const vlc_tick_t i_extra_buffering = playlist->getMaxBuffering() - i_min_buffering;
while(1)
{
- mutex_cleanup_push(&lock);
- while(!b_buffering)
+ while(!b_buffering && !b_canceled)
vlc_cond_wait(&waitcond, &lock);
- vlc_testcancel();
- vlc_cleanup_pop();
+ if (b_canceled)
+ break;
if(needsUpdate())
{
@@ -654,11 +658,12 @@ void PlaylistManager::Run()
vlc_cond_signal(&demux.cond);
vlc_mutex_unlock(&demux.lock);
- mutex_cleanup_push(&lock);
while(b_buffering &&
vlc_cond_timedwait(&waitcond, &lock, i_deadline) == 0 &&
- i_deadline > vlc_tick_now());
- vlc_cleanup_pop();
+ i_deadline > vlc_tick_now() &&
+ !b_canceled);
+ if (b_canceled)
+ break;
}
}
vlc_mutex_unlock(&lock);
diff --git a/modules/demux/adaptive/PlaylistManager.h b/modules/demux/adaptive/PlaylistManager.h
index d766cead80..55ceacde7c 100644
--- a/modules/demux/adaptive/PlaylistManager.h
+++ b/modules/demux/adaptive/PlaylistManager.h
@@ -135,6 +135,7 @@ namespace adaptive
bool b_thread;
vlc_cond_t waitcond;
bool b_buffering;
+ bool b_canceled;
};
}
More information about the vlc-commits
mailing list