Bug 1308147. Part 1 - add WaitForCDMState::mPendingSeek to store a pending seek job. draft
authorJW Wang <jwwang@mozilla.com>
Tue, 18 Oct 2016 17:36:49 +0800
changeset 428540 9406c03a712a76e79beaf98549d6ddcf939004f9
parent 428507 29e1108484c06f85a831e95603fa39ed6ce29132
child 428541 041d7bf9e8937897b219a77193bc1783b6a78661
push id33335
push userjwwang@mozilla.com
push dateMon, 24 Oct 2016 07:05:42 +0000
bugs1308147
milestone52.0a1
Bug 1308147. Part 1 - add WaitForCDMState::mPendingSeek to store a pending seek job. MozReview-Commit-ID: LmSSm98k9Ze
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -366,49 +366,61 @@ class MediaDecoderStateMachine::WaitForC
   : public MediaDecoderStateMachine::StateObject
 {
 public:
   explicit WaitForCDMState(Master* aPtr) : StateObject(aPtr) {}
 
   void Enter(bool aPendingDormant)
   {
     MOZ_ASSERT(!mMaster->mVideoDecodeSuspended);
+
+    // WAIT_FOR_CDM is transitioned from DECODING_METADATA
+    // where mQueuedSeek must be empty.
+    MOZ_ASSERT(!mMaster->mQueuedSeek.Exists());
+
     mPendingDormant = aPendingDormant;
   }
 
+  void Exit() override
+  {
+    // Transfer the seek job so it is available to the next state.
+    mMaster->mQueuedSeek = Move(mPendingSeek);
+  }
+
   State GetState() const override
   {
     return DECODER_STATE_WAIT_FOR_CDM;
   }
 
   bool HandleDormant(bool aDormant) override;
 
   bool HandleCDMProxyReady() override;
 
   RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget) override
   {
     SLOG("Not Enough Data to seek at this stage, queuing seek");
-    mMaster->mQueuedSeek.RejectIfExists(__func__);
-    mMaster->mQueuedSeek.mTarget = aTarget;
-    return mMaster->mQueuedSeek.mPromise.Ensure(__func__);
+    mPendingSeek.RejectIfExists(__func__);
+    mPendingSeek.mTarget = aTarget;
+    return mPendingSeek.mPromise.Ensure(__func__);
   }
 
   void HandleVideoSuspendTimeout() override
   {
     // Do nothing since no decoders are created yet.
   }
 
   void HandleResumeVideoDecoding() override
   {
     // We never suspend video decoding in this state.
     MOZ_ASSERT(false, "Shouldn't have suspended video decoding.");
   }
 
 private:
   bool mPendingDormant = false;
+  SeekJob mPendingSeek;
 };
 
 /**
  * Purpose: release decoder resources to save memory and hardware resources.
  *
  * Transition to:
  *   DECODING_FIRSTFRAME when being asked to exit dormant.
  */