Bug 1314524. Part 5 - remove unused HandleDormant() functions. draft
authorJW Wang <jwwang@mozilla.com>
Fri, 28 Oct 2016 16:14:14 +0800
changeset 433067 0d652e7b55a5073fc8c7e3e88c6c4f35ccfa02ec
parent 433066 732fbc32d217dae870b50710790aaa7ebdab345e
child 433068 19f576d51da4bbe499505ec2539a80e327590479
push id34474
push userjwwang@mozilla.com
push dateThu, 03 Nov 2016 03:26:05 +0000
bugs1314524
milestone52.0a1
Bug 1314524. Part 5 - remove unused HandleDormant() functions. MozReview-Commit-ID: 8NRwInXS0uU
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -189,18 +189,16 @@ class MediaDecoderStateMachine::StateObj
 public:
   virtual ~StateObject() {}
   virtual void Exit() {};  // Exit action.
   virtual void Step() {}   // Perform a 'cycle' of this state object.
   virtual State GetState() const = 0;
 
   // Event handlers for various events.
   // Return true if the event is handled by this state object.
-  bool HandleDormant(bool aDormant);
-
   virtual bool HandleCDMProxyReady() { return false; }
 
   virtual bool HandleAudioDecoded(MediaData* aAudio) { return false; }
 
   virtual bool HandleVideoDecoded(MediaData* aVideo, TimeStamp aDecodeStart)
   {
     return false;
   }
@@ -313,22 +311,16 @@ public:
     mMetadataRequest.DisconnectIfExists();
   }
 
   State GetState() const override
   {
     return DECODER_STATE_DECODING_METADATA;
   }
 
-  bool HandleDormant(bool aDormant)
-  {
-    mPendingDormant = aDormant;
-    return true;
-  }
-
   RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget) override
   {
     MOZ_DIAGNOSTIC_ASSERT(false, "Can't seek while decoding metadata.");
     return MediaDecoder::SeekPromise::CreateAndReject(true, __func__);
   }
 
   void HandleVideoSuspendTimeout() override
   {
@@ -385,18 +377,16 @@ public:
     mPendingSeek.RejectIfExists(__func__);
   }
 
   State GetState() const override
   {
     return DECODER_STATE_WAIT_FOR_CDM;
   }
 
-  bool HandleDormant(bool aDormant);
-
   bool HandleCDMProxyReady() override;
 
   RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget) override
   {
     SLOG("Not Enough Data to seek at this stage, queuing seek");
     mPendingSeek.RejectIfExists(__func__);
     mPendingSeek.mTarget = aTarget;
     return mPendingSeek.mPromise.Ensure(__func__);
@@ -438,18 +428,18 @@ public:
       mMaster->StopPlayback();
     }
     mMaster->Reset();
     mMaster->mReader->ReleaseResources();
   }
 
   void Exit() override
   {
-    // mPendingSeek is either moved in HandleDormant() or should be rejected
-    // here before transition to SHUTDOWN.
+    // mPendingSeek is either moved when exiting dormant or
+    // should be rejected here before transition to SHUTDOWN.
     mPendingSeek.RejectIfExists(__func__);
   }
 
   State GetState() const override
   {
     return DECODER_STATE_DORMANT;
   }
 
@@ -517,18 +507,16 @@ public:
   bool HandleEndOfStream() override
   {
     MaybeFinishDecodeFirstFrame();
     return true;
   }
 
   RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget) override;
 
-  bool HandleDormant(bool aDormant);
-
   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.
@@ -872,18 +860,16 @@ public:
     mMaster->SetMediaDecoderReaderWrapperCallback();
   }
 
   State GetState() const override
   {
     return DECODER_STATE_SEEKING;
   }
 
-  bool HandleDormant(bool aDormant);
-
   bool HandleAudioDecoded(MediaData* aAudio) override
   {
     MOZ_ASSERT(false);
     return true;
   }
 
   bool HandleVideoDecoded(MediaData* aVideo, TimeStamp aDecodeStart) override
   {
@@ -1154,21 +1140,16 @@ public:
     MOZ_DIAGNOSTIC_ASSERT(false, "Shouldn't escape the SHUTDOWN state.");
   }
 
   State GetState() const override
   {
     return DECODER_STATE_SHUTDOWN;
   }
 
