Bug 1121692 - Handle mid-seek Request{Audio,Video}Data calls. r=cpearce, a=sledru
authorBobby Holley <bobbyholley@gmail.com>
Fri, 16 Jan 2015 10:58:00 -0800
changeset 242943 4f059ea15ecf
parent 242942 2195dc79a65f
child 242944 56744595737c
push id4343
push userryanvm@gmail.com
push date2015-01-20 16:38 +0000
treeherdermozilla-beta@c5dfa7d081f4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce, sledru
bugs1121692
milestone36.0
Bug 1121692 - Handle mid-seek Request{Audio,Video}Data calls. r=cpearce, a=sledru The MDSM really shouldn't be issuing these. The correct solution (which I'll file a followup bug for) is to fix the MDSM to not do that. But rejecting the promise with CANCELED is a lot safer, so we do that for now.
dom/media/mediasource/MediaSourceReader.cpp
--- a/dom/media/mediasource/MediaSourceReader.cpp
+++ b/dom/media/mediasource/MediaSourceReader.cpp
@@ -113,17 +113,21 @@ MediaSourceReader::RequestAudioData()
 {
   nsRefPtr<AudioDataPromise> p = mAudioPromise.Ensure(__func__);
   MSE_DEBUGV("MediaSourceReader(%p)::RequestAudioData", this);
   if (!mAudioReader) {
     MSE_DEBUG("MediaSourceReader(%p)::RequestAudioData called with no audio reader", this);
     mAudioPromise.Reject(DECODE_ERROR, __func__);
     return p;
   }
-  MOZ_ASSERT(!mAudioIsSeeking);
+  if (mAudioIsSeeking) {
+    MSE_DEBUG("MediaSourceReader(%p)::RequestAudioData called mid-seek. Rejecting.", this);
+    mAudioPromise.Reject(CANCELED, __func__);
+    return p;
+  }
   if (SwitchAudioReader(mLastAudioTime)) {
     mAudioReader->Seek(mLastAudioTime, 0)
                 ->Then(GetTaskQueue(), __func__, this,
                        &MediaSourceReader::RequestAudioDataComplete,
                        &MediaSourceReader::RequestAudioDataFailed);
   } else {
     RequestAudioDataComplete(0);
   }
@@ -247,17 +251,21 @@ MediaSourceReader::RequestVideoData(bool
     mVideoPromise.Reject(DECODE_ERROR, __func__);
     return p;
   }
   if (aSkipToNextKeyframe) {
     mTimeThreshold = aTimeThreshold;
     mDropAudioBeforeThreshold = true;
     mDropVideoBeforeThreshold = true;
   }
-  MOZ_ASSERT(!mVideoIsSeeking);
+  if (mVideoIsSeeking) {
+    MSE_DEBUG("MediaSourceReader(%p)::RequestVideoData called mid-seek. Rejecting.", this);
+    mVideoPromise.Reject(CANCELED, __func__);
+    return p;
+  }
   if (SwitchVideoReader(mLastVideoTime)) {
     mVideoReader->Seek(mLastVideoTime, 0)
                 ->Then(GetTaskQueue(), __func__, this,
                        &MediaSourceReader::RequestVideoDataComplete,
                        &MediaSourceReader::RequestVideoDataFailed);
   } else {
     mVideoReader->RequestVideoData(aSkipToNextKeyframe, aTimeThreshold)
                 ->Then(GetTaskQueue(), __func__, this,