Bug 1159974 - Dispatch SetMinimizePrerollUntilPlabackStarts. r=jww

This commit is contained in:
Bobby Holley 2015-05-01 16:34:57 -07:00
parent 9cd6c4764b
commit 196450c61a
3 changed files with 21 additions and 10 deletions

View File

@ -751,14 +751,19 @@ void MediaDecoder::SetStateMachineParameters()
mDecoderStateMachine->DispatchAudioCaptured();
}
if (mMinimizePreroll) {
mDecoderStateMachine->SetMinimizePrerollUntilPlaybackStarts();
mDecoderStateMachine->DispatchMinimizePrerollUntilPlaybackStarts();
}
}
void MediaDecoder::SetMinimizePrerollUntilPlaybackStarts()
{
DECODER_LOG("SetMinimizePrerollUntilPlaybackStarts()");
MOZ_ASSERT(NS_IsMainThread());
mMinimizePreroll = true;
// This needs to be called before we init the state machine, otherwise it will
// have no effect.
MOZ_DIAGNOSTIC_ASSERT(!mDecoderStateMachine);
}
nsresult MediaDecoder::ScheduleStateMachineThread()

View File

@ -3416,14 +3416,6 @@ void MediaDecoderStateMachine::PreservesPitchChanged()
}
}
void
MediaDecoderStateMachine::SetMinimizePrerollUntilPlaybackStarts()
{
AssertCurrentThreadInMonitor();
DECODER_LOG("SetMinimizePrerollUntilPlaybackStarts()");
mMinimizePreroll = true;
}
bool MediaDecoderStateMachine::IsShutdown()
{
AssertCurrentThreadInMonitor();

View File

@ -399,7 +399,21 @@ public:
// the state machine is free to return to prerolling normally. Note
// "prerolling" in this context refers to when we decode and buffer decoded
// samples in advance of when they're needed for playback.
void SetMinimizePrerollUntilPlaybackStarts();
void DispatchMinimizePrerollUntilPlaybackStarts()
{
nsRefPtr<MediaDecoderStateMachine> self = this;
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction([self] () -> void
{
MOZ_ASSERT(self->OnTaskQueue());
ReentrantMonitorAutoEnter mon(self->mDecoder->GetReentrantMonitor());
self->mMinimizePreroll = true;
// Make sure that this arrives before playback starts, otherwise this won't
// have the intended effect.
MOZ_DIAGNOSTIC_ASSERT(self->mPlayState == MediaDecoder::PLAY_STATE_LOADING);
});
TaskQueue()->Dispatch(r.forget());
}
void OnAudioDecoded(AudioData* aSample);
void OnVideoDecoded(VideoData* aSample);