Bug 1258922: [MSE] P3. Check that the data we are attempting to skip to is buffered. r=gerald a=ritu
authorJean-Yves Avenard <jyavenard@mozilla.com>
Thu, 05 May 2016 15:43:40 +1000
changeset 332789 0ce7d0b3753b677f83c9a61c5f22491d506377bd
parent 332788 6ea323c87eb7f73e73ae374eb99a461723bc1323
child 332790 b72de38736248444009bfef8043ced0f15383776
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald, ritu
bugs1258922
milestone48.0a2
Bug 1258922: [MSE] P3. Check that the data we are attempting to skip to is buffered. r=gerald a=ritu MozReview-Commit-ID: DCQkIimciEe
dom/media/mediasource/MediaSourceDemuxer.cpp
--- a/dom/media/mediasource/MediaSourceDemuxer.cpp
+++ b/dom/media/mediasource/MediaSourceDemuxer.cpp
@@ -457,21 +457,27 @@ MediaSourceTrackDemuxer::DoGetSamples(in
       mManager->GetNextRandomAccessPoint(mType, MediaSourceDemuxer::EOS_FUZZ);
   }
   return SamplesPromise::CreateAndResolve(samples, __func__);
 }
 
 RefPtr<MediaSourceTrackDemuxer::SkipAccessPointPromise>
 MediaSourceTrackDemuxer::DoSkipToNextRandomAccessPoint(media::TimeUnit aTimeThreadshold)
 {
-  bool found;
-  uint32_t parsed =
-    mManager->SkipToNextRandomAccessPoint(mType, aTimeThreadshold, found);
-  if (found) {
-    return SkipAccessPointPromise::CreateAndResolve(parsed, __func__);
+  uint32_t parsed = 0;
+  // Ensure that the data we are about to skip to is still available.
+  TimeIntervals buffered = mManager->Buffered(mType);
+  buffered.SetFuzz(MediaSourceDemuxer::EOS_FUZZ);
+  if (buffered.Contains(aTimeThreadshold)) {
+    bool found;
+    parsed =
+      mManager->SkipToNextRandomAccessPoint(mType, aTimeThreadshold, found);
+    if (found) {
+      return SkipAccessPointPromise::CreateAndResolve(parsed, __func__);
+    }
   }
   SkipFailureHolder holder(
     mManager->IsEnded() ? DemuxerFailureReason::END_OF_STREAM :
                           DemuxerFailureReason::WAITING_FOR_DATA, parsed);
   return SkipAccessPointPromise::CreateAndReject(holder, __func__);
 }
 
 } // namespace mozilla