Bug 1314524. Part 3 - add DecodingState::EnterDormant().
MozReview-Commit-ID: 6YbO61mWqnj
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -725,35 +725,49 @@ private:
(DonePrerollingAudio() || Reader()->IsWaitingAudioData()) &&
(DonePrerollingVideo() || Reader()->IsWaitingVideoData())) {
mIsPrerolling = false;
// Check if we can start playback.
mMaster->ScheduleStateMachine();
}
}
+ void EnterDormant()
+ {
+ auto t = mMaster->mMediaSink->IsStarted()
+ ? mMaster->GetClock()
+ : mMaster->GetMediaTime();
+ SeekJob seekJob;
+ seekJob.mTarget = SeekTarget(t, SeekTarget::Accurate,
+ MediaDecoderEventVisibility::Suppressed);
+ // SeekJob asserts |mTarget.IsValid() == !mPromise.IsEmpty()| so we
+ // need to create the promise even it is not used at all.
+ RefPtr<MediaDecoder::SeekPromise> unused = seekJob.mPromise.Ensure(__func__);
+ SetState<DormantState>(Move(seekJob));
+ }
+
void StartDormantTimer()
{
auto timeout = MediaPrefs::DormantOnPauseTimeout();
if (timeout < 0) {
// Disabled when timeout is negative.
return;
} else if (timeout == 0) {
// Enter dormant immediately without scheduling a timer.
- HandleDormant(true);
+ EnterDormant();
return;
}
TimeStamp target = TimeStamp::Now() +
TimeDuration::FromMilliseconds(timeout);
mDormantTimer.Ensure(target,
[this] () {
mDormantTimer.CompleteRequest();
- HandleDormant(true);
+ EnterDormant();
}, [this] () {
mDormantTimer.CompleteRequest();
});
}
// Time at which we started decoding.
TimeStamp mDecodeStartTime;