Bug 1311267 - DecodingFirstFrameState should override HandleDormant(). draft
authorJW Wang <jwwang@mozilla.com>
Wed, 19 Oct 2016 14:25:42 +0800
changeset 426848 f8f248c34e11f9d66ea63aa9b764c758efb62c38
parent 426838 206a0add4d051a2dcba130c61d87e1101bc47733
child 534284 ae88d3c26e09b48a6e1da572e14aab862fbfc724
push id32821
push userjwwang@mozilla.com
push dateWed, 19 Oct 2016 07:20:35 +0000
bugs1311267
milestone52.0a1
Bug 1311267 - DecodingFirstFrameState should override HandleDormant(). MozReview-Commit-ID: LGcvRJF3cNC
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -461,16 +461,18 @@ public:
   bool HandleEndOfStream() override
   {
     MaybeFinishDecodeFirstFrame();
     return true;
   }
 
   RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget) override;
 
+  bool HandleDormant(bool aDormant) override;
+
   void HandleVideoSuspendTimeout() override
   {
     // Do nothing for we need to decode the 1st video frame to get the dimensions.
   }
 
   void HandleResumeVideoDecoding() override
   {
     // We never suspend video decoding in this state.
@@ -1250,16 +1252,31 @@ DecodingFirstFrameState::HandleSeek(Seek
   MOZ_ASSERT(!mMaster->mQueuedSeek.Exists());
 
   SLOG("Changed state to SEEKING (to %lld)", aTarget.GetTime().ToMicroseconds());
   SeekJob seekJob;
   seekJob.mTarget = aTarget;
   return SetState<SeekingState>(Move(seekJob));
 }
 
+bool
+MediaDecoderStateMachine::
+DecodingFirstFrameState::HandleDormant(bool aDormant)
+{
+  if (aDormant) {
+    // Don't store mQueuedSeek because:
+    // 1. if mQueuedSeek is not empty, respect the latest seek request
+    //    and don't overwrite it.
+    // 2. if mQueuedSeek is empty, there is no need to seek when exiting
+    //    the dormant state for we are at position 0.
+    SetState<DormantState>();
+  }
+  return true;
+}
+
 void
 MediaDecoderStateMachine::
 DecodingFirstFrameState::MaybeFinishDecodeFirstFrame()
 {
   MOZ_ASSERT(!mMaster->mSentFirstFrameLoadedEvent);
 
   if ((mMaster->IsAudioDecoding() && mMaster->AudioQueue().GetSize() == 0) ||
       (mMaster->IsVideoDecoding() && mMaster->VideoQueue().GetSize() == 0)) {