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

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

Issue 130003002: Handle loops in audio graph better for PannerNodes (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 months 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/PannerNode.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/PannerNode.cpp
diff --git a/Source/modules/webaudio/PannerNode.cpp b/Source/modules/webaudio/PannerNode.cpp
index fcebe1273dca1da2529be7de71891fdccf383330..e15e7b49376efb5385fcffae88846f5079b202a7 100644
--- a/Source/modules/webaudio/PannerNode.cpp
+++ b/Source/modules/webaudio/PannerNode.cpp
@@ -85,8 +85,12 @@ void PannerNode::pullInputs(size_t framesToProcess)
if (m_connectionCount != context()->connectionCount()) {
m_connectionCount = context()->connectionCount();
- // Recursively go through all nodes connected to us.
- notifyAudioSourcesConnectedToNode(this);
+ // A map for keeping track if we have visited a node or not. This prevents feedback loops
+ // from recursing infinitely. See crbug.com/331446.
+ HashMap<AudioNode*, bool> visitedNodes;
+
+ // Recursively go through all nodes connected to us
+ notifyAudioSourcesConnectedToNode(this, visitedNodes);
}
AudioNode::pullInputs(framesToProcess);
@@ -386,7 +390,7 @@ float PannerNode::distanceConeGain()
return float(distanceGain * coneGain);
}
-void PannerNode::notifyAudioSourcesConnectedToNode(AudioNode* node)
+void PannerNode::notifyAudioSourcesConnectedToNode(AudioNode* node, HashMap<AudioNode*, bool>& visitedNodes)
{
ASSERT(node);
if (!node)
@@ -405,7 +409,14 @@ void PannerNode::notifyAudioSourcesConnectedToNode(AudioNode* node)
for (unsigned j = 0; j < input->numberOfRenderingConnections(); ++j) {
AudioNodeOutput* connectedOutput = input->renderingOutput(j);
AudioNode* connectedNode = connectedOutput->node();
- notifyAudioSourcesConnectedToNode(connectedNode); // recurse
+ HashMap<AudioNode*, bool>::iterator iterator = visitedNodes.find(connectedNode);
+
+ // If we've seen this node already, we don't need to process it again. Otherwise,
+ // mark it as visited and recurse through the node looking for sources.
+ if (iterator == visitedNodes.end()) {
+ visitedNodes.set(connectedNode, true);
+ notifyAudioSourcesConnectedToNode(connectedNode, visitedNodes); // recurse
+ }
}
}
}
« no previous file with comments | « Source/modules/webaudio/PannerNode.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698