fix some threading issues
This commit is contained in:
parent
d0f498189c
commit
6ba8527cb6
|
@ -822,10 +822,6 @@ void DivEngine::runExportThread() {
|
||||||
size_t curFadeOutSample=0;
|
size_t curFadeOutSample=0;
|
||||||
bool isFadingOut=false;
|
bool isFadingOut=false;
|
||||||
|
|
||||||
quitDispatch();
|
|
||||||
initDispatch(true);
|
|
||||||
renderSamples();
|
|
||||||
|
|
||||||
switch (exportMode) {
|
switch (exportMode) {
|
||||||
case DIV_EXPORT_MODE_ONE: {
|
case DIV_EXPORT_MODE_ONE: {
|
||||||
SNDFILE* sf;
|
SNDFILE* sf;
|
||||||
|
@ -838,9 +834,6 @@ void DivEngine::runExportThread() {
|
||||||
sf=sfWrap.doOpen(exportPath.c_str(),SFM_WRITE,&si);
|
sf=sfWrap.doOpen(exportPath.c_str(),SFM_WRITE,&si);
|
||||||
if (sf==NULL) {
|
if (sf==NULL) {
|
||||||
logE("could not open file for writing! (%s)",sf_strerror(NULL));
|
logE("could not open file for writing! (%s)",sf_strerror(NULL));
|
||||||
quitDispatch();
|
|
||||||
initDispatch(false);
|
|
||||||
renderSamples();
|
|
||||||
exporting=false;
|
exporting=false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1153,9 +1146,6 @@ void DivEngine::runExportThread() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
quitDispatch();
|
|
||||||
initDispatch(false);
|
|
||||||
renderSamples();
|
|
||||||
stopExport=false;
|
stopExport=false;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -1163,6 +1153,11 @@ void DivEngine::runExportThread() {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool DivEngine::shallSwitchCores() {
|
||||||
|
// TODO: detect whether we should
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool DivEngine::saveAudio(const char* path, int loops, DivAudioExportModes mode, double fadeOutTime) {
|
bool DivEngine::saveAudio(const char* path, int loops, DivAudioExportModes mode, double fadeOutTime) {
|
||||||
#ifndef HAVE_SNDFILE
|
#ifndef HAVE_SNDFILE
|
||||||
logE("Furnace was not compiled with libsndfile. cannot export!");
|
logE("Furnace was not compiled with libsndfile. cannot export!");
|
||||||
|
@ -1192,6 +1187,20 @@ bool DivEngine::saveAudio(const char* path, int loops, DivAudioExportModes mode,
|
||||||
} else {
|
} else {
|
||||||
remainingLoops=-1;
|
remainingLoops=-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (shallSwitchCores()) {
|
||||||
|
bool isMutedBefore[DIV_MAX_CHANS];
|
||||||
|
memcpy(isMutedBefore,isMuted,DIV_MAX_CHANS*sizeof(bool));
|
||||||
|
quitDispatch();
|
||||||
|
initDispatch(true);
|
||||||
|
renderSamplesP();
|
||||||
|
for (int i=0; i<tchans; i++) {
|
||||||
|
if (isMutedBefore[i]) {
|
||||||
|
muteChannels(i,true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
exportLoopCount=loops;
|
exportLoopCount=loops;
|
||||||
exportThread=new std::thread(_runExportThread,this);
|
exportThread=new std::thread(_runExportThread,this);
|
||||||
return true;
|
return true;
|
||||||
|
@ -1206,10 +1215,27 @@ void DivEngine::waitAudioFile() {
|
||||||
|
|
||||||
bool DivEngine::haltAudioFile() {
|
bool DivEngine::haltAudioFile() {
|
||||||
stopExport=true;
|
stopExport=true;
|
||||||
|
waitAudioFile();
|
||||||
stop();
|
stop();
|
||||||
|
finishAudioFile();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DivEngine::finishAudioFile() {
|
||||||
|
if (shallSwitchCores()) {
|
||||||
|
bool isMutedBefore[DIV_MAX_CHANS];
|
||||||
|
memcpy(isMutedBefore,isMuted,DIV_MAX_CHANS*sizeof(bool));
|
||||||
|
quitDispatch();
|
||||||
|
initDispatch(false);
|
||||||
|
renderSamplesP();
|
||||||
|
for (int i=0; i<tchans; i++) {
|
||||||
|
if (isMutedBefore[i]) {
|
||||||
|
muteChannels(i,true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DivEngine::notifyInsChange(int ins) {
|
void DivEngine::notifyInsChange(int ins) {
|
||||||
BUSY_BEGIN;
|
BUSY_BEGIN;
|
||||||
for (int i=0; i<song.systemLen; i++) {
|
for (int i=0; i<song.systemLen; i++) {
|
||||||
|
|
|
@ -497,6 +497,7 @@ class DivEngine {
|
||||||
void playSub(bool preserveDrift, int goalRow=0);
|
void playSub(bool preserveDrift, int goalRow=0);
|
||||||
void runMidiClock(int totalCycles=1);
|
void runMidiClock(int totalCycles=1);
|
||||||
void runMidiTime(int totalCycles=1);
|
void runMidiTime(int totalCycles=1);
|
||||||
|
bool shallSwitchCores();
|
||||||
|
|
||||||
void testFunction();
|
void testFunction();
|
||||||
|
|
||||||
|
@ -614,6 +615,8 @@ class DivEngine {
|
||||||
void waitAudioFile();
|
void waitAudioFile();
|
||||||
// stop audio file export
|
// stop audio file export
|
||||||
bool haltAudioFile();
|
bool haltAudioFile();
|
||||||
|
// return back to playback cores if necessary
|
||||||
|
void finishAudioFile();
|
||||||
// notify instrument parameter change
|
// notify instrument parameter change
|
||||||
void notifyInsChange(int ins);
|
void notifyInsChange(int ins);
|
||||||
// notify wavetable change
|
// notify wavetable change
|
||||||
|
|
|
@ -5262,6 +5262,7 @@ bool FurnaceGUI::loop() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!e->isExporting()) {
|
if (!e->isExporting()) {
|
||||||
|
e->finishAudioFile();
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
}
|
}
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
|
|
Loading…
Reference in New Issue