Bug 1310140. Part 12 - move the HasVideo() check into HandleVideoSuspendTimeout(). draft
authorJW Wang <jwwang@mozilla.com>
Tue, 18 Oct 2016 14:07:07 +0800
changeset 426837 cebaece8441a52370b2954898dfe4c852832edd7
parent 426836 9fc043196994bda7aff42381b09ec0ca66477779
child 426838 206a0add4d051a2dcba130c61d87e1101bc47733
push id32814
push userjwwang@mozilla.com
push dateWed, 19 Oct 2016 06:32:41 +0000
bugs1310140
milestone52.0a1
Bug 1310140. Part 12 - move the HasVideo() check into HandleVideoSuspendTimeout(). If MDSM becomes invisible while decoding metadata, VisibilityChanged() will return early because mInfo is still nothing. And MDSM will never suspend video decoding if there are no visibility changes later. We should delay the check util the timer goes off and MDSM needs to switch on the blank decoder. MozReview-Commit-ID: Ids9MncpC2l
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -527,19 +527,21 @@ public:
     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);
+    if (mMaster->HasVideo()) {
+      mMaster->mVideoDecodeSuspended = true;
+      mMaster->mOnPlaybackEvent.Notify(MediaEventType::EnterVideoSuspend);
+      Reader()->SetVideoBlankDecode(true);
+    }
   }
 
   void DumpDebugInfo() override
   {
     SDUMP("mIsPrerolling=%d", mIsPrerolling);
   }
 
 private:
@@ -825,19 +827,21 @@ public:
   }
 
   bool HandleEndOfStream() override;
 
   RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget) override;
 
   void HandleVideoSuspendTimeout() override
   {
-    mMaster->mVideoDecodeSuspended = true;
-    mMaster->mOnPlaybackEvent.Notify(MediaEventType::EnterVideoSuspend);
-    Reader()->SetVideoBlankDecode(true);
+    if (mMaster->HasVideo()) {
+      mMaster->mVideoDecodeSuspended = true;
+      mMaster->mOnPlaybackEvent.Notify(MediaEventType::EnterVideoSuspend);
+      Reader()->SetVideoBlankDecode(true);
+    }
   }
 
 private:
   TimeStamp mBufferingStart;
 
   // The maximum number of second we spend buffering when we are short on
   // unbuffered data.
   const uint32_t mBufferingWait = 15;
@@ -2314,20 +2318,16 @@ ReportRecoveryTelemetry(const TimeStamp&
 
 void MediaDecoderStateMachine::VisibilityChanged()
 {
   MOZ_ASSERT(OnTaskQueue());
   DECODER_LOG("VisibilityChanged: mIsVisible=%d, "
               "mVideoDecodeSuspended=%c, mIsReaderSuspended=%d",
               mIsVisible.Ref(), mVideoDecodeSuspended ? 'T' : 'F', mIsReaderSuspended.Ref());
 
-  if (mInfo.isNothing() || !HasVideo()) {
-    return;
-  }
-
   // Start timer to trigger suspended decoding state when going invisible.
   if (!mIsVisible) {
     TimeStamp target = TimeStamp::Now() + SuspendBackgroundVideoDelay();
 
     RefPtr<MediaDecoderStateMachine> self = this;
     mVideoDecodeSuspendTimer.Ensure(target,
                                     [=]() { self->OnSuspendTimerResolved(); },
                                     [=]() { self->OnSuspendTimerRejected(); });