Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 9773a06

Browse files
author
Ehsan Akhgari
committed
Bug 865004 - Disconnect the AudioNode from the graph before deleting it; r=bzbarsky
1 parent 834afc7 commit 9773a06

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

content/media/webaudio/AudioNode.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,20 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(AudioNode, nsDOMEventTargetHel
2424
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
2525

2626
NS_IMPL_ADDREF_INHERITED(AudioNode, nsDOMEventTargetHelper)
27-
NS_IMPL_RELEASE_INHERITED(AudioNode, nsDOMEventTargetHelper)
27+
28+
NS_IMETHODIMP_(nsrefcnt)
29+
AudioNode::Release()
30+
{
31+
if (mRefCnt.get() == 1) {
32+
// We are about to be deleted, disconnect the object from the graph before
33+
// the derived type is destroyed.
34+
DisconnectFromGraph();
35+
}
36+
nsrefcnt r = nsDOMEventTargetHelper::Release();
37+
NS_LOG_RELEASE(this, r, "AudioNode");
38+
return r;
39+
}
40+
2841
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(AudioNode)
2942
NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
3043

@@ -38,7 +51,6 @@ AudioNode::AudioNode(AudioContext* aContext)
3851

3952
AudioNode::~AudioNode()
4053
{
41-
DisconnectFromGraph();
4254
MOZ_ASSERT(mInputNodes.IsEmpty());
4355
MOZ_ASSERT(mOutputNodes.IsEmpty());
4456
}

content/media/webaudio/AudioNode.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,12 @@ class SelfReference {
7373
class AudioNode : public nsDOMEventTargetHelper,
7474
public EnableWebAudioCheck
7575
{
76+
protected:
77+
// You can only use refcounting to delete this object
78+
virtual ~AudioNode();
79+
7680
public:
7781
explicit AudioNode(AudioContext* aContext);
78-
virtual ~AudioNode();
7982

8083
// This should be idempotent (safe to call multiple times).
8184
virtual void DestroyMediaStream();
@@ -87,7 +90,7 @@ class AudioNode : public nsDOMEventTargetHelper,
8790
return false;
8891
}
8992

90-
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
93+
NS_DECL_ISUPPORTS_INHERITED
9194
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(AudioNode,
9295
nsDOMEventTargetHelper)
9396

0 commit comments

Comments
 (0)