Bug 1173792 - Seek to original seeking position should video seeked time not found. r=cpearce, a=lizzard FIREFOX_RELEASE_39_BASE
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 17 Jun 2015 22:53:45 +1000
changeset 276818 5fecfbec2e3c934d4646a739bea60d3c93a35f9e
parent 276817 d4648fee1cca7575e8b8c69576ff84773cc57440
child 276819 0ac3fc5d4e0728b63d3f1cb23d7a17696dad51c2
push id3356
push userbsmedberg@mozilla.com
push dateThu, 09 Jul 2015 21:52:23 +0000
reviewerscpearce, lizzard
bugs1173792
milestone39.0
Bug 1173792 - Seek to original seeking position should video seeked time not found. r=cpearce, a=lizzard CLOSED TREE
dom/media/mediasource/MediaSourceReader.cpp
dom/media/mediasource/MediaSourceReader.h
--- a/dom/media/mediasource/MediaSourceReader.cpp
+++ b/dom/media/mediasource/MediaSourceReader.cpp
@@ -42,16 +42,17 @@ extern PRLogModuleInfo* GetMediaSourceLo
 using mozilla::dom::TimeRanges;
 
 namespace mozilla {
 
 MediaSourceReader::MediaSourceReader(MediaSourceDecoder* aDecoder)
   : MediaDecoderReader(aDecoder)
   , mLastAudioTime(0)
   , mLastVideoTime(0)
+  , mOriginalSeekTime(-1)
   , mPendingSeekTime(-1)
   , mWaitingForSeekData(false)
   , mSeekToEnd(false)
   , mTimeThreshold(0)
   , mDropAudioBeforeThreshold(false)
   , mDropVideoBeforeThreshold(false)
   , mAudioDiscontinuity(false)
   , mVideoDiscontinuity(false)
@@ -826,16 +827,17 @@ MediaSourceReader::Seek(int64_t aTime, i
 
   if (IsShutdown()) {
     mSeekPromise.Reject(NS_ERROR_FAILURE, __func__);
     return p;
   }
 
   // Store pending seek target in case the track buffers don't contain
   // the desired time and we delay doing the seek.
+  mOriginalSeekTime = aTime;
   mPendingSeekTime = aTime;
 
   {
     ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
     mWaitingForSeekData = true;
     mDropAudioBeforeThreshold = false;
     mDropVideoBeforeThreshold = false;
     mTimeThreshold = 0;
@@ -910,17 +912,18 @@ MediaSourceReader::OnVideoSeekFailed(nsr
 
 void
 MediaSourceReader::DoAudioSeek()
 {
   int64_t seekTime = mPendingSeekTime;
   if (mSeekToEnd) {
     seekTime = LastSampleTime(MediaData::AUDIO_DATA);
   }
-  if (SwitchAudioSource(&seekTime) == SOURCE_NONE) {
+  if (SwitchAudioSource(&seekTime) == SOURCE_NONE &&
+      SwitchAudioSource(&mOriginalSeekTime) == SOURCE_NONE) {
     // Data we need got evicted since the last time we checked for data
     // availability. Abort current seek attempt.
     mWaitingForSeekData = true;
     return;
   }
   GetAudioReader()->ResetDecode();
   mAudioSeekRequest.Begin(GetAudioReader()->Seek(GetReaderAudioTime(seekTime), 0)
                          ->RefableThen(GetTaskQueue(), __func__, this,
--- a/dom/media/mediasource/MediaSourceReader.h
+++ b/dom/media/mediasource/MediaSourceReader.h
@@ -262,16 +262,17 @@ private:
   int64_t mLastVideoTime;
 
   MediaPromiseConsumerHolder<SeekPromise> mAudioSeekRequest;
   MediaPromiseConsumerHolder<SeekPromise> mVideoSeekRequest;
   MediaPromiseHolder<SeekPromise> mSeekPromise;
 
   // Temporary seek information while we wait for the data
   // to be added to the track buffer.
+  int64_t mOriginalSeekTime;
   int64_t mPendingSeekTime;
   bool mWaitingForSeekData;
   bool mSeekToEnd;
 
   int64_t mTimeThreshold;
   bool mDropAudioBeforeThreshold;
   bool mDropVideoBeforeThreshold;