-  bool HandleDormant(bool aDormant)
-  {
-    return true;
-  }
-
   RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget) override
   {
     MOZ_DIAGNOSTIC_ASSERT(false, "Can't seek in shutdown state.");
     return MediaDecoder::SeekPromise::CreateAndReject(true, __func__);
   }
 
   RefPtr<ShutdownPromise> HandleShutdown() override
   {
@@ -1182,37 +1163,16 @@ public:
   }
 
   void HandleResumeVideoDecoding() override
   {
     MOZ_DIAGNOSTIC_ASSERT(false, "Already shutting down.");
   }
 };
 
-bool
-MediaDecoderStateMachine::
-StateObject::HandleDormant(bool aDormant)
-{
-  if (!aDormant) {
-    return true;
-  }
-  SeekJob seekJob;
-  int64_t seekTargetTime = mMaster->mMediaSink->IsStarted()
-                           ? mMaster->GetClock() : mMaster->GetMediaTime();
-
-  seekJob.mTarget = SeekTarget(seekTargetTime,
-                               SeekTarget::Accurate,
-                               MediaDecoderEventVisibility::Suppressed);
-  // SeekJob asserts |mTarget.IsValid() == !mPromise.IsEmpty()| so we
-  // need to create the promise even it is not used at all.
-  RefPtr<MediaDecoder::SeekPromise> unused = seekJob.mPromise.Ensure(__func__);
-  SetState<DormantState>(Move(seekJob));
-  return true;
-}
-
 RefPtr<ShutdownPromise>
 MediaDecoderStateMachine::
 StateObject::HandleShutdown()
 {
   return SetState<ShutdownState>();
 }
 
 static void
@@ -1345,24 +1305,16 @@ DecodeMetadataState::OnMetadataRead(Meta
     SetState<WaitForCDMState>(mPendingDormant);
   } else if (mPendingDormant) {
     SetState<DormantState>(SeekJob{});
   } else {
     SetState<DecodingFirstFrameState>(SeekJob{});
   }
 }
 
-bool
-MediaDecoderStateMachine::
-WaitForCDMState::HandleDormant(bool aDormant)
-{
-  mPendingDormant = aDormant;
-  return true;
-}
-
 RefPtr<MediaDecoder::SeekPromise>
 MediaDecoderStateMachine::
 DormantState::HandleSeek(SeekTarget aTarget)
 {
   // Exit dormant when the user wants to seek.
   mPendingSeek.RejectIfExists(__func__);
   SeekJob seekJob;
   seekJob.mTarget = aTarget;
@@ -1438,26 +1390,16 @@ DecodingFirstFrameState::HandleSeek(Seek
   MOZ_ASSERT(!mPendingSeek.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) {
-    SetState<DormantState>(Move(mPendingSeek));
-  }
-  return true;
-}
-
 void
 MediaDecoderStateMachine::
 DecodingFirstFrameState::MaybeFinishDecodeFirstFrame()
 {
   MOZ_ASSERT(!mMaster->mSentFirstFrameLoadedEvent);
 
   if ((mMaster->IsAudioDecoding() && mMaster->AudioQueue().GetSize() == 0) ||
       (mMaster->IsVideoDecoding() && mMaster->VideoQueue().GetSize() == 0)) {
@@ -1558,36 +1500,16 @@ DecodingState::MaybeStartBuffering()
       (mMaster->OutOfDecodedAudio() && Reader()->IsWaitingAudioData()) ||
       (mMaster->OutOfDecodedVideo() && Reader()->IsWaitingVideoData());
   }
   if (shouldBuffer) {
     SetState<BufferingState>();
   }
 }
 
-bool
-MediaDecoderStateMachine::
-SeekingState::HandleDormant(bool aDormant)
-{
-  if (!aDormant) {
-    return true;
-  }
-  MOZ_ASSERT(mSeekJob.Exists());
-  // Because both audio and video decoders are going to be reset in this
-  // method later, we treat a VideoOnly seek task as a normal Accurate
-  // seek task so that while it is resumed, both audio and video playback
-  // are handled.
-  if (mSeekJob.mTarget.IsVideoOnly()) {
-    mSeekJob.mTarget.SetType(SeekTarget::Accurate);
-    mSeekJob.mTarget.SetVideoOnly(false);
-  }
-  SetState<DormantState>(Move(mSeekJob));
-  return true;
-}
-
 RefPtr<MediaDecoder::SeekPromise>
 MediaDecoderStateMachine::
 SeekingState::HandleSeek(SeekTarget aTarget)
 {
   SLOG("Changed state to SEEKING (to %lld)", aTarget.GetTime().ToMicroseconds());
   SeekJob seekJob;
   seekJob.mTarget = aTarget;
   return SetState<SeekingState>(Move(seekJob));