[vlc-devel] [PATCH 6/6] demux: adaptive: make managerThread interruptable
Zhao Zhili
quinkblack at foxmail.com
Wed Sep 20 05:52:49 CEST 2017
---
modules/demux/adaptive/PlaylistManager.cpp | 15 ++++++++++++++-
modules/demux/adaptive/PlaylistManager.h | 4 ++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/modules/demux/adaptive/PlaylistManager.cpp
b/modules/demux/adaptive/PlaylistManager.cpp
index fced732..ec4e8f9 100644
--- a/modules/demux/adaptive/PlaylistManager.cpp
+++ b/modules/demux/adaptive/PlaylistManager.cpp
@@ -59,7 +59,8 @@ PlaylistManager::PlaylistManager( demux_t *p_demux_,
logic ( NULL ),
playlist ( pl ),
streamFactory ( factory ),
- p_demux ( p_demux_ )
+ p_demux ( p_demux_ ),
+ interrupt ( NULL )
{
currentPeriod = playlist->getFirstPeriod();
failedupdates = 0;
@@ -91,6 +92,8 @@ PlaylistManager::~PlaylistManager ()
vlc_mutex_destroy(&demux.lock);
vlc_cond_destroy(&demux.cond);
vlc_mutex_destroy(&cached.lock);
+ if(interrupt)
+ vlc_interrupt_destroy(interrupt);
}
void PlaylistManager::unsetPeriod()
@@ -153,6 +156,10 @@ bool PlaylistManager::setupPeriod()
bool PlaylistManager::start()
{
+ interrupt = vlc_interrupt_create();
+ if(unlikely(interrupt == NULL))
+ return false;
+
if(!conManager && !(conManager = new (std::nothrow)
HTTPConnectionManager(VLC_OBJECT(p_demux->s))))
return false;
@@ -168,7 +175,11 @@ bool PlaylistManager::start()
b_thread = !vlc_clone(&thread, managerThread,
static_cast<void *>(this),
VLC_THREAD_PRIORITY_INPUT);
if(!b_thread)
+ {
+ vlc_interrupt_destroy(interrupt);
+ interrupt = NULL;
return false;
+ }
setBufferingRunState(true);
@@ -181,6 +192,7 @@ void PlaylistManager::stop()
{
if(conManager)
conManager->interrupt();
+ vlc_interrupt_kill(interrupt);
vlc_cancel(thread);
vlc_join(thread, NULL);
b_thread = false;
@@ -639,6 +651,7 @@ void PlaylistManager::setBufferingRunState(bool b)
void PlaylistManager::Run()
{
+ vlc_interrupt_set(interrupt);
vlc_mutex_lock(&lock);
mutex_cleanup_push(&lock);
const unsigned i_min_buffering = playlist->getMinBuffering();
diff --git a/modules/demux/adaptive/PlaylistManager.h
b/modules/demux/adaptive/PlaylistManager.h
index ac5a872..3977fea 100644
--- a/modules/demux/adaptive/PlaylistManager.h
+++ b/modules/demux/adaptive/PlaylistManager.h
@@ -22,6 +22,9 @@
#ifndef PLAYLISTMANAGER_H_
#define PLAYLISTMANAGER_H_
+#include <vlc_common.h>
+#include <vlc_interrupt.h>
+
#include "logic/AbstractAdaptationLogic.h"
#include "Streams.hpp"
#include <vector>
@@ -132,6 +135,7 @@ namespace adaptive
bool b_thread;
vlc_cond_t waitcond;
bool b_buffering;
+ vlc_interrupt_t *interrupt;
};
}
--
2.7.4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0006-demux-adaptive-make-managerThread-interruptable.patch
Type: text/x-patch
Size: 3128 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20170920/061eea68/attachment.bin>
More information about the vlc-devel
mailing list