Bug 1128811 - Reject data wait promises when we seek. r=cpearce a=lmandel
authorBobby Holley <bobbyholley@gmail.com>
Tue, 03 Feb 2015 18:17:56 -0800
changeset 249792 dc9a1813588e6fc08321aa54ef59c83ee551e63f
parent 249791 c7855054fc6838f1e7f4207c170e70c72c0f47af
child 249793 cd0f43f2bb0e26c04fcfc17bf1319bfcadb73760
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce, lmandel
bugs1128811
milestone37.0a2
Bug 1128811 - Reject data wait promises when we seek. r=cpearce a=lmandel
dom/media/MediaDecoderReader.h
dom/media/MediaDecoderStateMachine.h
dom/media/mediasource/MediaSourceReader.cpp
--- a/dom/media/MediaDecoderReader.h
+++ b/dom/media/MediaDecoderReader.h
@@ -21,17 +21,18 @@ namespace dom {
 class TimeRanges;
 }
 
 class MediaDecoderReader;
 class SharedDecoderManager;
 
 struct WaitForDataRejectValue {
   enum Reason {
-    SHUTDOWN
+    SHUTDOWN,
+    CANCELED
   };
 
   WaitForDataRejectValue(MediaData::Type aType, Reason aReason)
     :mType(aType), mReason(aReason) {}
   MediaData::Type mType;
   Reason mReason;
 };
 
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -417,17 +417,16 @@ public:
     if (RequestStatusRef(aType) == RequestStatus::Waiting) {
       RequestStatusRef(aType) = RequestStatus::Idle;
       DispatchDecodeTasksIfNeeded();
     }
   }
 
   void OnWaitForDataRejected(WaitForDataRejectValue aRejection)
   {
-    MOZ_ASSERT(aRejection.mReason == WaitForDataRejectValue::SHUTDOWN);
     if (RequestStatusRef(aRejection.mType) == RequestStatus::Waiting) {
       RequestStatusRef(aRejection.mType) = RequestStatus::Idle;
     }
   }
 
 private:
   void AcquireMonitorAndInvokeDecodeError();
 
--- a/dom/media/mediasource/MediaSourceReader.cpp
+++ b/dom/media/mediasource/MediaSourceReader.cpp
@@ -683,16 +683,20 @@ MediaSourceReader::Seek(int64_t aTime, i
   mAudioRequest.DisconnectIfExists();
   mVideoRequest.DisconnectIfExists();
 
   // Additionally, reject any outstanding promises _we_ made that we might have
   // been waiting on the above to fulfill.
   mAudioPromise.RejectIfExists(CANCELED, __func__);
   mVideoPromise.RejectIfExists(CANCELED, __func__);
 
+  // Do the same for any data wait promises.
+  mAudioWaitPromise.RejectIfExists(WaitForDataRejectValue(MediaData::AUDIO_DATA, WaitForDataRejectValue::CANCELED), __func__);
+  mVideoWaitPromise.RejectIfExists(WaitForDataRejectValue(MediaData::VIDEO_DATA, WaitForDataRejectValue::CANCELED), __func__);
+
   // Finally, if we were midway seeking a new reader to find a sample, abandon
   // that too.
   mAudioSeekRequest.DisconnectIfExists();
   mVideoSeekRequest.DisconnectIfExists();
 
   // Store pending seek target in case the track buffers don't contain
   // the desired time and we delay doing the seek.
   mPendingSeekTime = aTime;