| Index: Source/modules/webaudio/AudioNode.cpp
|
| diff --git a/Source/modules/webaudio/AudioNode.cpp b/Source/modules/webaudio/AudioNode.cpp
|
| index 69d6aba4cdba6883452cae38d42eb9b4335ef244..9f1c622bca235f2aaf2938a72c7d5e49ed7954a5 100644
|
| --- a/Source/modules/webaudio/AudioNode.cpp
|
| +++ b/Source/modules/webaudio/AudioNode.cpp
|
| @@ -55,7 +55,6 @@
|
| , m_lastNonSilentTime(-1)
|
| , m_normalRefCount(1) // start out with normal refCount == 1 (like WTF::RefCounted class)
|
| , m_connectionRefCount(0)
|
| - , m_wasDisconnected(false)
|
| , m_isMarkedForDeletion(false)
|
| , m_isDisabled(false)
|
| , m_channelCount(2)
|
| @@ -470,28 +469,34 @@
|
| }
|
| }
|
|
|
| -void AudioNode::ref()
|
| +void AudioNode::ref(RefType refType)
|
| {
|
| #if ENABLE(OILPAN)
|
| ASSERT(m_keepAlive);
|
| #endif
|
| - atomicIncrement(&m_normalRefCount);
|
| + switch (refType) {
|
| + case RefTypeNormal:
|
| + atomicIncrement(&m_normalRefCount);
|
| + break;
|
| + case RefTypeConnection:
|
| + atomicIncrement(&m_connectionRefCount);
|
| + break;
|
| + default:
|
| + ASSERT_NOT_REACHED();
|
| + }
|
|
|
| #if DEBUG_AUDIONODE_REFERENCES
|
| - fprintf(stderr, "%p: %d: AudioNode::ref() %d %d\n", this, nodeType(), m_normalRefCount, m_connectionRefCount);
|
| -#endif
|
| -}
|
| -
|
| -void AudioNode::makeConnection()
|
| -{
|
| - atomicIncrement(&m_connectionRefCount);
|
| - // See the disabling code in finishDeref() below. This handles the case
|
| - // where a node is being re-connected after being used at least once and
|
| - // disconnected. In this case, we need to re-enable.
|
| - enableOutputsIfNecessary();
|
| -}
|
| -
|
| -void AudioNode::deref()
|
| + fprintf(stderr, "%p: %d: AudioNode::ref(%d) %d %d\n", this, nodeType(), refType, m_normalRefCount, m_connectionRefCount);
|
| +#endif
|
| +
|
| + // See the disabling code in finishDeref() below. This handles the case where a node
|
| + // is being re-connected after being used at least once and disconnected.
|
| + // In this case, we need to re-enable.
|
| + if (refType == RefTypeConnection)
|
| + enableOutputsIfNecessary();
|
| +}
|
| +
|
| +void AudioNode::deref(RefType refType)
|
| {
|
| // The actually work for deref happens completely within the audio context's graph lock.
|
| // In the case of the audio thread, we must use a tryLock to avoid glitches.
|
| @@ -508,13 +513,14 @@
|
|
|
| if (hasLock) {
|
| // This is where the real deref work happens.
|
| - finishDeref();
|
| + finishDeref(refType);
|
|
|
| if (mustReleaseLock)
|
| context()->unlock();
|
| } else {
|
| // We were unable to get the lock, so put this in a list to finish up later.
|
| ASSERT(context()->isAudioThread());
|
| + ASSERT(refType == RefTypeConnection);
|
| context()->addDeferredFinishDeref(this);
|
| }
|
|
|
| @@ -525,39 +531,40 @@
|
| context()->deleteMarkedNodes();
|
| }
|
|
|
| -void AudioNode::breakConnection()
|
| -{
|
| - ASSERT(m_normalRefCount > 0);
|
| - atomicDecrement(&m_connectionRefCount);
|
| - m_wasDisconnected = true;
|
| -}
|
| -
|
| -void AudioNode::finishDeref()
|
| +void AudioNode::finishDeref(RefType refType)
|
| {
|
| ASSERT(context()->isGraphOwner());
|
|
|
| - ASSERT(m_normalRefCount > 0);
|
| - atomicDecrement(&m_normalRefCount);
|
| + switch (refType) {
|
| + case RefTypeNormal:
|
| + ASSERT(m_normalRefCount > 0);
|
| + atomicDecrement(&m_normalRefCount);
|
| + break;
|
| + case RefTypeConnection:
|
| + ASSERT(m_connectionRefCount > 0);
|
| + atomicDecrement(&m_connectionRefCount);
|
| + break;
|
| + default:
|
| + ASSERT_NOT_REACHED();
|
| + }
|
|
|
| #if DEBUG_AUDIONODE_REFERENCES
|
| - fprintf(stderr, "%p: %d: AudioNode::deref() %d %d\n", this, nodeType(), m_normalRefCount, m_connectionRefCount);
|
| -#endif
|
| -
|
| - if (m_wasDisconnected) {
|
| - if (m_connectionRefCount == 0 && m_normalRefCount > 0)
|
| + fprintf(stderr, "%p: %d: AudioNode::deref(%d) %d %d\n", this, nodeType(), refType, m_normalRefCount, m_connectionRefCount);
|
| +#endif
|
| +
|
| + if (!m_connectionRefCount) {
|
| + if (!m_normalRefCount) {
|
| + if (!m_isMarkedForDeletion) {
|
| + // All references are gone - we need to go away.
|
| + for (unsigned i = 0; i < m_outputs.size(); ++i)
|
| + output(i)->disconnectAll(); // This will deref() nodes we're connected to.
|
| +
|
| + // Mark for deletion at end of each render quantum or when context shuts down.
|
| + context()->markForDeletion(this);
|
| + m_isMarkedForDeletion = true;
|
| + }
|
| + } else if (refType == RefTypeConnection)
|
| disableOutputsIfNecessary();
|
| - m_wasDisconnected = false;
|
| - }
|
| -
|
| - if (!m_normalRefCount && !m_isMarkedForDeletion) {
|
| - // All references are gone - we need to go away.
|
| - for (unsigned i = 0; i < m_outputs.size(); ++i)
|
| - output(i)->disconnectAll(); // This will deref() nodes we're connected to.
|
| -
|
| - // Mark for deletion at end of each render quantum or when context shuts
|
| - // down.
|
| - context()->markForDeletion(this);
|
| - m_isMarkedForDeletion = true;
|
| }
|
| }
|
|
|
|
|