b=916680 don't keep active AudioNodes alive from an AudioContext that has shut down r=ehsan
--- a/content/media/webaudio/AudioContext.cpp
+++ b/content/media/webaudio/AudioContext.cpp
@@ -55,16 +55,17 @@ AudioContext::AudioContext(nsPIDOMWindow
float aSampleRate)
: mSampleRate(aIsOffline ? aSampleRate : IdealAudioRate())
, mDestination(new AudioDestinationNode(MOZ_THIS_IN_INITIALIZER_LIST(),
aIsOffline, aNumberOfChannels,
aLength, aSampleRate))
, mNumberOfChannels(aNumberOfChannels)
, mIsOffline(aIsOffline)
, mIsStarted(!aIsOffline)
+ , mIsShutDown(false)
{
// Actually play audio
mDestination->Stream()->AddAudioOutput(&gWebAudioOutputKey);
nsDOMEventTargetHelper::BindToOwner(aWindow);
aWindow->AddAudioContext(this);
SetIsDOMBinding();
}
@@ -438,17 +439,19 @@ void
AudioContext::RemoveFromDecodeQueue(WebAudioDecodeJob* aDecodeJob)
{
mDecodeJobs.RemoveElement(aDecodeJob);
}
void
AudioContext::RegisterActiveNode(AudioNode* aNode)
{
- mActiveNodes.PutEntry(aNode);
+ if (!mIsShutDown) {
+ mActiveNodes.PutEntry(aNode);
+ }
}
void
AudioContext::UnregisterActiveNode(AudioNode* aNode)
{
mActiveNodes.RemoveEntry(aNode);
}
@@ -531,16 +534,18 @@ static void
GetHashtableElements(nsTHashtable<nsPtrHashKey<T> >& aHashtable, nsTArray<T*>& aArray)
{
aHashtable.EnumerateEntries(&GetHashtableEntry<T>, &aArray);
}
void
AudioContext::Shutdown()
{
+ mIsShutDown = true;
+
Suspend();
// Release references to active nodes.
// Active AudioNodes don't unregister in destructors, at which point the
// Node is already unregistered.
mActiveNodes.Clear();
// Stop all audio buffer source nodes, to make sure that they release
--- a/content/media/webaudio/AudioContext.h
+++ b/content/media/webaudio/AudioContext.h
@@ -265,15 +265,16 @@ private:
nsTHashtable<nsPtrHashKey<OscillatorNode> > mOscillatorNodes;
// Hashset containing all ScriptProcessorNodes in order to stop them.
// These are all weak pointers.
nsTHashtable<nsPtrHashKey<ScriptProcessorNode> > mScriptProcessorNodes;
// Number of channels passed in the OfflineAudioContext ctor.
uint32_t mNumberOfChannels;
bool mIsOffline;
bool mIsStarted;
+ bool mIsShutDown;
};
}
}
#endif