[vlc-commits] demux: adaptive: restart stream demuxer when required

Francois Cartegnie git at videolan.org
Mon Jul 18 16:19:56 CEST 2016


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Jul 18 16:11:09 2016 +0200| [771a2a17fb5145a65ca8f3c8183adc004d0e5604] | committer: Francois Cartegnie

demux: adaptive: restart stream demuxer when required

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

 modules/demux/adaptive/Streams.cpp |   23 +++++++++++++++++------
 modules/demux/adaptive/Streams.hpp |    1 +
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/modules/demux/adaptive/Streams.cpp b/modules/demux/adaptive/Streams.cpp
index 74269b5..b67cf7a 100644
--- a/modules/demux/adaptive/Streams.cpp
+++ b/modules/demux/adaptive/Streams.cpp
@@ -44,6 +44,7 @@ AbstractStream::AbstractStream(demux_t * demux_)
     dead = false;
     disabled = false;
     discontinuity = false;
+    needrestart = false;
     segmentTracker = NULL;
     demuxersource = NULL;
     commandsqueue = NULL;
@@ -316,12 +317,17 @@ AbstractStream::buffering_status AbstractStream::bufferize(mtime_t nz_deadline,
         vlc_mutex_lock(&lock);
         if(i_ret != VLC_DEMUXER_SUCCESS)
         {
-            if(discontinuity)
+            if(discontinuity || needrestart)
             {
-                msg_Dbg( p_realdemux, "Flushing on discontinuity" );
-                prepareRestart();
-                discontinuity = false;
-                commandsqueue->setFlush();
+                msg_Dbg(p_realdemux, "Restarting demuxer");
+                prepareRestart(discontinuity);
+                if(discontinuity)
+                {
+                    msg_Dbg(p_realdemux, "Flushing on discontinuity");
+                    commandsqueue->setFlush();
+                    discontinuity = false;
+                }
+                needrestart = false;
                 vlc_mutex_unlock(&lock);
                 return AbstractStream::buffering_ongoing;
             }
@@ -388,7 +394,7 @@ block_t * AbstractStream::readNextBlock()
     if (currentChunk == NULL && !eof)
         currentChunk = segmentTracker->getNextChunk(!fakeesout->restarting(), connManager);
 
-    if(discontinuity)
+    if(discontinuity || needrestart)
     {
         msg_Info(p_realdemux, "Encountered discontinuity");
         /* Force stream/demuxer to end for this call */
@@ -435,6 +441,7 @@ bool AbstractStream::setPosition(mtime_t time, bool tryonly)
             if(currentChunk)
                 delete currentChunk;
             currentChunk = NULL;
+            needrestart = false;
 
             if( !restartDemux() )
                 dead = true;
@@ -501,6 +508,10 @@ void AbstractStream::trackerEvent(const SegmentTrackerEvent &event)
             break;
 
         case SegmentTrackerEvent::SWITCHING:
+            if(demuxer && demuxer->needsRestartOnSwitch())
+            {
+                needrestart = true;
+            }
         default:
             break;
     }
diff --git a/modules/demux/adaptive/Streams.hpp b/modules/demux/adaptive/Streams.hpp
index a51b446..ebf0962 100644
--- a/modules/demux/adaptive/Streams.hpp
+++ b/modules/demux/adaptive/Streams.hpp
@@ -104,6 +104,7 @@ namespace adaptive
         virtual void prepareRestart(bool = true);
 
         bool discontinuity;
+        bool needrestart;
 
         demux_t *p_realdemux;
         StreamFormat format;



More information about the vlc-commits mailing list