Commit f5c034d5 authored by haraken@chromium.org's avatar haraken@chromium.org

Merge m_didCallDispose and m_isMarkedForDeletion flags into one flag

Currently we have the following two flags:

- m_didCallDispose is used to know whether AudioContext::dispose() is called or not.
- m_isMarkedForDeletion is used to guarantee the following facts:

--- AudioNode should not be re-registered to AudioNode::m_outputs after AudioNode::dispose is called.
--- AudioNode should not get marked as dirty after AudoNode::dispose is called.

We don't need the two flags; just one flag that is set in AudioContext::dispose() is enough.

This CL removes m_didCallDispose and m_isMarkedForDeletion and introduces m_isDisposeCalled. This CL doesn't change any behavior.

BUG=340522

Review URL: https://codereview.chromium.org/460303003

git-svn-id: svn://svn.chromium.org/blink/trunk@180330 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent bb0b6daf
...@@ -56,13 +56,8 @@ AudioNode::AudioNode(AudioContext* context, float sampleRate) ...@@ -56,13 +56,8 @@ AudioNode::AudioNode(AudioContext* context, float sampleRate)
, m_normalRefCount(1) // start out with normal refCount == 1 (like WTF::RefCounted class) , m_normalRefCount(1) // start out with normal refCount == 1 (like WTF::RefCounted class)
#endif #endif
, m_connectionRefCount(0) , m_connectionRefCount(0)
#if !ENABLE(OILPAN)
, m_isMarkedForDeletion(false)
#endif
, m_isDisabled(false) , m_isDisabled(false)
#if ENABLE(ASSERT) , m_isDisposeCalled(false)
, m_didCallDispose(false)
#endif
, m_channelCount(2) , m_channelCount(2)
, m_channelCountMode(Max) , m_channelCountMode(Max)
, m_channelInterpretation(AudioBus::Speakers) , m_channelInterpretation(AudioBus::Speakers)
...@@ -82,7 +77,7 @@ AudioNode::AudioNode(AudioContext* context, float sampleRate) ...@@ -82,7 +77,7 @@ AudioNode::AudioNode(AudioContext* context, float sampleRate)
AudioNode::~AudioNode() AudioNode::~AudioNode()
{ {
ASSERT(m_didCallDispose); ASSERT(m_isDisposeCalled);
--s_instanceCount; --s_instanceCount;
#if DEBUG_AUDIONODE_REFERENCES #if DEBUG_AUDIONODE_REFERENCES
--s_nodeCount[nodeType()]; --s_nodeCount[nodeType()];
...@@ -109,13 +104,17 @@ void AudioNode::dispose() ...@@ -109,13 +104,17 @@ void AudioNode::dispose()
ASSERT(isMainThread()); ASSERT(isMainThread());
ASSERT(context()->isGraphOwner()); ASSERT(context()->isGraphOwner());
// This flag prevents:
// - the following disconnectAll() from re-registering this AudioNode into
// the m_outputs.
// - this AudioNode from getting marked as dirty after calling
// unmarkDirtyNode.
m_isDisposeCalled = true;
context()->removeAutomaticPullNode(this); context()->removeAutomaticPullNode(this);
for (unsigned i = 0; i < m_outputs.size(); ++i) for (unsigned i = 0; i < m_outputs.size(); ++i)
output(i)->disconnectAll(); output(i)->disconnectAll();
context()->unmarkDirtyNode(*this); context()->unmarkDirtyNode(*this);
#if ENABLE(ASSERT)
m_didCallDispose = true;
#endif
} }
String AudioNode::nodeTypeName() const String AudioNode::nodeTypeName() const
...@@ -605,11 +604,10 @@ void AudioNode::finishDeref() ...@@ -605,11 +604,10 @@ void AudioNode::finishDeref()
fprintf(stderr, "%p: %d: AudioNode::deref() %d %d\n", this, nodeType(), m_normalRefCount, m_connectionRefCount); fprintf(stderr, "%p: %d: AudioNode::deref() %d %d\n", this, nodeType(), m_normalRefCount, m_connectionRefCount);
#endif #endif
if (!m_normalRefCount && !m_isMarkedForDeletion) { if (!m_normalRefCount) {
// Mark for deletion at end of each render quantum or when context shuts // Mark for deletion at end of each render quantum or when context shuts
// down. // down.
context()->markForDeletion(this); context()->markForDeletion(this);
m_isMarkedForDeletion = true;
} }
} }
#endif #endif
......
...@@ -158,9 +158,7 @@ public: ...@@ -158,9 +158,7 @@ public:
static void printNodeCounts(); static void printNodeCounts();
#endif #endif
#if !ENABLE(OILPAN) bool isDisposeCalled() const { return m_isDisposeCalled; }
bool isMarkedForDeletion() const { return m_isMarkedForDeletion; }
#endif
// tailTime() is the length of time (not counting latency time) where non-zero output may occur after continuous silent input. // tailTime() is the length of time (not counting latency time) where non-zero output may occur after continuous silent input.
virtual double tailTime() const = 0; virtual double tailTime() const = 0;
...@@ -227,14 +225,8 @@ private: ...@@ -227,14 +225,8 @@ private:
#endif #endif
volatile int m_connectionRefCount; volatile int m_connectionRefCount;
#if !ENABLE(OILPAN)
bool m_isMarkedForDeletion;
#endif
bool m_isDisabled; bool m_isDisabled;
bool m_isDisposeCalled;
#if ENABLE(ASSERT)
bool m_didCallDispose;
#endif
#if DEBUG_AUDIONODE_REFERENCES #if DEBUG_AUDIONODE_REFERENCES
static bool s_isNodeCountInitialized; static bool s_isNodeCountInitialized;
......
...@@ -45,9 +45,7 @@ public: ...@@ -45,9 +45,7 @@ public:
// AudioSummingJunction // AudioSummingJunction
virtual void trace(Visitor*) OVERRIDE; virtual void trace(Visitor*) OVERRIDE;
#if !ENABLE(OILPAN) virtual bool canUpdateState() OVERRIDE { return !node().isDisposeCalled(); }
virtual bool canUpdateState() OVERRIDE { return !node().isMarkedForDeletion(); }
#endif
virtual void didUpdate() OVERRIDE; virtual void didUpdate() OVERRIDE;
// Can be called from any thread. // Can be called from any thread.
......
...@@ -59,9 +59,7 @@ public: ...@@ -59,9 +59,7 @@ public:
} }
// AudioSummingJunction // AudioSummingJunction
#if !ENABLE(OILPAN)
virtual bool canUpdateState() OVERRIDE { return true; } virtual bool canUpdateState() OVERRIDE { return true; }
#endif
virtual void didUpdate() OVERRIDE { } virtual void didUpdate() OVERRIDE { }
// Intrinsic value. // Intrinsic value.
......
...@@ -60,11 +60,7 @@ void AudioSummingJunction::trace(Visitor* visitor) ...@@ -60,11 +60,7 @@ void AudioSummingJunction::trace(Visitor* visitor)
void AudioSummingJunction::changedOutputs() void AudioSummingJunction::changedOutputs()
{ {
ASSERT(context()->isGraphOwner()); ASSERT(context()->isGraphOwner());
#if ENABLE(OILPAN)
if (!m_renderingStateNeedUpdating) {
#else
if (!m_renderingStateNeedUpdating && canUpdateState()) { if (!m_renderingStateNeedUpdating && canUpdateState()) {
#endif
context()->markSummingJunctionDirty(this); context()->markSummingJunctionDirty(this);
m_renderingStateNeedUpdating = true; m_renderingStateNeedUpdating = true;
} }
...@@ -73,11 +69,7 @@ void AudioSummingJunction::changedOutputs() ...@@ -73,11 +69,7 @@ void AudioSummingJunction::changedOutputs()
void AudioSummingJunction::updateRenderingState() void AudioSummingJunction::updateRenderingState()
{ {
ASSERT(context()->isAudioThread() && context()->isGraphOwner()); ASSERT(context()->isAudioThread() && context()->isGraphOwner());
#if ENABLE(OILPAN)
if (m_renderingStateNeedUpdating) {
#else
if (m_renderingStateNeedUpdating && canUpdateState()) { if (m_renderingStateNeedUpdating && canUpdateState()) {
#endif
// Copy from m_outputs to m_renderingOutputs. // Copy from m_outputs to m_renderingOutputs.
m_renderingOutputs.resize(m_outputs.size()); m_renderingOutputs.resize(m_outputs.size());
unsigned j = 0; unsigned j = 0;
......
...@@ -57,9 +57,7 @@ public: ...@@ -57,9 +57,7 @@ public:
AudioNodeOutput* renderingOutput(unsigned i) { return m_renderingOutputs[i]; } AudioNodeOutput* renderingOutput(unsigned i) { return m_renderingOutputs[i]; }
bool isConnected() const { return numberOfRenderingConnections() > 0; } bool isConnected() const { return numberOfRenderingConnections() > 0; }
#if !ENABLE(OILPAN)
virtual bool canUpdateState() = 0; virtual bool canUpdateState() = 0;
#endif
virtual void didUpdate() = 0; virtual void didUpdate() = 0;
protected: protected:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment