From 6ca3c4ec4df5f4bd7ea43b5947f0aa9623b11ffe Mon Sep 17 00:00:00 2001 From: tildearrow Date: Mon, 17 Jan 2022 01:42:26 -0500 Subject: [PATCH] dynamic audio settings changing --- src/engine/dispatchContainer.cpp | 37 ++++++++++++++++++++++++-------- src/engine/engine.cpp | 32 +++++++++++++++++++++------ src/engine/engine.h | 10 ++++++++- src/gui/gui.cpp | 2 ++ 4 files changed, 64 insertions(+), 17 deletions(-) diff --git a/src/engine/dispatchContainer.cpp b/src/engine/dispatchContainer.cpp index 50126b1d0..6affaffab 100644 --- a/src/engine/dispatchContainer.cpp +++ b/src/engine/dispatchContainer.cpp @@ -1,3 +1,4 @@ +#include "blip_buf.h" #include "engine.h" #include "platform/genesis.h" #include "platform/genesisext.h" @@ -22,21 +23,39 @@ void DivDispatchContainer::setRates(double gotRate) { blip_set_rates(bb[1],dispatch->rate,gotRate); } +void DivDispatchContainer::setQuality(bool lowQual) { + lowQuality=lowQual; +} + void DivDispatchContainer::acquire(size_t offset, size_t count) { dispatch->acquire(bbIn[0],bbIn[1],offset,count); } void DivDispatchContainer::fillBuf(size_t runtotal, size_t size) { - for (size_t i=0; iisStereo()) for (size_t i=0; iisStereo()) for (size_t i=0; iisStereo()) for (size_t i=0; isetRun(true)) { + logE("error while activating audio!\n"); + } + } +} + void DivEngine::initDispatch() { isBusy.lock(); for (int i=0; iinit(want,got)) { logE("error while initializing audio!\n"); + delete output; + output=NULL; return false; } return true; @@ -3301,13 +3326,6 @@ bool DivEngine::init() { loadConf(); - // load values - if (getConfString("audioEngine","SDL")=="JACK") { - audioEngine=DIV_AUDIO_JACK; - } else { - audioEngine=DIV_AUDIO_SDL; - } - // init the rest of engine if (!initAudioBackend()) return false; diff --git a/src/engine/engine.h b/src/engine/engine.h index 43209fd50..7c4933aa2 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -86,8 +86,10 @@ struct DivDispatchContainer { int temp[2], prevSample[2]; short* bbIn[2]; short* bbOut[2]; + bool lowQuality; void setRates(double gotRate); + void setQuality(bool lowQual); void acquire(size_t offset, size_t count); void fillBuf(size_t runtotal, size_t size); void clear(); @@ -100,7 +102,8 @@ struct DivDispatchContainer { temp{0,0}, prevSample{0,0}, bbIn{NULL,NULL}, - bbOut{NULL,NULL} {} + bbOut{NULL,NULL}, + lowQuality(false) {} }; class DivEngine { @@ -109,6 +112,7 @@ class DivEngine { TAAudioDesc want, got; int chans; bool active; + bool lowQuality; bool playing; bool freelance; bool speedAB; @@ -424,6 +428,9 @@ class DivEngine { // get last error String getLastError(); + + // switch master + void switchMaster(); // init dispatch void initDispatch(); @@ -443,6 +450,7 @@ class DivEngine { output(NULL), chans(0), active(false), + lowQuality(false), playing(false), freelance(false), speedAB(false), diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 4d1667abb..c5de734ca 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -1923,6 +1923,8 @@ void FurnaceGUI::commitSettings() { e->saveConf(); + e->switchMaster(); + ImGui::GetIO().Fonts->Clear(); if ((mainFont=ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(defFont_main_compressed_data,defFont_main_compressed_size,e->getConfInt("mainFontSize",18)*dpiScale))==NULL) { logE("could not load UI font!\n");