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
--- 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(); });