Bug 1307725. Part 2 - handle prerolling in DecodingState::HandleEndOfStream() and move it to the public section.
MozReview-Commit-ID: DMlLV8KLXvQ
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -630,16 +630,26 @@ public:
SLOG("Changed state to SEEKING (to %lld)", aTarget.GetTime().ToMicroseconds());
SeekJob seekJob;
seekJob.mTarget = aTarget;
RefPtr<MediaDecoder::SeekPromise> p = seekJob.mPromise.Ensure(__func__);
mMaster->InitiateSeek(Move(seekJob));
return p.forget();
}
+ bool HandleEndOfStream() override
+ {
+ if (mMaster->CheckIfDecodeComplete()) {
+ SetState(DECODER_STATE_COMPLETED);
+ } else {
+ mMaster->MaybeStopPrerolling();
+ }
+ return true;
+ }
+
bool HandleAudioCaptured() override
{
mMaster->MaybeStopPrerolling();
// MediaSink is changed. Schedule Step() to check if we can start playback.
mMaster->ScheduleStateMachine();
return true;
}
@@ -670,24 +680,16 @@ private:
SLOG("Slow video decode, set "
"mLowAudioThresholdUsecs=%lld "
"mAmpleAudioThresholdUsecs=%lld",
mMaster->mLowAudioThresholdUsecs,
mMaster->mAmpleAudioThresholdUsecs);
}
}
- bool HandleEndOfStream() override
- {
- if (mMaster->CheckIfDecodeComplete()) {
- SetState(DECODER_STATE_COMPLETED);
- }
- return true;
- }
-
// Time at which we started decoding.
TimeStamp mDecodeStartTime;
};
class MediaDecoderStateMachine::SeekingState
: public MediaDecoderStateMachine::StateObject
{
public:
@@ -1589,18 +1591,16 @@ MediaDecoderStateMachine::OnNotDecoded(M
// This is an EOS. Finish off the queue, and then handle things based on our
// state.
if (isAudio) {
AudioQueue().Finish();
} else {
VideoQueue().Finish();
}
- MaybeStopPrerolling();
-
mStateObj->HandleEndOfStream();
}
void
MediaDecoderStateMachine::OnVideoDecoded(MediaData* aVideo,
TimeStamp aDecodeStartTime)
{
MOZ_ASSERT(OnTaskQueue());