mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 1183044 - Properly mute AudioContext when there's an attempt to mute it before it has a destination. r=ehsan
This commit is contained in:
parent
c02e9dd583
commit
e004f2a723
@ -3475,17 +3475,16 @@ nsPIDOMWindow::SetFrameElementInternal(Element* aFrameElement)
|
||||
mOuterWindow->SetFrameElementInternal(aFrameElement);
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
nsPIDOMWindow::AddAudioContext(AudioContext* aAudioContext)
|
||||
{
|
||||
MOZ_ASSERT(IsInnerWindow());
|
||||
|
||||
mAudioContexts.AppendElement(aAudioContext);
|
||||
|
||||
// Return true if the context should be muted and false if not.
|
||||
nsIDocShell* docShell = GetDocShell();
|
||||
if (docShell && !docShell->GetAllowMedia() && !aAudioContext->IsOffline()) {
|
||||
aAudioContext->Mute();
|
||||
}
|
||||
return docShell && !docShell->GetAllowMedia() && !aAudioContext->IsOffline();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -718,7 +718,7 @@ public:
|
||||
const nsAString& aPopupWindowFeatures) = 0;
|
||||
|
||||
// Inner windows only.
|
||||
void AddAudioContext(mozilla::dom::AudioContext* aAudioContext);
|
||||
bool AddAudioContext(mozilla::dom::AudioContext* aAudioContext);
|
||||
void RemoveAudioContext(mozilla::dom::AudioContext* aAudioContext);
|
||||
void MuteAudioContexts();
|
||||
void UnmuteAudioContexts();
|
||||
|
@ -101,12 +101,17 @@ AudioContext::AudioContext(nsPIDOMWindow* aWindow,
|
||||
, mIsShutDown(false)
|
||||
, mCloseCalled(false)
|
||||
{
|
||||
aWindow->AddAudioContext(this);
|
||||
bool mute = aWindow->AddAudioContext(this);
|
||||
|
||||
// Note: AudioDestinationNode needs an AudioContext that must already be
|
||||
// bound to the window.
|
||||
mDestination = new AudioDestinationNode(this, aIsOffline, aChannel,
|
||||
aNumberOfChannels, aLength, aSampleRate);
|
||||
|
||||
// The context can't be muted until it has a destination.
|
||||
if (mute) {
|
||||
Mute();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user