mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 00:27:58 +00:00
fixing infinite loop when stop and start are scheduled at the same time
validating change with test
This commit is contained in:
parent
43f8725eff
commit
433cd78689
2 changed files with 21 additions and 1 deletions
|
@ -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));
|
||||
|
|
|
@ -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(){
|
||||
|
|
Loading…
Reference in a new issue