Bug 1297580: [MSE] P2. Halves the fuzz value when checking if seek target is present. r?gerald draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 24 Aug 2016 17:20:52 +1200
changeset 405245 de89c070188423990b1a01aad7a5f2b392acae9a
parent 405244 d94f28ef0418537e6df5be512abf8cca741090d7
child 405246 696d461f777f24895815351c7bb61c845f3f7ced
push id27443
push userbmo:jyavenard@mozilla.com
push dateThu, 25 Aug 2016 04:44:40 +0000
reviewersgerald
bugs1297580
milestone51.0a1
Bug 1297580: [MSE] P2. Halves the fuzz value when checking if seek target is present. r?gerald The fuzz value is a +/- one. To check if a target is within an interval we need to check with half the fuzz only. MozReview-Commit-ID: J5H5sbNokse
dom/media/mediasource/MediaSourceDemuxer.cpp
--- a/dom/media/mediasource/MediaSourceDemuxer.cpp
+++ b/dom/media/mediasource/MediaSourceDemuxer.cpp
@@ -376,17 +376,19 @@ MediaSourceTrackDemuxer::BreakCycles()
     } );
   mParent->GetTaskQueue()->Dispatch(task.forget());
 }
 
 RefPtr<MediaSourceTrackDemuxer::SeekPromise>
 MediaSourceTrackDemuxer::DoSeek(media::TimeUnit aTime)
 {
   TimeIntervals buffered = mManager->Buffered(mType);
-  buffered.SetFuzz(MediaSourceDemuxer::EOS_FUZZ);
+  // Fuzz factor represents a +/- threshold. So when seeking it allows the gap
+  // to be twice as big as the fuzz value. We only want to allow EOS_FUZZ gap.
+  buffered.SetFuzz(MediaSourceDemuxer::EOS_FUZZ / 2);
   TimeUnit seekTime = std::max(aTime - mPreRoll, TimeUnit::FromMicroseconds(0));
 
   if (!buffered.Contains(seekTime)) {
     if (!buffered.Contains(aTime)) {
       // We don't have the data to seek to.
       return SeekPromise::CreateAndReject(
         mManager->IsEnded() ? DemuxerFailureReason::END_OF_STREAM :
                               DemuxerFailureReason::WAITING_FOR_DATA, __func__);
@@ -395,17 +397,17 @@ MediaSourceTrackDemuxer::DoSeek(media::T
     // however, to avoid unwanted regressions we assume that if at this time
     // we don't have the wanted data it won't come later.
     // Instead of using the pre-rolled time, use the earliest time available in
     // the interval.
     TimeIntervals::IndexType index = buffered.Find(aTime);
     MOZ_ASSERT(index != TimeIntervals::NoIndex);
     seekTime = buffered[index].mStart;
   }
-  seekTime = mManager->Seek(mType, seekTime, MediaSourceDemuxer::EOS_FUZZ);
+  seekTime = mManager->Seek(mType, seekTime, MediaSourceDemuxer::EOS_FUZZ / 2);
   bool error;
   RefPtr<MediaRawData> sample =
     mManager->GetSample(mType,
                         media::TimeUnit(),
                         error);
   MOZ_ASSERT(!error && sample);
   mNextSample = Some(sample);
   mReset = false;