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)
, m_normalRefCount(1) // start out with normal refCount == 1 (like WTF::RefCounted class)
#endif
, m_connectionRefCount(0)
#if !ENABLE(OILPAN)
, m_isMarkedForDeletion(false)
#endif
, m_isDisabled(false)
#if ENABLE(ASSERT)
, m_didCallDispose(false)
#endif
, m_isDisposeCalled(false)
, m_channelCount(2)
, m_channelCountMode(Max)
, m_channelInterpretation(AudioBus::Speakers)
......@@ -82,7 +77,7 @@ AudioNode::AudioNode(AudioContext* context, float sampleRate)
AudioNode::~AudioNode()
{
ASSERT(m_didCallDispose);
ASSERT(m_isDisposeCalled);
--s_instanceCount;
#if DEBUG_AUDIONODE_REFERENCES
--s_nodeCount[nodeType()];
......@@ -109,13 +104,17 @@ void AudioNode::dispose()
ASSERT(isMainThread());
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);
for (unsigned i = 0; i < m_outputs.size(); ++i)
output(i)->disconnectAll();
context()->unmarkDirtyNode(*this);
#if ENABLE(ASSERT)
m_didCallDispose = true;
#endif
}
String AudioNode::nodeTypeName() const
......@@ -605,11 +604,10 @@ void AudioNode::finishDeref()
fprintf(stderr, "%p: %d: AudioNode::deref() %d %d\n", this, nodeType(), m_normalRefCount, m_connectionRefCount);
#endif
if (!m_normalRefCount && !m_isMarkedForDeletion) {
if (!m_normalRefCount) {
// Mark for deletion at end of each render quantum or when context shuts
// down.
context()->markForDeletion(this);
m_isMarkedForDeletion = true;
}
}
#endif
......
......@@ -158,9 +158,7 @@ public:
static void printNodeCounts();
#endif
#if !ENABLE(OILPAN)
bool isMarkedForDeletion() const { return m_isMarkedForDeletion; }
#endif
bool isDisposeCalled() const { return m_isDisposeCalled; }
// 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;
......@@ -227,14 +225,8 @@ private:
#endif
volatile int m_connectionRefCount;
#if !ENABLE(OILPAN)
bool m_isMarkedForDeletion;
#endif
bool m_isDisabled;
#if ENABLE(ASSERT)
bool m_didCallDispose;
#endif
bool m_isDisposeCalled;
#if DEBUG_AUDIONODE_REFERENCES
static bool s_isNodeCountInitialized;
......
......@@ -45,9 +45,7 @@ public:
// AudioSummingJunction
virtual void trace(Visitor*) OVERRIDE;
#if !ENABLE(OILPAN)
virtual bool canUpdateState() OVERRIDE { return !node().isMarkedForDeletion(); }
#endif
virtual bool canUpdateState() OVERRIDE { return !node().isDisposeCalled(); }
virtual void didUpdate() OVERRIDE;
// Can be called from any thread.
......
......@@ -59,9 +59,7 @@ public:
}
// AudioSummingJunction
#if !ENABLE(OILPAN)
virtual bool canUpdateState() OVERRIDE { return true; }
#endif
virtual void didUpdate() OVERRIDE { }
// Intrinsic value.
......
......@@ -60,11 +60,7 @@ void AudioSummingJunction::trace(Visitor* visitor)
void AudioSummingJunction::changedOutputs()
{
ASSERT(context()->isGraphOwner());
#if ENABLE(OILPAN)
if (!m_renderingStateNeedUpdating) {
#else
if (!m_renderingStateNeedUpdating && canUpdateState()) {
#endif
context()->markSummingJunctionDirty(this);
m_renderingStateNeedUpdating = true;
}
......@@ -73,11 +69,7 @@ void AudioSummingJunction::changedOutputs()
void AudioSummingJunction::updateRenderingState()
{
ASSERT(context()->isAudioThread() && context()->isGraphOwner());
#if ENABLE(OILPAN)
if (m_renderingStateNeedUpdating) {
#else
if (m_renderingStateNeedUpdating && canUpdateState()) {
#endif
// Copy from m_outputs to m_renderingOutputs.
m_renderingOutputs.resize(m_outputs.size());
unsigned j = 0;
......
......@@ -57,9 +57,7 @@ public:
AudioNodeOutput* renderingOutput(unsigned i) { return m_renderingOutputs[i]; }
bool isConnected() const { return numberOfRenderingConnections() > 0; }
#if !ENABLE(OILPAN)
virtual bool canUpdateState() = 0;
#endif
virtual void didUpdate() = 0;
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