[vlc-commits] demux: adaptive: start buffering on demux only
Francois Cartegnie
git at videolan.org
Mon Mar 30 16:15:32 CEST 2020
vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri May 17 10:18:23 2019 +0200| [b9d17f8098f0474a799cf18ba2ed0fd615466766] | committer: Francois Cartegnie
demux: adaptive: start buffering on demux only
Because of race condition in Init(), the es_out isn't set up
between demux pf_open() & pf_demux() calls and ES selection is
then totally impossible.
Randomly broke streams depending on thread speed & buffering.
(cherry picked from commit e0d303ebbb75158d748e72347d8c9aa5e5a94b76)
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=b9d17f8098f0474a799cf18ba2ed0fd615466766
---
modules/demux/adaptive/PlaylistManager.cpp | 17 ++++++++++++++++-
modules/demux/adaptive/PlaylistManager.h | 2 ++
modules/demux/adaptive/adaptive.cpp | 2 +-
3 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/modules/demux/adaptive/PlaylistManager.cpp b/modules/demux/adaptive/PlaylistManager.cpp
index 83257e6367..df1acf8db5 100644
--- a/modules/demux/adaptive/PlaylistManager.cpp
+++ b/modules/demux/adaptive/PlaylistManager.cpp
@@ -143,7 +143,7 @@ bool PlaylistManager::setupPeriod()
return true;
}
-bool PlaylistManager::start()
+bool PlaylistManager::init()
{
if(!conManager &&
!(conManager =
@@ -161,6 +161,14 @@ bool PlaylistManager::start()
updateControlsContentType();
updateControlsPosition();
+ return true;
+}
+
+bool PlaylistManager::start()
+{
+ if(b_thread || !conManager)
+ return false;
+
b_thread = !vlc_clone(&thread, managerThread,
static_cast<void *>(this), VLC_THREAD_PRIORITY_INPUT);
if(!b_thread)
@@ -171,6 +179,11 @@ bool PlaylistManager::start()
return true;
}
+bool PlaylistManager::started() const
+{
+ return b_thread;
+}
+
void PlaylistManager::stop()
{
if(b_thread)
@@ -425,6 +438,8 @@ bool PlaylistManager::reactivateStream(AbstractStream *stream)
int PlaylistManager::demux_callback(demux_t *p_demux)
{
PlaylistManager *manager = reinterpret_cast<PlaylistManager *>(p_demux->p_sys);
+ if(!manager->started() && !manager->start())
+ return VLC_DEMUXER_EOF;
return manager->doDemux(DEMUX_INCREMENT);
}
diff --git a/modules/demux/adaptive/PlaylistManager.h b/modules/demux/adaptive/PlaylistManager.h
index be157eb950..6de06b82d2 100644
--- a/modules/demux/adaptive/PlaylistManager.h
+++ b/modules/demux/adaptive/PlaylistManager.h
@@ -52,7 +52,9 @@ namespace adaptive
AbstractAdaptationLogic::LogicType type );
virtual ~PlaylistManager ();
+ bool init();
bool start();
+ bool started() const;
void stop();
AbstractStream::buffering_status bufferize(mtime_t, unsigned, unsigned);
diff --git a/modules/demux/adaptive/adaptive.cpp b/modules/demux/adaptive/adaptive.cpp
index f0fd6588ae..4704b7e687 100644
--- a/modules/demux/adaptive/adaptive.cpp
+++ b/modules/demux/adaptive/adaptive.cpp
@@ -223,7 +223,7 @@ static int Open(vlc_object_t *p_obj)
}
}
- if(!p_manager || !p_manager->start())
+ if(!p_manager || !p_manager->init())
{
delete p_manager;
return VLC_EGENERIC;
More information about the vlc-commits
mailing list