Bug 1159974 - Dispatch SetAudioCaptured. r=jww

While we're at it, I figured it was time to experiment with lambdas. :-)
This commit is contained in:
Bobby Holley 2015-05-01 14:54:06 -07:00
Родитель d4519a33a2
Коммит 598c3289ab
3 изменённых файлов: 16 добавлений и 14 удалений

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

@ -535,7 +535,7 @@ void MediaDecoder::AddOutputStream(ProcessedMediaStream* aStream,
{
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
if (mDecoderStateMachine) {
mDecoderStateMachine->SetAudioCaptured();
mDecoderStateMachine->DispatchAudioCaptured();
}
if (!GetDecodedStream()) {
int64_t t = mDecoderStateMachine ?
@ -748,7 +748,7 @@ void MediaDecoder::SetStateMachineParameters()
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
mDecoderStateMachine->SetDuration(mDuration);
if (GetDecodedStream()) {
mDecoderStateMachine->SetAudioCaptured();
mDecoderStateMachine->DispatchAudioCaptured();
}
if (mMinimizePreroll) {
mDecoderStateMachine->SetMinimizePrerollUntilPlaybackStarts();

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

@ -1372,17 +1372,6 @@ void MediaDecoderStateMachine::VolumeChanged()
}
}
void MediaDecoderStateMachine::SetAudioCaptured()
{
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
AssertCurrentThreadInMonitor();
if (!mAudioCaptured) {
mAudioCaptured = true;
// Schedule the state machine to send stream data as soon as possible.
ScheduleStateMachine();
}
}
double MediaDecoderStateMachine::GetCurrentTime() const
{
return static_cast<double>(mCurrentFrameTime) / static_cast<double>(USECS_PER_S);

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

@ -152,7 +152,20 @@ public:
return mState;
}
void SetAudioCaptured();
void DispatchAudioCaptured()
{
nsRefPtr<MediaDecoderStateMachine> self = this;
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction([self] () -> void
{
MOZ_ASSERT(self->OnTaskQueue());
ReentrantMonitorAutoEnter mon(self->mDecoder->GetReentrantMonitor());
if (!self->mAudioCaptured) {
self->mAudioCaptured = true;
self->ScheduleStateMachine();
}
});
TaskQueue()->Dispatch(r.forget());
}
// Check if the decoder needs to become dormant state.
bool IsDormantNeeded();