don't stop the song until it has been loaded

This commit is contained in:
tildearrow 2021-12-20 14:20:05 -05:00
parent f24493efb6
commit 548fa2ad73
3 changed files with 11 additions and 5 deletions

View File

@ -884,10 +884,17 @@ bool DivEngine::load(unsigned char* f, size_t slen) {
}
}
if (active) quitDispatch();
isBusy.lock();
song.unload();
song=ds;
chans=getChannelCount(song.system);
renderSamples();
isBusy.unlock();
if (active) {
initDispatch();
syncReset();
}
} catch (EndOfFileException e) {
logE("premature end of file!\n");
delete[] file;
@ -1867,6 +1874,7 @@ bool DivEngine::init(String outName) {
initDispatch();
reset();
active=true;
if (outName!="") {
short* ilBuffer=new short[got.bufsize*2];
@ -1911,5 +1919,6 @@ bool DivEngine::quit() {
quitDispatch();
logI("saving config.\n");
saveConf();
active=false;
return true;
}

View File

@ -72,6 +72,7 @@ class DivEngine {
TAAudio* output;
TAAudioDesc want, got;
int chans;
bool active;
bool playing;
bool speedAB;
bool endOfSong;
@ -267,6 +268,7 @@ class DivEngine {
DivEngine():
chans(0),
active(false),
playing(false),
speedAB(false),
endOfSong(false),

View File

@ -1821,15 +1821,10 @@ int FurnaceGUI::load(String path) {
return 1;
}
fclose(f);
e->quitDispatch();
if (!e->load(file,(size_t)len)) {
logE("could not open file!\n");
e->initDispatch();
e->syncReset();
return 1;
}
e->initDispatch();
e->syncReset();
}
updateWindowTitle();
return 0;