Skip to content

Commit

Permalink
Fix infinite loop when traversing feedback loops
Browse files Browse the repository at this point in the history
  • Loading branch information
oampo committed Feb 13, 2012
1 parent 2d247c2 commit d87cd24
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/core/AudioletDevice.js
Expand Up @@ -50,8 +50,8 @@ AudioletDevice.prototype.tick = function(buffer, numberOfChannels) {
this.needTraverse = false;
}

// Tick up to, but not including this node
for (var j = 0; j < this.nodes.length - 1; j++) {
// Tick in reverse order up to, but not including this node
for (var j = this.nodes.length - 1; j > 0; j--) {
this.nodes[j].tick();
}
// Cut down tick to just sum the input samples
Expand Down
6 changes: 2 additions & 4 deletions src/core/AudioletNode.js
Expand Up @@ -109,9 +109,9 @@ AudioletNode.prototype.tick = function() {
};

AudioletNode.prototype.traverse = function(nodes) {
nodes = this.traverseParents(nodes);
if (nodes.indexOf(this) == -1) {
nodes.push(this);
nodes = this.traverseParents(nodes);
}
return nodes;
};
Expand Down Expand Up @@ -148,9 +148,6 @@ AudioletNode.prototype.createInputSamples = function() {
var numberOfInputs = this.inputs.length;
for (var i = 0; i < numberOfInputs; i++) {
var input = this.inputs[i];
if (!input.connectedFrom.length) {
continue;
}

var numberOfInputChannels = 0;

Expand All @@ -167,6 +164,7 @@ AudioletNode.prototype.createInputSamples = function() {
}
}
}

if (input.samples.length > numberOfInputChannels) {
input.samples = input.samples.slice(0, numberOfInputChannels);
}
Expand Down

0 comments on commit d87cd24

Please sign in to comment.