Bug 1285248. Part 2 - fix logic for video-only seek. r=gerald
authorJW Wang <jwwang@mozilla.com>
Fri, 08 Jul 2016 11:52:40 +0800
changeset 304236 0aa6ee3eb1d8cb7380397b8c28abbabc122fa210
parent 304235 32de23e9cca627e3e48eb56c186a1598a7ef4c20
child 304237 114f71154f0095cd439e3619f5e453713aeaa337
push id79280
push userkwierso@gmail.com
push dateFri, 08 Jul 2016 22:04:28 +0000
treeherdermozilla-inbound@14b16ac38991 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1285248
milestone50.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 1285248. Part 2 - fix logic for video-only seek. r=gerald MozReview-Commit-ID: lopt6zxC5f
dom/media/AccurateSeekTask.cpp
--- a/dom/media/AccurateSeekTask.cpp
+++ b/dom/media/AccurateSeekTask.cpp
@@ -304,16 +304,24 @@ AccurateSeekTask::OnAudioDecoded(MediaDa
   MOZ_ASSERT(audio);
 
   // The MDSM::mDecodedAudioEndTime will be updated once the whole SeekTask is
   // resolved.
 
   SAMPLE_LOG("OnAudioDecoded [%lld,%lld] disc=%d",
     audio->mTime, audio->GetEndTime(), audio->mDiscontinuity);
 
+  // Video-only seek doesn't reset audio decoder. There might be pending audio
+  // requests when AccurateSeekTask::Seek() begins. We will just store the data
+  // without checking |mDiscontinuity| or calling DropAudioUpToSeekTarget().
+  if (mSeekJob.mTarget.IsVideoOnly()) {
+    mSeekedAudioData = audio.forget();
+    return;
+  }
+
   if (mFirstAudioSample) {
     mFirstAudioSample = false;
     MOZ_ASSERT(audio->mDiscontinuity);
   }
 
   AdjustFastSeekIfNeeded(audio);
 
   if (mSeekJob.mTarget.IsFast()) {
@@ -336,16 +344,21 @@ void
 AccurateSeekTask::OnNotDecoded(MediaData::Type aType,
                                MediaDecoderReader::NotDecodedReason aReason)
 {
   AssertOwnerThread();
   MOZ_ASSERT(!mSeekTaskPromise.IsEmpty(), "Seek shouldn't be finished");
 
   SAMPLE_LOG("OnNotDecoded type=%d reason=%u", aType, aReason);
 
+  // Ignore pending requests from video-only seek.
+  if (aType == MediaData::AUDIO_DATA && mSeekJob.mTarget.IsVideoOnly()) {
+    return;
+  }
+
   if (aReason == MediaDecoderReader::DECODE_ERROR) {
     // If this is a decode error, delegate to the generic error path.
     RejectIfExist(__func__);
     return;
   }
 
   // If the decoder is waiting for data, we tell it to call us back when the
   // data arrives.
@@ -441,16 +454,20 @@ AccurateSeekTask::SetCallbacks()
     } else {
       OnNotDecoded(MediaData::VIDEO_DATA,
         aData.as<MediaDecoderReader::NotDecodedReason>());
     }
   });
 
   mAudioWaitCallback = mReader->AudioWaitCallback().Connect(
     OwnerThread(), [this] (WaitCallbackData aData) {
+    // Ignore pending requests from video-only seek.
+    if (mSeekJob.mTarget.IsVideoOnly()) {
+      return;
+    }
     if (aData.is<MediaData::Type>()) {
       RequestAudioData();
     }
   });
 
   mVideoWaitCallback = mReader->VideoWaitCallback().Connect(
     OwnerThread(), [this] (WaitCallbackData aData) {
     if (aData.is<MediaData::Type>()) {