fixing infinite loop when stop and start are scheduled at the same time

validating change with test
This commit is contained in:
Yotam Mann 2018-03-30 13:15:53 -04:00
parent 43f8725eff
commit 433cd78689
2 changed files with 21 additions and 1 deletions

View file

@ -302,7 +302,7 @@ define(["Tone/core/Tone", "Tone/signal/TickSignal", "Tone/core/TimelineState",
var lastStateEvent = this._state.get(startTime);
this._state.forEachBetween(startTime, endTime, function(event){
if (lastStateEvent.state === Tone.State.Started && event.state !== Tone.State.Started){
this.forEachTickBetween(Math.max(lastStateEvent.time, startTime), event.time, callback);
this.forEachTickBetween(Math.max(lastStateEvent.time, startTime) + this.sampleTime, event.time, callback);
}
lastStateEvent = event;
}.bind(this));

View file

@ -120,6 +120,26 @@ define(["Test", "Tone/core/Clock", "helper/Offline", "helper/Supports", "Tone/co
};
}, 0.5);
});
it("stop and immediately start", function(){
return Offline(function(){
var clock = new Clock();
expect(clock.state).to.equal("stopped");
clock.start(0).stop(0.1).start(0.1);
expect(clock.state).to.equal("started");
return function(sample, time){
Test.whenBetween(time, 0, 0.1, function(){
expect(clock.state).to.equal("started");
});
Test.whenBetween(time, 0.1, 0.5, function(){
expect(clock.state).to.equal("started");
});
};
}, 0.5);
});
});
context("Scheduling", function(){