Bug 1114840 - Use StartDecoding() rather than SetState in PlayInternal. r=cpearce

This makes sure that decode tasks are dispatched and that all the preroll state
is appropriately set up.
This commit is contained in:
Bobby Holley 2014-12-29 23:16:48 -08:00
parent 87a09e70db
commit 756be06580

View File

@ -1505,9 +1505,16 @@ void MediaDecoderStateMachine::DoNotifyWaitingForResourcesStatusChanged()
void MediaDecoderStateMachine::PlayInternal()
{
NS_ASSERTION(OnStateMachineThread(), "Should be on state machine thread.");
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
// Once we start playing, we don't want to minimize our prerolling, as we
// assume the user is likely to want to keep playing in future. This needs to
// happen before we invoke StartDecoding().
if (mMinimizePreroll) {
mMinimizePreroll = false;
DispatchDecodeTasksIfNeeded();
}
// Some state transitions still happen synchronously on the main thread. So
// if the main thread invokes Play() and then Seek(), the seek will initiate
// synchronously on the main thread, and the asynchronous PlayInternal task
@ -1526,17 +1533,14 @@ void MediaDecoderStateMachine::PlayInternal()
// we are currently buffering. In other cases, we'll start playing anyway
// when the state machine notices the decoder's state change to PLAYING.
if (mState == DECODER_STATE_BUFFERING) {
DECODER_LOG("Changed state from BUFFERING to DECODING");
SetState(DECODER_STATE_DECODING);
mDecodeStartTime = TimeStamp::Now();
StartDecoding();
}
if (mDecodingFrozenAtStateDecoding) {
mDecodingFrozenAtStateDecoding = false;
DispatchDecodeTasksIfNeeded();
}
// Once we start playing, we don't want to minimize our prerolling, as we
// assume the user is likely to want to keep playing in future.
mMinimizePreroll = false;
ScheduleStateMachine();
}
@ -3379,6 +3383,7 @@ void
MediaDecoderStateMachine::SetMinimizePrerollUntilPlaybackStarts()
{
AssertCurrentThreadInMonitor();
DECODER_LOG("SetMinimizePrerollUntilPlaybackStarts()");
mMinimizePreroll = true;
}