Bug 1310140. Part 6 - have DecodingState handle suspend-video-decoding.
MozReview-Commit-ID: 3GxHdxZCiwE
--- 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();
@@ -1127,16 +1134,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();