fix possible hang in runMidiClock

issue #1167
This commit is contained in:
tildearrow 2023-06-20 01:08:51 -05:00
parent 9851f5cc87
commit 443535a54c

View file

@ -1564,8 +1564,10 @@ void DivEngine::runMidiClock(int totalCycles) {
if (speedSum<1.0) speedSum=1.0;
if (vD<1) vD=1;
double bpm=((24.0*divider)/(timeBase*hl*speedSum))*(double)curSubSong->virtualTempoN/vD;
if (bpm<1.0) bpm=1.0;
int increment=got.rate*pow(2,MASTER_CLOCK_PREC)/(bpm);
midiClockCycles+=got.rate*pow(2,MASTER_CLOCK_PREC)/(bpm);
midiClockCycles+=increment;
midiClockDrift+=fmod(got.rate*pow(2,MASTER_CLOCK_PREC),(double)(bpm));
if (midiClockDrift>=(bpm)) {
midiClockDrift-=(bpm);