Bug 1310140. Part 6 - have DecodingState handle suspend-video-decoding. r=kaku,kamidphish
authorJW Wang <jwwang@mozilla.com>
Tue, 18 Oct 2016 10:48:46 +0800
changeset 318474 bc9daff4c5e084224e23aab9afe372e1fe934ef4
parent 318473 008b75b607a6a035d2df622a24df618416ebde64
child 318475 d4a4999dcf1571a6be82e6fea3cc97072206a3d0
push id30841
push usercbook@mozilla.com
push dateWed, 19 Oct 2016 14:59:31 +0000
treeherdermozilla-central@8b2d92343bcb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskaku, kamidphish
bugs1310140
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1310140. Part 6 - have DecodingState handle suspend-video-decoding. r=kaku,kamidphish MozReview-Commit-ID: 3GxHdxZCiwE
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -530,16 +530,23 @@ public:
   bool HandleAudioCaptured() override
   {
     MaybeStopPrerolling();
     // MediaSink is changed. Schedule Step() to check if we can start playback.
     mMaster->ScheduleStateMachine();
     return true;
   }
 
+  void HandleVideoSuspendTimeout() override
+  {
+    mMaster->mVideoDecodeSuspended = true;
+    mMaster->mOnPlaybackEvent.Notify(MediaEventType::EnterVideoSuspend);
+    Reader()->SetVideoBlankDecode(true);
+  }
+
   void DumpDebugInfo() override
   {
     SDUMP("mIsPrerolling=%d", mIsPrerolling);
   }
 
 private:
   void MaybeStartBuffering();
 
@@ -1124,16 +1131,24 @@ void
 MediaDecoderStateMachine::
 DecodingState::Enter()
 {
   MOZ_ASSERT(mMaster->mSentFirstFrameLoadedEvent);
   // Pending seek should've been handled by DECODING_FIRSTFRAME before
   // transitioning to DECODING.
   MOZ_ASSERT(!mMaster->mQueuedSeek.Exists());
 
+  if (!mMaster->mIsVisible &&
+      !mMaster->mVideoDecodeSuspendTimer.IsScheduled() &&
+      !mMaster->mVideoDecodeSuspended) {
+    // If we are not visible and the timer is not schedule, it means the timer
+    // has timed out and we should suspend video decoding now if necessary.
+    HandleVideoSuspendTimeout();
+  }
+
   if (mMaster->CheckIfDecodeComplete()) {
     SetState<CompletedState>();
     return;
   }
 
   mDecodeStartTime = TimeStamp::Now();
 
   MaybeStopPrerolling();