vlc | branch: master | Francois Cartegnie <[email protected]> | Wed Sep 9 11:41:25 2015 +0200| [c1591aa1246bcc1c0dd292d64c2757443d2a354d] | committer: Francois Cartegnie
demux: adaptative: fix chained initializations bug Since the bw adaptation can go really fast now, we need to be sure to send at least 1 data segment before switching to another. Otherwise we'll have multiple moov bug and can also never get any data outside of init segments. > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c1591aa1246bcc1c0dd292d64c2757443d2a354d --- modules/demux/adaptative/SegmentTracker.cpp | 22 +++++++++++++++++----- modules/demux/adaptative/SegmentTracker.hpp | 3 ++- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/modules/demux/adaptative/SegmentTracker.cpp b/modules/demux/adaptative/SegmentTracker.cpp index e64ee11..dd23890 100644 --- a/modules/demux/adaptative/SegmentTracker.cpp +++ b/modules/demux/adaptative/SegmentTracker.cpp @@ -32,7 +32,8 @@ SegmentTracker::SegmentTracker(AbstractAdaptationLogic *logic_, BaseAdaptationSe { count = 0; initializing = true; - indexed = false; + index_sent = false; + init_sent = false; prevRepresentation = NULL; setAdaptationLogic(logic_); adaptationSet = adaptSet; @@ -62,6 +63,10 @@ SegmentChunk * SegmentTracker::getNextChunk(bool switch_allowed) if(!adaptationSet) return NULL; + /* Ensure we don't keep chaining init/index without data */ + if( initializing && prevRepresentation ) + switch_allowed = false; + if( !switch_allowed || (prevRepresentation && prevRepresentation->getSwitchPolicy() == SegmentInformation::SWITCH_UNAVAILABLE) ) rep = prevRepresentation; @@ -74,20 +79,21 @@ SegmentChunk * SegmentTracker::getNextChunk(bool switch_allowed) if(rep != prevRepresentation) { prevRepresentation = rep; + init_sent = false; initializing = true; } - if(initializing) + if(!init_sent) { - initializing = false; + init_sent = true; segment = rep->getSegment(BaseRepresentation::INFOTYPE_INIT); if(segment) return segment->toChunk(count, rep); } - if(!indexed) + if(!index_sent) { - indexed = true; + index_sent = true; segment = rep->getSegment(BaseRepresentation::INFOTYPE_INDEX); if(segment) return segment->toChunk(count, rep); @@ -99,6 +105,8 @@ SegmentChunk * SegmentTracker::getNextChunk(bool switch_allowed) resetCounter(); return NULL; } + /* stop initializing after 1st chunk */ + initializing = false; SegmentChunk *chunk = segment->toChunk(count, rep); if(chunk) @@ -116,7 +124,11 @@ bool SegmentTracker::setPosition(mtime_t time, bool restarted, bool tryonly) if(!tryonly) { if(restarted) + { initializing = true; + index_sent = false; + init_sent = false; + } count = segcount; } return true; diff --git a/modules/demux/adaptative/SegmentTracker.hpp b/modules/demux/adaptative/SegmentTracker.hpp index 1f04100..023cf12 100644 --- a/modules/demux/adaptative/SegmentTracker.hpp +++ b/modules/demux/adaptative/SegmentTracker.hpp @@ -59,7 +59,8 @@ namespace adaptative private: bool initializing; - bool indexed; + bool index_sent; + bool init_sent; uint64_t count; AbstractAdaptationLogic *logic; BaseAdaptationSet *adaptationSet; _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
