Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1131)

Unified Diff: Source/modules/webaudio/AudioContext.cpp

Issue 776203002: Web Audio: Oilpan: Correctly trace m_referencedNodes elements within a lock. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: else trace Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/webaudio/AudioContext.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/webaudio/AudioContext.cpp
diff --git a/Source/modules/webaudio/AudioContext.cpp b/Source/modules/webaudio/AudioContext.cpp
index fde9cf2c51d36e4aea01626108c36d93ef42d011..04079801a32b1177350d21c4e373f2f0953b48f3 100644
--- a/Source/modules/webaudio/AudioContext.cpp
+++ b/Source/modules/webaudio/AudioContext.cpp
@@ -106,11 +106,12 @@ AudioContext::AudioContext(Document* document)
, m_isResolvingResumePromises(false)
, m_automaticPullNodesNeedUpdating(false)
, m_connectionCount(0)
+ , m_didInitializeContextGraphMutex(false)
, m_audioThread(0)
, m_isOfflineContext(false)
, m_contextState(Suspended)
{
- m_referencedNodes = new HeapVector<Member<AudioNode>>();
+ m_didInitializeContextGraphMutex = true;
m_destinationNode = DefaultAudioDestinationNode::create(this);
initialize();
@@ -129,11 +130,12 @@ AudioContext::AudioContext(Document* document, unsigned numberOfChannels, size_t
, m_isResolvingResumePromises(false)
, m_automaticPullNodesNeedUpdating(false)
, m_connectionCount(0)
+ , m_didInitializeContextGraphMutex(false)
, m_audioThread(0)
, m_isOfflineContext(true)
, m_contextState(Suspended)
{
- m_referencedNodes = new HeapVector<Member<AudioNode>>();
+ m_didInitializeContextGraphMutex = true;
// Create a new destination for offline rendering.
m_renderTarget = AudioBuffer::create(numberOfChannels, numberOfFrames, sampleRate);
if (m_renderTarget.get())
@@ -149,6 +151,7 @@ AudioContext::~AudioContext()
#endif
// AudioNodes keep a reference to their context, so there should be no way to be in the destructor if there are still AudioNodes around.
ASSERT(!m_isInitialized);
+ ASSERT(!m_referencedNodes.size());
ASSERT(!m_finishedNodes.size());
ASSERT(!m_automaticPullNodes.size());
if (m_automaticPullNodesNeedUpdating)
@@ -678,7 +681,7 @@ void AudioContext::refNode(AudioNode* node)
ASSERT(isMainThread());
AutoLocker locker(this);
- m_referencedNodes->append(node);
+ m_referencedNodes.append(node);
node->makeConnection();
}
@@ -686,10 +689,10 @@ void AudioContext::derefNode(AudioNode* node)
{
ASSERT(isGraphOwner());
- for (unsigned i = 0; i < m_referencedNodes->size(); ++i) {
- if (node == m_referencedNodes->at(i).get()) {
+ for (unsigned i = 0; i < m_referencedNodes.size(); ++i) {
+ if (node == m_referencedNodes.at(i).get()) {
node->breakConnection();
- m_referencedNodes->remove(i);
+ m_referencedNodes.remove(i);
break;
}
}
@@ -698,10 +701,10 @@ void AudioContext::derefNode(AudioNode* node)
void AudioContext::derefUnfinishedSourceNodes()
{
ASSERT(isMainThread());
- for (unsigned i = 0; i < m_referencedNodes->size(); ++i)
- m_referencedNodes->at(i)->breakConnection();
+ for (unsigned i = 0; i < m_referencedNodes.size(); ++i)
+ m_referencedNodes.at(i)->breakConnection();
- m_referencedNodes->clear();
+ m_referencedNodes.clear();
}
void AudioContext::lock()
@@ -1078,12 +1081,12 @@ void AudioContext::trace(Visitor* visitor)
visitor->trace(m_destinationNode);
visitor->trace(m_listener);
// trace() can be called in AudioContext constructor, and
- // m_contextGraphMutex might be unavailable. We can use m_contextGraphMutex
- // if m_referencedNodes is not null because m_referencedNodes is initialized
- // after m_contextGraphMutex.
- if (m_referencedNodes) {
+ // m_contextGraphMutex might be unavailable.
+ if (m_didInitializeContextGraphMutex) {
AutoLocker lock(this);
visitor->trace(m_referencedNodes);
+ } else {
+ visitor->trace(m_referencedNodes);
}
visitor->trace(m_liveNodes);
visitor->trace(m_liveAudioSummingJunctions);
« no previous file with comments | « Source/modules/webaudio/AudioContext.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698