diff --git a/content/media/webaudio/AudioContext.cpp b/content/media/webaudio/AudioContext.cpp index 44abf6d05de..ea26191a336 100644 --- a/content/media/webaudio/AudioContext.cpp +++ b/content/media/webaudio/AudioContext.cpp @@ -401,6 +401,7 @@ void AudioContext::UnregisterPannerNode(PannerNode* aNode) { mPannerNodes.RemoveEntry(aNode); + mListener->UnregisterPannerNode(aNode); } void diff --git a/content/media/webaudio/AudioListener.cpp b/content/media/webaudio/AudioListener.cpp index e20bbdc13c2..8c3c9163852 100644 --- a/content/media/webaudio/AudioListener.cpp +++ b/content/media/webaudio/AudioListener.cpp @@ -52,6 +52,11 @@ AudioListener::RegisterPannerNode(PannerNode* aPannerNode) UpdatePannersVelocity(); } +void AudioListener::UnregisterPannerNode(PannerNode* aPannerNode) +{ + mPanners.RemoveElement(aPannerNode); +} + void AudioListener::SendDoubleParameterToStream(uint32_t aIndex, double aValue) { diff --git a/content/media/webaudio/AudioListener.h b/content/media/webaudio/AudioListener.h index e2e83d852e8..bb38108cca5 100644 --- a/content/media/webaudio/AudioListener.h +++ b/content/media/webaudio/AudioListener.h @@ -127,6 +127,7 @@ public: } void RegisterPannerNode(PannerNode* aPannerNode); + void UnregisterPannerNode(PannerNode* aPannerNode); private: void SendDoubleParameterToStream(uint32_t aIndex, double aValue); diff --git a/content/media/webaudio/PannerNode.cpp b/content/media/webaudio/PannerNode.cpp index 89036112024..9ad2a1422e7 100644 --- a/content/media/webaudio/PannerNode.cpp +++ b/content/media/webaudio/PannerNode.cpp @@ -212,6 +212,14 @@ PannerNode::WrapObject(JSContext* aCx, JS::Handle aScope) return PannerNodeBinding::Wrap(aCx, aScope, this); } +void PannerNode::DestroyMediaStream() +{ + if (Context()) { + Context()->UnregisterPannerNode(this); + } + AudioNode::DestroyMediaStream(); +} + // Those three functions are described in the spec. float PannerNodeEngine::LinearGainFunction(float aDistance) diff --git a/content/media/webaudio/PannerNode.h b/content/media/webaudio/PannerNode.h index d0b0839a319..065d1d2d1d9 100644 --- a/content/media/webaudio/PannerNode.h +++ b/content/media/webaudio/PannerNode.h @@ -31,9 +31,12 @@ public: explicit PannerNode(AudioContext* aContext); virtual ~PannerNode(); + virtual JSObject* WrapObject(JSContext* aCx, JS::Handle aScope) MOZ_OVERRIDE; + virtual void DestroyMediaStream() MOZ_OVERRIDE; + NS_DECL_ISUPPORTS_INHERITED NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(PannerNode, AudioNode)