Bug 1189138: [MSE] P3. Properly shift our demuxing index when data is added. r=gerald
☠☠ backed out by bce7955eaa13 ☠ ☠
authorJean-Yves Avenard <jyavenard@mozilla.com>
Thu, 30 Jul 2015 14:03:44 +1000
changeset 287078 ca2c0a7b3b3bf38abf606b9d315ea1d4d7b9046d
parent 287077 e4ea0d56fcb6b593e6f9c304416a8acb7d676662
child 287079 42a673cd36ff22cd916c05841cbd45adc03f0b16
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1189138
milestone42.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1189138: [MSE] P3. Properly shift our demuxing index when data is added. r=gerald Should frames be added before our current demuxing position, we must shift the index ; otherwise the next retrieved frames will be the wrong one.
dom/media/mediasource/TrackBuffersManager.cpp
--- a/dom/media/mediasource/TrackBuffersManager.cpp
+++ b/dom/media/mediasource/TrackBuffersManager.cpp
@@ -1510,16 +1510,22 @@ TrackBuffersManager::InsertFrames(TrackB
   if (intersection.Length()) {
     RemoveFrames(aIntervals, trackBuffer, trackBuffer.mNextInsertionIndex.refOr(0));
   }
 
   // 16. Add the coded frame with the presentation timestamp, decode timestamp, and frame duration to the track buffer.
   CheckNextInsertionIndex(aTrackData,
                           TimeUnit::FromMicroseconds(aSamples[0]->mTime));
 
+  // Adjust our demuxing index if necessary.
+  if (trackBuffer.mNextGetSampleIndex.isSome() &&
+      trackBuffer.mNextInsertionIndex.ref() <= trackBuffer.mNextGetSampleIndex.ref()) {
+    trackBuffer.mNextGetSampleIndex.ref() += aSamples.Length();
+  }
+
   TrackBuffer& data = trackBuffer.mBuffers.LastElement();
   data.InsertElementsAt(trackBuffer.mNextInsertionIndex.ref(), aSamples);
   trackBuffer.mNextInsertionIndex.ref() += aSamples.Length();
 
   // Update our buffered range with new sample interval.
   // We allow a fuzz factor in our interval of half a frame length,
   // as fuzz is +/- value, giving an effective leeway of a full frame
   // length.