Bug 1349097 P1 - let HandleResumeVideoDecoding() take a const TimeUnit& argument; r?jwwang draft
authorKaku Kuo <kaku@mozilla.com>
Tue, 28 Mar 2017 11:21:41 +0800
changeset 556585 80f876a2c724dd9ad1f56e181c7adcbae29ab47a
parent 556469 867df9483d5af4c8c12e19fab9b0de18bee30db7
child 556586 e5ffd8f9258b67f7874150254cc7a60ecada5109
push id52588
push userbmo:kaku@mozilla.com
push dateThu, 06 Apr 2017 03:24:43 +0000
reviewersjwwang
bugs1349097
milestone55.0a1
Bug 1349097 P1 - let HandleResumeVideoDecoding() take a const TimeUnit& argument; r?jwwang MozReview-Commit-ID: BEBLUP9SwWC
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -240,17 +240,17 @@ public:
   }
 
   virtual RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget);
 
   virtual RefPtr<ShutdownPromise> HandleShutdown();
 
   virtual void HandleVideoSuspendTimeout() = 0;
 
-  virtual void HandleResumeVideoDecoding();
+  virtual void HandleResumeVideoDecoding(const TimeUnit& aTarget);
 
   virtual void HandlePlayStateChanged(MediaDecoder::PlayState aPlayState) {}
 
   virtual nsCString GetDebugInfo() { return nsCString(); }
 
 private:
   template <class S, typename R, typename... As>
   auto ReturnTypeHelper(R(S::*)(As...)) -> R;
@@ -390,17 +390,17 @@ public:
     return MediaDecoder::SeekPromise::CreateAndReject(true, __func__);
   }
 
   void HandleVideoSuspendTimeout() override
   {
     // Do nothing since no decoders are created yet.
   }
 
-  void HandleResumeVideoDecoding() override
+  void HandleResumeVideoDecoding(const TimeUnit&) override
   {
     // We never suspend video decoding in this state.
     MOZ_ASSERT(false, "Shouldn't have suspended video decoding.");
   }
 
 private:
   void OnMetadataRead(MetadataHolder* aMetadata);
 
@@ -454,17 +454,17 @@ public:
     return mPendingSeek.mPromise.Ensure(__func__);
   }
 
   void HandleVideoSuspendTimeout() override
   {
     // Do nothing since no decoders are created yet.
   }
 
-  void HandleResumeVideoDecoding() override
+  void HandleResumeVideoDecoding(const TimeUnit&) override
   {
     // We never suspend video decoding in this state.
     MOZ_ASSERT(false, "Shouldn't have suspended video decoding.");
   }
 
 private:
   SeekJob mPendingSeek;
 };
@@ -513,17 +513,17 @@ public:
     return DECODER_STATE_DORMANT;
   }
 
   void HandleVideoSuspendTimeout() override
   {
     // Do nothing since we've released decoders in Enter().
   }
 
-  void HandleResumeVideoDecoding() override
+  void HandleResumeVideoDecoding(const TimeUnit&) override
   {
     // Do nothing since we won't resume decoding until exiting dormant.
   }
 
   void HandlePlayStateChanged(MediaDecoder::PlayState aPlayState) override;
 
 private:
   SeekJob mPendingSeek;
@@ -612,17 +612,17 @@ public:
   }
 
   void HandleVideoSuspendTimeout() override
   {
     // Do nothing for we need to decode the 1st video frame to get the
     // dimensions.
   }
 
-  void HandleResumeVideoDecoding() override
+  void HandleResumeVideoDecoding(const TimeUnit&) override
   {
     // We never suspend video decoding in this state.
     MOZ_ASSERT(false, "Shouldn't have suspended video decoding.");
   }
 
   RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget) override
   {
     if (mMaster->mIsMSE) {
@@ -992,17 +992,17 @@ public:
   void HandleAudioWaited(MediaData::Type aType) override = 0;
   void HandleVideoWaited(MediaData::Type aType) override = 0;
 
   void HandleVideoSuspendTimeout() override
   {
     // Do nothing since we want a valid video frame to show when seek is done.
   }
 
-  void HandleResumeVideoDecoding() override
+  void HandleResumeVideoDecoding(const TimeUnit&) override
   {
     // We set mVideoDecodeSuspended to false in Enter().
     MOZ_ASSERT(false, "Shouldn't have suspended video decoding.");
   }
 
 protected:
   SeekJob mSeekJob;
 
@@ -1939,17 +1939,17 @@ public:
     return nullptr;
   }
 
   void HandleVideoSuspendTimeout() override
   {
     MOZ_DIAGNOSTIC_ASSERT(false, "Already shutting down.");
   }
 
-  void HandleResumeVideoDecoding() override
+  void HandleResumeVideoDecoding(const TimeUnit&) override
   {
     MOZ_DIAGNOSTIC_ASSERT(false, "Already shutting down.");
   }
 };
 
 RefPtr<MediaDecoder::SeekPromise>
 MediaDecoderStateMachine::
 StateObject::HandleSeek(SeekTarget aTarget)
@@ -2005,17 +2005,17 @@ ReportRecoveryTelemetry(const TimeStamp&
                         uint32_t(duration_ms + 0.5));
   Telemetry::Accumulate(Telemetry::VIDEO_SUSPEND_RECOVERY_TIME_MS,
                         NS_LITERAL_CSTRING("All"),
                         uint32_t(duration_ms + 0.5));
 }
 
 void
 MediaDecoderStateMachine::
-StateObject::HandleResumeVideoDecoding()
+StateObject::HandleResumeVideoDecoding(const TimeUnit& aTarget)
 {
   MOZ_ASSERT(mMaster->mVideoDecodeSuspended);
 
   // Start counting recovery time from right now.
   TimeStamp start = TimeStamp::Now();
 
   // Local reference to mInfo, so that it will be copied in the lambda below.
   auto& info = Info();
@@ -2023,19 +2023,17 @@ StateObject::HandleResumeVideoDecoding()
 
   // Start video-only seek to the current time.
   SeekJob seekJob;
 
   const SeekTarget::Type type = mMaster->HasAudio()
                                 ? SeekTarget::Type::Accurate
                                 : SeekTarget::Type::PrevSyncPoint;
 
-  seekJob.mTarget.emplace(mMaster->GetMediaTime(),
-                          type,
-                          true /* aVideoOnly */);
+  seekJob.mTarget.emplace(aTarget, type, true /* aVideoOnly */);
 
   // Hold mMaster->mAbstractMainThread here because this->mMaster will be
   // invalid after the current state object is deleted in SetState();
   RefPtr<AbstractThread> mainThread = mMaster->mAbstractMainThread;
 
   SetSeekingState(Move(seekJob), EventVisibility::Observable)->Then(
     mainThread, __func__,
     [start, info, hw](){ ReportRecoveryTelemetry(start, info, hw); },
@@ -3071,17 +3069,17 @@ void MediaDecoderStateMachine::SetVideoD
   }
 
   // Resuming from suspended decoding
 
   // If suspend timer exists, destroy it.
   CancelSuspendTimer();
 
   if (mVideoDecodeSuspended) {
-    mStateObj->HandleResumeVideoDecoding();
+    mStateObj->HandleResumeVideoDecoding(GetMediaTime());
   }
 }
 
 void MediaDecoderStateMachine::BufferedRangeUpdated()
 {
   MOZ_ASSERT(OnTaskQueue());
 
   // While playing an unseekable stream of unknown duration, mObservedDuration