Bug 1171311: P9. Only allow seeking if we have target time. r=cpearce
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 12 Jun 2015 09:26:58 +1000
changeset 248538 2328d14a175c0081b1ce30c70244e8f7d07bcf2e
parent 248537 29a86559487287f3f4b93430ffa31c3116ea7479
child 248539 ea7919145d65acc4cf79c1be6c7d9a119cac775e
push id28899
push userryanvm@gmail.com
push dateFri, 12 Jun 2015 18:57:39 +0000
treeherdermozilla-central@203e1025a826 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1171311
milestone41.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 1171311: P9. Only allow seeking if we have target time. r=cpearce
dom/media/mediasource/MediaSourceDemuxer.cpp
--- a/dom/media/mediasource/MediaSourceDemuxer.cpp
+++ b/dom/media/mediasource/MediaSourceDemuxer.cpp
@@ -305,16 +305,21 @@ MediaSourceTrackDemuxer::BreakCycles()
   nsCOMPtr<nsIRunnable> task =
     NS_NewRunnableFunction([self]() { self->mParent = nullptr; } );
   mParent->GetTaskQueue()->Dispatch(task.forget());
 }
 
 nsRefPtr<MediaSourceTrackDemuxer::SeekPromise>
 MediaSourceTrackDemuxer::DoSeek(media::TimeUnit aTime)
 {
+  if (aTime.ToMicroseconds() && !mManager->Buffered(mType).Contains(aTime)) {
+    // We don't have the data to seek to.
+    return SeekPromise::CreateAndReject(DemuxerFailureReason::WAITING_FOR_DATA,
+                                        __func__);
+  }
   const TrackBuffersManager::TrackBuffer& track =
     mManager->GetTrackBuffer(mType);
   TimeUnit lastKeyFrameTime;
   uint32_t lastKeyFrameIndex = 0;
   for (uint32_t i = 0; i < track.Length(); i++) {
     const nsRefPtr<MediaRawData>& sample = track[i];
     if (sample->mKeyframe) {
       lastKeyFrameTime = TimeUnit::FromMicroseconds(sample->mTime);