Permalink
Browse files

Fix infinite loop when traversing feedback loops

  • Loading branch information...
1 parent 2d247c2 commit d87cd24cf3ffc31bce02d299cd252bd35dc265c1 @oampo committed Feb 13, 2012
Showing with 4 additions and 6 deletions.
  1. +2 −2 src/core/AudioletDevice.js
  2. +2 −4 src/core/AudioletNode.js
@@ -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
@@ -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;
};
@@ -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;
@@ -167,6 +164,7 @@ AudioletNode.prototype.createInputSamples = function() {
}
}
}
+
if (input.samples.length > numberOfInputChannels) {
input.samples = input.samples.slice(0, numberOfInputChannels);
}

0 comments on commit d87cd24

Please sign in to comment.