Bug 815492 - Pause Web Audio playback when entering the bfcache, and resume it when coming out of the bfcache; r=bzbarsky

This commit is contained in:
Ehsan Akhgari 2013-03-21 22:59:33 -04:00
parent 7f1add90db
commit e9e1b63618
3 changed files with 25 additions and 0 deletions

View File

@ -197,5 +197,17 @@ AudioContext::CurrentTime() const
return MediaTimeToSeconds(Destination()->Stream()->GetCurrentTime());
}
void
AudioContext::Suspend()
{
DestinationStream()->ChangeExplicitBlockerCount(1);
}
void
AudioContext::Resume()
{
DestinationStream()->ChangeExplicitBlockerCount(-1);
}
}
}

View File

@ -69,6 +69,9 @@ public:
mDecoder.Shutdown();
}
void Suspend();
void Resume();
virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
static already_AddRefed<AudioContext>

View File

@ -10870,6 +10870,11 @@ nsGlobalWindow::SuspendTimeouts(uint32_t aIncrease,
t->Release();
}
}
// Suspend all of the AudioContexts for this window
for (uint32_t i = 0; i < mAudioContexts.Length(); ++i) {
mAudioContexts[i]->Suspend();
}
}
// Suspend our children as well.
@ -10926,6 +10931,11 @@ nsGlobalWindow::ResumeTimeouts(bool aThawChildren)
}
EnableGamepadUpdates();
// Resume all of the AudioContexts for this window
for (uint32_t i = 0; i < mAudioContexts.Length(); ++i) {
mAudioContexts[i]->Resume();
}
// Resume all of the workers for this window.
nsIScriptContext *scx = GetContextInternal();
AutoPushJSContext cx(scx ? scx->GetNativeContext() : nullptr);