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

View File

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

View File

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