Bug 1159974 - Dispatch SetMinimizePrerollUntilPlabackStarts. r=jww

This commit is contained in:
Bobby Holley 2015-05-01 16:34:57 -07:00
Родитель 598c3289ab
Коммит 7e4411d3ff
3 изменённых файлов: 21 добавлений и 10 удалений

Просмотреть файл

@ -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()

Просмотреть файл

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

Просмотреть файл

@ -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);