fix audio backend not changing on switchMaster

This commit is contained in:
tildearrow 2022-09-10 23:32:04 -05:00
parent 2f0e97f6d9
commit 29f1be3b36
2 changed files with 9 additions and 4 deletions

View File

@ -3453,7 +3453,8 @@ void DivEngine::setConsoleMode(bool enable) {
}
bool DivEngine::switchMaster() {
deinitAudioBackend();
logI("switching output...");
deinitAudioBackend(true);
quitDispatch();
initDispatch();
if (initAudioBackend()) {
@ -3599,6 +3600,7 @@ void DivEngine::quitDispatch() {
bool DivEngine::initAudioBackend() {
// load values
logI("initializing audio.");
if (audioEngine==DIV_AUDIO_NULL) {
if (getConfString("audioEngine","SDL")=="JACK") {
audioEngine=DIV_AUDIO_JACK;
@ -3704,8 +3706,9 @@ bool DivEngine::initAudioBackend() {
return true;
}
bool DivEngine::deinitAudioBackend() {
bool DivEngine::deinitAudioBackend(bool dueToSwitchMaster) {
if (output!=NULL) {
logI("closing audio output.");
output->quit();
if (output->midiIn) {
if (output->midiIn->isDeviceOpen()) {
@ -3722,7 +3725,9 @@ bool DivEngine::deinitAudioBackend() {
output->quitMidi();
delete output;
output=NULL;
//audioEngine=DIV_AUDIO_NULL;
if (dueToSwitchMaster) {
audioEngine=DIV_AUDIO_NULL;
}
}
return true;
}

View File

@ -452,7 +452,7 @@ class DivEngine {
int loadSampleROM(String path, ssize_t expectedSize, unsigned char*& ret);
bool initAudioBackend();
bool deinitAudioBackend();
bool deinitAudioBackend(bool dueToSwitchMaster=false);
void registerSystems();
void initSongWithDesc(const int* description);