Skip to content
This repository
Browse code

Fix infinite loop when traversing feedback loops

  • Loading branch information...
commit d87cd24cf3ffc31bce02d299cd252bd35dc265c1 1 parent 2d247c2
Joe Turner authored February 13, 2012
4  src/core/AudioletDevice.js
@@ -50,8 +50,8 @@ AudioletDevice.prototype.tick = function(buffer, numberOfChannels) {
50 50
                 this.needTraverse = false;
51 51
             }
52 52
 
53  
-            // Tick up to, but not including this node
54  
-            for (var j = 0; j < this.nodes.length - 1; j++) {
  53
+            // Tick in reverse order up to, but not including this node
  54
+            for (var j = this.nodes.length - 1; j > 0; j--) {
55 55
                 this.nodes[j].tick();
56 56
             }
57 57
             // Cut down tick to just sum the input samples 
6  src/core/AudioletNode.js
@@ -109,9 +109,9 @@ AudioletNode.prototype.tick = function() {
109 109
 };
110 110
 
111 111
 AudioletNode.prototype.traverse = function(nodes) {
112  
-    nodes = this.traverseParents(nodes);
113 112
     if (nodes.indexOf(this) == -1) {
114 113
         nodes.push(this);
  114
+        nodes = this.traverseParents(nodes);
115 115
     }
116 116
     return nodes;
117 117
 };
@@ -148,9 +148,6 @@ AudioletNode.prototype.createInputSamples = function() {
148 148
     var numberOfInputs = this.inputs.length;
149 149
     for (var i = 0; i < numberOfInputs; i++) {
150 150
         var input = this.inputs[i];
151  
-        if (!input.connectedFrom.length) {
152  
-            continue;
153  
-        }
154 151
 
155 152
         var numberOfInputChannels = 0;
156 153
 
@@ -167,6 +164,7 @@ AudioletNode.prototype.createInputSamples = function() {
167 164
                 }
168 165
             }
169 166
         }
  167
+
170 168
         if (input.samples.length > numberOfInputChannels) {
171 169
             input.samples = input.samples.slice(0, numberOfInputChannels);
172 170
         }

0 notes on commit d87cd24

Please sign in to comment.
Something went wrong with that request. Please try again.