[vlc-commits] demux: adaptive: start buffering on demux only

Francois Cartegnie git at videolan.org
Fri May 17 11:32:34 CEST 2019


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri May 17 10:18:23 2019 +0200| [e0d303ebbb75158d748e72347d8c9aa5e5a94b76] | 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.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e0d303ebbb75158d748e72347d8c9aa5e5a94b76
---

 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 50629cfe48..7b0d54026a 100644
--- a/modules/demux/adaptive/PlaylistManager.cpp
+++ b/modules/demux/adaptive/PlaylistManager.cpp
@@ -142,7 +142,7 @@ bool PlaylistManager::setupPeriod()
     return true;
 }
 
-bool PlaylistManager::start()
+bool PlaylistManager::init()
 {
     if(!conManager &&
        !(conManager =
@@ -160,6 +160,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)
@@ -170,6 +178,11 @@ bool PlaylistManager::start()
     return true;
 }
 
+bool PlaylistManager::started() const
+{
+    return b_thread;
+}
+
 void PlaylistManager::stop()
 {
     if(b_thread)
@@ -401,6 +414,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 e0e3c899ed..43261ef9b2 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(vlc_tick_t, vlc_tick_t, vlc_tick_t);
diff --git a/modules/demux/adaptive/adaptive.cpp b/modules/demux/adaptive/adaptive.cpp
index 5c5a63d7ba..d6424b0e69 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