fix song stopping too early

This commit is contained in:
tildearrow 2022-10-22 03:46:39 -05:00
parent b073368b21
commit a8def55d56
3 changed files with 12 additions and 4 deletions

View File

@ -2357,6 +2357,7 @@ void DivEngine::reset() {
speed2=curSubSong->speed2;
firstTick=false;
shallStop=false;
shallStopSched=false;
nextSpeed=speed1;
divider=60;
if (curSubSong->customTempo) {

View File

@ -328,7 +328,7 @@ class DivEngine {
bool lowQuality;
bool playing;
bool freelance;
bool shallStop;
bool shallStop, shallStopSched;
bool speedAB;
bool endOfSong;
bool consoleMode;
@ -1017,6 +1017,7 @@ class DivEngine {
playing(false),
freelance(false),
shallStop(false),
shallStopSched(false),
speedAB(false),
endOfSong(false),
consoleMode(false),

View File

@ -844,7 +844,8 @@ void DivEngine::processRow(int i, bool afterDelay) {
break;
case 0xff: // stop song
shallStop=true;
shallStopSched=true;
logV("scheduling stop");
break;
}
}
@ -1132,7 +1133,11 @@ bool DivEngine::nextTick(bool noAccum, bool inhibitLowLat) {
tempoAccum-=curSubSong->virtualTempoD;
if (--ticks<=0) {
ret=endOfSong;
if (endOfSong) {
if (shallStopSched) {
logV("acknowledging scheduled stop");
shallStop=true;
break;
} else if (endOfSong) {
if (song.loopModality!=2) {
playSub(true);
}
@ -1147,7 +1152,7 @@ bool DivEngine::nextTick(bool noAccum, bool inhibitLowLat) {
if (tempoAccum>1023) tempoAccum=1023;
}
// process stuff
for (int i=0; i<chans; i++) {
if (!shallStop) for (int i=0; i<chans; i++) {
if (chan[i].rowDelay>0) {
if (--chan[i].rowDelay==0) {
processRow(i,true);
@ -1291,6 +1296,7 @@ bool DivEngine::nextTick(bool noAccum, bool inhibitLowLat) {
sPreview.dir=false;
ret=true;
shallStop=false;
shallStopSched=false;
return ret;
}