From 8ea6bef98f535301d23aa1c81d4080c208527705 Mon Sep 17 00:00:00 2001 From: sowens99 Date: Wed, 13 Oct 2021 20:29:04 -0400 Subject: [PATCH] Port Main.DSP to MainSettings While trying to work on adding audiodump support for CLI, I was alerted that it was important to first try moving the DSP configs to the new config before continuing, as that makes it substantially easier to write clean code to add such a feature. This commit aims to allow for Dolphin to only rely on the new config for DSP-related settings. --- Source/Core/AudioCommon/AudioCommon.cpp | 27 +++++---- Source/Core/AudioCommon/AudioStretcher.cpp | 4 +- Source/Core/AudioCommon/CubebStream.cpp | 4 +- Source/Core/AudioCommon/Mixer.cpp | 2 +- Source/Core/AudioCommon/OpenALStream.cpp | 8 +-- Source/Core/AudioCommon/PulseAudioStream.cpp | 4 +- Source/Core/AudioCommon/WASAPIStream.cpp | 20 +++---- Source/Core/AudioCommon/WaveFile.cpp | 3 +- Source/Core/Core/BootManager.cpp | 23 -------- Source/Core/Core/Config/MainSettings.cpp | 10 ++++ Source/Core/Core/Config/MainSettings.h | 17 ++++++ .../Core/ConfigLoaders/IsSettingSaveable.cpp | 8 ++- Source/Core/Core/ConfigManager.cpp | 58 ------------------- Source/Core/Core/ConfigManager.h | 36 ------------ Source/Core/Core/Core.cpp | 13 +++-- Source/Core/Core/DolphinAnalytics.cpp | 8 +-- Source/Core/Core/HW/DSPHLE/UCodes/ROM.cpp | 3 +- Source/Core/Core/HW/DSPHLE/UCodes/UCodes.cpp | 3 +- Source/Core/Core/HW/DSPLLE/DSPHost.cpp | 5 +- Source/Core/Core/HW/DSPLLE/DSPLLE.cpp | 7 ++- Source/Core/Core/HW/HW.cpp | 3 +- Source/Core/Core/IOS/MIOS.cpp | 6 +- Source/Core/DolphinQt/HotkeyScheduler.cpp | 5 +- Source/Core/DolphinQt/MenuBar.cpp | 5 +- Source/Core/DolphinQt/Settings.cpp | 4 +- Source/Core/DolphinQt/Settings/AudioPane.cpp | 51 ++++++++-------- 26 files changed, 132 insertions(+), 205 deletions(-) diff --git a/Source/Core/AudioCommon/AudioCommon.cpp b/Source/Core/AudioCommon/AudioCommon.cpp index d3bdcde445..ab45161651 100644 --- a/Source/Core/AudioCommon/AudioCommon.cpp +++ b/Source/Core/AudioCommon/AudioCommon.cpp @@ -13,6 +13,7 @@ #include "Common/Common.h" #include "Common/FileUtil.h" #include "Common/Logging/Log.h" +#include "Core/Config/MainSettings.h" #include "Core/ConfigManager.h" // This shouldn't be a global, at least not here. @@ -47,7 +48,7 @@ static std::unique_ptr CreateSoundStreamForBackend(std::string_view void InitSoundStream() { - std::string backend = SConfig::GetInstance().sBackend; + std::string backend = Config::Get(Config::MAIN_AUDIO_BACKEND); g_sound_stream = CreateSoundStreamForBackend(backend); if (!g_sound_stream) @@ -73,7 +74,7 @@ void PostInitSoundStream() UpdateSoundStream(); SetSoundStreamRunning(true); - if (SConfig::GetInstance().m_DumpAudio && !s_audio_dump_start) + if (Config::Get(Config::MAIN_DUMP_AUDIO) && !s_audio_dump_start) StartAudioDump(); } @@ -81,7 +82,7 @@ void ShutdownSoundStream() { INFO_LOG_FMT(AUDIO, "Shutting down sound stream"); - if (SConfig::GetInstance().m_DumpAudio && s_audio_dump_start) + if (Config::Get(Config::MAIN_DUMP_AUDIO) && s_audio_dump_start) StopAudioDump(); SetSoundStreamRunning(false); @@ -159,7 +160,7 @@ void UpdateSoundStream() { if (g_sound_stream) { - int volume = SConfig::GetInstance().m_IsMuted ? 0 : SConfig::GetInstance().m_Volume; + int volume = Config::Get(Config::MAIN_AUDIO_MUTED) ? 0 : Config::Get(Config::MAIN_AUDIO_VOLUME); g_sound_stream->SetVolume(volume); } } @@ -186,9 +187,9 @@ void SendAIBuffer(const short* samples, unsigned int num_samples) if (!g_sound_stream) return; - if (SConfig::GetInstance().m_DumpAudio && !s_audio_dump_start) + if (Config::Get(Config::MAIN_DUMP_AUDIO) && !s_audio_dump_start) StartAudioDump(); - else if (!SConfig::GetInstance().m_DumpAudio && s_audio_dump_start) + else if (!Config::Get(Config::MAIN_DUMP_AUDIO) && s_audio_dump_start) StopAudioDump(); Mixer* pMixer = g_sound_stream->GetMixer(); @@ -221,28 +222,30 @@ void StopAudioDump() void IncreaseVolume(unsigned short offset) { - SConfig::GetInstance().m_IsMuted = false; - int& currentVolume = SConfig::GetInstance().m_Volume; + Config::SetBaseOrCurrent(Config::MAIN_AUDIO_MUTED, false); + int currentVolume = Config::Get(Config::MAIN_AUDIO_VOLUME); currentVolume += offset; if (currentVolume > AUDIO_VOLUME_MAX) currentVolume = AUDIO_VOLUME_MAX; + Config::SetBaseOrCurrent(Config::MAIN_AUDIO_VOLUME, currentVolume); UpdateSoundStream(); } void DecreaseVolume(unsigned short offset) { - SConfig::GetInstance().m_IsMuted = false; - int& currentVolume = SConfig::GetInstance().m_Volume; + Config::SetBaseOrCurrent(Config::MAIN_AUDIO_MUTED, false); + int currentVolume = Config::Get(Config::MAIN_AUDIO_VOLUME); currentVolume -= offset; if (currentVolume < AUDIO_VOLUME_MIN) currentVolume = AUDIO_VOLUME_MIN; + Config::SetBaseOrCurrent(Config::MAIN_AUDIO_VOLUME, currentVolume); UpdateSoundStream(); } void ToggleMuteVolume() { - bool& isMuted = SConfig::GetInstance().m_IsMuted; - isMuted = !isMuted; + bool isMuted = Config::Get(Config::MAIN_AUDIO_MUTED); + Config::SetBaseOrCurrent(Config::MAIN_AUDIO_MUTED, !isMuted); UpdateSoundStream(); } } // namespace AudioCommon diff --git a/Source/Core/AudioCommon/AudioStretcher.cpp b/Source/Core/AudioCommon/AudioStretcher.cpp index a94e707d56..c786dc0941 100644 --- a/Source/Core/AudioCommon/AudioStretcher.cpp +++ b/Source/Core/AudioCommon/AudioStretcher.cpp @@ -7,7 +7,7 @@ #include "AudioCommon/AudioStretcher.h" #include "Common/Logging/Log.h" -#include "Core/ConfigManager.h" +#include "Core/Config/MainSettings.h" namespace AudioCommon { @@ -31,7 +31,7 @@ void AudioStretcher::ProcessSamples(const short* in, unsigned int num_in, unsign // We were given actual_samples number of samples, and num_samples were requested from us. double current_ratio = static_cast(num_in) / static_cast(num_out); - const double max_latency = SConfig::GetInstance().m_audio_stretch_max_latency; + const double max_latency = Config::Get(Config::MAIN_AUDIO_STRETCH_LATENCY); const double max_backlog = m_sample_rate * max_latency / 1000.0 / m_stretch_ratio; const double backlog_fullness = m_sound_touch.numSamples() / max_backlog; if (backlog_fullness > 5.0) diff --git a/Source/Core/AudioCommon/CubebStream.cpp b/Source/Core/AudioCommon/CubebStream.cpp index 0d9535600a..6d903bb999 100644 --- a/Source/Core/AudioCommon/CubebStream.cpp +++ b/Source/Core/AudioCommon/CubebStream.cpp @@ -8,7 +8,7 @@ #include "Common/CommonTypes.h" #include "Common/Logging/Log.h" #include "Common/Thread.h" -#include "Core/ConfigManager.h" +#include "Core/Config/MainSettings.h" // ~10 ms - needs to be at least 240 for surround constexpr u32 BUFFER_SAMPLES = 512; @@ -36,7 +36,7 @@ bool CubebStream::Init() if (!m_ctx) return false; - m_stereo = !SConfig::GetInstance().ShouldUseDPL2Decoder(); + m_stereo = !Config::ShouldUseDPL2Decoder(); cubeb_stream_params params; params.rate = m_mixer->GetSampleRate(); diff --git a/Source/Core/AudioCommon/Mixer.cpp b/Source/Core/AudioCommon/Mixer.cpp index e50d90b32b..dbd2b1f69f 100644 --- a/Source/Core/AudioCommon/Mixer.cpp +++ b/Source/Core/AudioCommon/Mixer.cpp @@ -154,7 +154,7 @@ unsigned int Mixer::Mix(short* samples, unsigned int num_samples) memset(samples, 0, num_samples * 2 * sizeof(short)); - if (SConfig::GetInstance().m_audio_stretch) + if (Config::Get(Config::MAIN_AUDIO_STRETCH)) { unsigned int available_samples = std::min(m_dma_mixer.AvailableSamples(), m_streaming_mixer.AvailableSamples()); diff --git a/Source/Core/AudioCommon/OpenALStream.cpp b/Source/Core/AudioCommon/OpenALStream.cpp index 3e56fe8e08..45d1aa23c8 100644 --- a/Source/Core/AudioCommon/OpenALStream.cpp +++ b/Source/Core/AudioCommon/OpenALStream.cpp @@ -12,7 +12,7 @@ #include "Common/Logging/Log.h" #include "Common/MsgHandler.h" #include "Common/Thread.h" -#include "Core/ConfigManager.h" +#include "Core/Config/MainSettings.h" static HMODULE s_openal_dll = nullptr; @@ -212,7 +212,7 @@ void OpenALStream::SoundLoop() bool float32_capable = palIsExtensionPresent("AL_EXT_float32") != 0; bool surround_capable = palIsExtensionPresent("AL_EXT_MCFORMATS") || IsCreativeXFi(); - bool use_surround = SConfig::GetInstance().ShouldUseDPL2Decoder() && surround_capable; + bool use_surround = Config::ShouldUseDPL2Decoder() && surround_capable; // As there is no extension to check for 32-bit fixed point support // and we know that only a X-Fi with hardware OpenAL supports it, @@ -223,9 +223,9 @@ void OpenALStream::SoundLoop() u32 frames_per_buffer; // Can't have zero samples per buffer - if (SConfig::GetInstance().iLatency > 0) + if (Config::Get(Config::MAIN_AUDIO_LATENCY) > 0) { - frames_per_buffer = frequency / 1000 * SConfig::GetInstance().iLatency / OAL_BUFFERS; + frames_per_buffer = frequency / 1000 * Config::Get(Config::MAIN_AUDIO_LATENCY) / OAL_BUFFERS; } else { diff --git a/Source/Core/AudioCommon/PulseAudioStream.cpp b/Source/Core/AudioCommon/PulseAudioStream.cpp index 3b093aeb79..5b0662972d 100644 --- a/Source/Core/AudioCommon/PulseAudioStream.cpp +++ b/Source/Core/AudioCommon/PulseAudioStream.cpp @@ -9,7 +9,7 @@ #include "Common/CommonTypes.h" #include "Common/Logging/Log.h" #include "Common/Thread.h" -#include "Core/ConfigManager.h" +#include "Core/Config/MainSettings.h" namespace { @@ -20,7 +20,7 @@ PulseAudio::PulseAudio() = default; bool PulseAudio::Init() { - m_stereo = !SConfig::GetInstance().ShouldUseDPL2Decoder(); + m_stereo = !Config::ShouldUseDPL2Decoder(); m_channels = m_stereo ? 2 : 6; // will tell PA we use a Stereo or 5.0 channel setup NOTICE_LOG_FMT(AUDIO, "PulseAudio backend using {} channels", m_channels); diff --git a/Source/Core/AudioCommon/WASAPIStream.cpp b/Source/Core/AudioCommon/WASAPIStream.cpp index d65471226b..2a15e08195 100644 --- a/Source/Core/AudioCommon/WASAPIStream.cpp +++ b/Source/Core/AudioCommon/WASAPIStream.cpp @@ -20,7 +20,7 @@ #include "Common/Logging/Log.h" #include "Common/StringUtil.h" #include "Common/Thread.h" -#include "Core/ConfigManager.h" +#include "Core/Config/MainSettings.h" #include "VideoCommon/OnScreenDisplay.h" using Microsoft::WRL::ComPtr; @@ -176,19 +176,19 @@ bool WASAPIStream::SetRunning(bool running) HRESULT result; - if (SConfig::GetInstance().sWASAPIDevice == "default") + if (Config::Get(Config::MAIN_WASAPI_DEVICE) == "default") { result = m_enumerator->GetDefaultAudioEndpoint(eRender, eConsole, device.GetAddressOf()); } else { result = S_OK; - device = GetDeviceByName(SConfig::GetInstance().sWASAPIDevice); + device = GetDeviceByName(Config::Get(Config::MAIN_WASAPI_DEVICE)); if (!device) { ERROR_LOG_FMT(AUDIO, "Can't find device '{}', falling back to default", - SConfig::GetInstance().sWASAPIDevice); + Config::Get(Config::MAIN_WASAPI_DEVICE)); result = m_enumerator->GetDefaultAudioEndpoint(eRender, eConsole, device.GetAddressOf()); } } @@ -222,7 +222,7 @@ bool WASAPIStream::SetRunning(bool running) result = audio_client->GetDevicePeriod(nullptr, &device_period); - device_period += SConfig::GetInstance().iLatency * (10000 / m_format.Format.nChannels); + device_period += Config::Get(Config::MAIN_AUDIO_LATENCY) * (10000 / m_format.Format.nChannels); INFO_LOG_FMT(AUDIO, "Audio period set to {}", device_period); if (!HandleWinAPI("Failed to obtain device period", result)) @@ -258,7 +258,7 @@ bool WASAPIStream::SetRunning(bool running) device_period = static_cast( 10000.0 * 1000 * m_frames_in_buffer / m_format.Format.nSamplesPerSec + 0.5) + - SConfig::GetInstance().iLatency * 10000; + Config::Get(Config::MAIN_AUDIO_LATENCY) * 10000; result = audio_client->Initialize( AUDCLNT_SHAREMODE_EXCLUSIVE, @@ -333,13 +333,13 @@ void WASAPIStream::SoundLoop() s16* audio_data = reinterpret_cast(data); GetMixer()->Mix(audio_data, m_frames_in_buffer); - const SConfig& config = SConfig::GetInstance(); - const bool is_muted = config.m_IsMuted || config.m_Volume == 0; - const bool need_volume_adjustment = config.m_Volume != 100 && !is_muted; + const bool is_muted = + Config::Get(Config::MAIN_AUDIO_MUTED) || Config::Get(Config::MAIN_AUDIO_VOLUME) == 0; + const bool need_volume_adjustment = Config::Get(Config::MAIN_AUDIO_VOLUME) != 100 && !is_muted; if (need_volume_adjustment) { - const float volume = config.m_Volume / 100.0f; + const float volume = Config::Get(Config::MAIN_AUDIO_VOLUME) / 100.0f; for (u32 i = 0; i < m_frames_in_buffer * 2; i++) *audio_data++ *= volume; diff --git a/Source/Core/AudioCommon/WaveFile.cpp b/Source/Core/AudioCommon/WaveFile.cpp index ac378cb748..a7dd489db3 100644 --- a/Source/Core/AudioCommon/WaveFile.cpp +++ b/Source/Core/AudioCommon/WaveFile.cpp @@ -12,6 +12,7 @@ #include "Common/MsgHandler.h" #include "Common/StringUtil.h" #include "Common/Swap.h" +#include "Core/Config/MainSettings.h" #include "Core/ConfigManager.h" constexpr size_t WaveFileWriter::BUFFER_SIZE; @@ -30,7 +31,7 @@ bool WaveFileWriter::Start(const std::string& filename, unsigned int HLESampleRa // Ask to delete file if (File::Exists(filename)) { - if (SConfig::GetInstance().m_DumpAudioSilent || + if (Config::Get(Config::MAIN_DUMP_AUDIO_SILENT) || AskYesNoFmtT("Delete the existing file '{0}'?", filename)) { File::Delete(filename); diff --git a/Source/Core/Core/BootManager.cpp b/Source/Core/Core/BootManager.cpp index a9a0014155..308cfbcd01 100644 --- a/Source/Core/Core/BootManager.cpp +++ b/Source/Core/Core/BootManager.cpp @@ -82,22 +82,18 @@ private: bool bMMU = false; bool bLowDCBZHack = false; bool bDisableICache = false; - bool m_EnableJIT = false; bool bSyncGPU = false; int iSyncGpuMaxDistance = 0; int iSyncGpuMinDistance = 0; float fSyncGpuOverclock = 0; bool bFastDiscSpeed = false; - bool bDSPHLE = false; bool bHLE_BS2 = false; int iSelectedLanguage = 0; PowerPC::CPUCore cpu_core = PowerPC::CPUCore::Interpreter; - int Volume = 0; float m_EmulationSpeed = 0; float m_OCFactor = 0; bool m_OCEnable = false; bool m_bt_passthrough_enabled = false; - std::string sBackend; std::string m_strGPUDeterminismMode; std::array iWiimoteSource{}; std::array Pads{}; @@ -117,19 +113,15 @@ void ConfigCache::SaveConfig(const SConfig& config) bAccurateNaNs = config.bAccurateNaNs; bDisableICache = config.bDisableICache; bMMU = config.bMMU; - m_EnableJIT = config.m_DSPEnableJIT; bSyncGPU = config.bSyncGPU; iSyncGpuMaxDistance = config.iSyncGpuMaxDistance; iSyncGpuMinDistance = config.iSyncGpuMinDistance; fSyncGpuOverclock = config.fSyncGpuOverclock; bFastDiscSpeed = config.bFastDiscSpeed; - bDSPHLE = config.bDSPHLE; bHLE_BS2 = config.bHLE_BS2; iSelectedLanguage = config.SelectedLanguage; cpu_core = config.cpu_core; - Volume = config.m_Volume; m_EmulationSpeed = config.m_EmulationSpeed; - sBackend = config.sBackend; m_strGPUDeterminismMode = config.m_strGPUDeterminismMode; m_OCFactor = config.m_OCFactor; m_OCEnable = config.m_OCEnable; @@ -165,22 +157,17 @@ void ConfigCache::RestoreConfig(SConfig* config) config->bDisableICache = bDisableICache; config->bMMU = bMMU; config->bLowDCBZHack = bLowDCBZHack; - config->m_DSPEnableJIT = m_EnableJIT; config->bSyncGPU = bSyncGPU; config->iSyncGpuMaxDistance = iSyncGpuMaxDistance; config->iSyncGpuMinDistance = iSyncGpuMinDistance; config->fSyncGpuOverclock = fSyncGpuOverclock; config->bFastDiscSpeed = bFastDiscSpeed; - config->bDSPHLE = bDSPHLE; config->bHLE_BS2 = bHLE_BS2; config->SelectedLanguage = iSelectedLanguage; config->cpu_core = cpu_core; // Only change these back if they were actually set by game ini, since they can be changed while a // game is running. - if (bSetVolume) - config->m_Volume = Volume; - if (config->bWii) { for (unsigned int i = 0; i < MAX_BBMOTES; ++i) @@ -205,7 +192,6 @@ void ConfigCache::RestoreConfig(SConfig* config) config->m_EXIDevice[i] = m_EXIDevice[i]; } - config->sBackend = sBackend; config->m_strGPUDeterminismMode = m_strGPUDeterminismMode; config->m_OCFactor = m_OCFactor; config->m_OCEnable = m_OCEnable; @@ -255,7 +241,6 @@ bool BootCore(std::unique_ptr boot, const WindowSystemInfo& wsi) // General settings IniFile::Section* core_section = game_ini.GetOrCreateSection("Core"); - IniFile::Section* dsp_section = game_ini.GetOrCreateSection("DSP"); IniFile::Section* controls_section = game_ini.GetOrCreateSection("Controls"); core_section->Get("CPUThread", &StartUp.bCPUThread, StartUp.bCPUThread); @@ -272,17 +257,12 @@ bool BootCore(std::unique_ptr boot, const WindowSystemInfo& wsi) core_section->Get("LowDCBZHack", &StartUp.bLowDCBZHack, StartUp.bLowDCBZHack); core_section->Get("SyncGPU", &StartUp.bSyncGPU, StartUp.bSyncGPU); core_section->Get("FastDiscSpeed", &StartUp.bFastDiscSpeed, StartUp.bFastDiscSpeed); - core_section->Get("DSPHLE", &StartUp.bDSPHLE, StartUp.bDSPHLE); core_section->Get("CPUCore", &StartUp.cpu_core, StartUp.cpu_core); core_section->Get("HLE_BS2", &StartUp.bHLE_BS2, StartUp.bHLE_BS2); core_section->Get("GameCubeLanguage", &StartUp.SelectedLanguage, StartUp.SelectedLanguage); if (core_section->Get("EmulationSpeed", &StartUp.m_EmulationSpeed, StartUp.m_EmulationSpeed)) config_cache.bSetEmulationSpeed = true; - if (dsp_section->Get("Volume", &StartUp.m_Volume, StartUp.m_Volume)) - config_cache.bSetVolume = true; - dsp_section->Get("EnableJIT", &StartUp.m_DSPEnableJIT, StartUp.m_DSPEnableJIT); - dsp_section->Get("Backend", &StartUp.sBackend, StartUp.sBackend); core_section->Get("GPUDeterminismMode", &StartUp.m_strGPUDeterminismMode, StartUp.m_strGPUDeterminismMode); core_section->Get("Overclock", &StartUp.m_OCFactor, StartUp.m_OCFactor); @@ -334,7 +314,6 @@ bool BootCore(std::unique_ptr boot, const WindowSystemInfo& wsi) // TODO: remove this once ConfigManager starts using OnionConfig. StartUp.bCPUThread = Config::Get(Config::MAIN_CPU_THREAD); StartUp.bJITFollowBranch = Config::Get(Config::MAIN_JIT_FOLLOW_BRANCH); - StartUp.bDSPHLE = Config::Get(Config::MAIN_DSP_HLE); StartUp.bFastDiscSpeed = Config::Get(Config::MAIN_FAST_DISC_SPEED); StartUp.cpu_core = Config::Get(Config::MAIN_CPU_CORE); StartUp.bSyncGPU = Config::Get(Config::MAIN_SYNC_GPU); @@ -361,12 +340,10 @@ bool BootCore(std::unique_ptr boot, const WindowSystemInfo& wsi) const NetPlay::NetSettings& netplay_settings = NetPlay::GetNetSettings(); Config::AddLayer(ConfigLoaders::GenerateNetPlayConfigLoader(netplay_settings)); StartUp.bCPUThread = netplay_settings.m_CPUthread; - StartUp.bDSPHLE = netplay_settings.m_DSPHLE; StartUp.bCopyWiiSaveNetplay = netplay_settings.m_CopyWiiSave; StartUp.cpu_core = netplay_settings.m_CPUcore; StartUp.SelectedLanguage = netplay_settings.m_SelectedLanguage; StartUp.bOverrideRegionSettings = netplay_settings.m_OverrideRegionSettings; - StartUp.m_DSPEnableJIT = netplay_settings.m_DSPEnableJIT; StartUp.m_OCEnable = netplay_settings.m_OCEnable; StartUp.m_OCFactor = netplay_settings.m_OCFactor; StartUp.m_EXIDevice[0] = netplay_settings.m_EXIDevice[0]; diff --git a/Source/Core/Core/Config/MainSettings.cpp b/Source/Core/Core/Config/MainSettings.cpp index ca48d4c9f8..fdb75cce33 100644 --- a/Source/Core/Core/Config/MainSettings.cpp +++ b/Source/Core/Core/Config/MainSettings.cpp @@ -131,6 +131,7 @@ const Info MAIN_DISABLE_SCREENSAVER{{System::Main, "Display", "DisableScre // Main.DSP +const Info MAIN_DSP_THREAD{{System::Main, "DSP", "DSPThread"}, false}; const Info MAIN_DSP_CAPTURE_LOG{{System::Main, "DSP", "CaptureLog"}, false}; const Info MAIN_DSP_JIT{{System::Main, "DSP", "EnableJIT"}, true}; const Info MAIN_DUMP_AUDIO{{System::Main, "DSP", "DumpAudio"}, false}; @@ -139,6 +140,15 @@ const Info MAIN_DUMP_UCODE{{System::Main, "DSP", "DumpUCode"}, false}; const Info MAIN_AUDIO_BACKEND{{System::Main, "DSP", "Backend"}, AudioCommon::GetDefaultSoundBackend()}; const Info MAIN_AUDIO_VOLUME{{System::Main, "DSP", "Volume"}, 100}; +const Info MAIN_AUDIO_MUTED{{System::Main, "DSP", "Muted"}, false}; +#ifdef _WIN32 +const Info MAIN_WASAPI_DEVICE{{System::Main, "DSP", "WASAPIDevice"}, "Default"}; +#endif + +bool ShouldUseDPL2Decoder() +{ + return Get(MAIN_DPL2_DECODER) && !Get(MAIN_DSP_HLE); +} // Main.General diff --git a/Source/Core/Core/Config/MainSettings.h b/Source/Core/Core/Config/MainSettings.h index 14867978ac..3e8380163e 100644 --- a/Source/Core/Core/Config/MainSettings.h +++ b/Source/Core/Core/Config/MainSettings.h @@ -6,9 +6,19 @@ #include #include +#include "Common/Common.h" #include "Common/Config/Config.h" #include "DiscIO/Enums.h" +// DSP Backend Types +#define BACKEND_NULLSOUND _trans("No Audio Output") +#define BACKEND_ALSA "ALSA" +#define BACKEND_CUBEB "Cubeb" +#define BACKEND_OPENAL "OpenAL" +#define BACKEND_PULSEAUDIO "Pulse" +#define BACKEND_OPENSLES "OpenSLES" +#define BACKEND_WASAPI _trans("WASAPI (Exclusive Mode)") + namespace PowerPC { enum class CPUCore; @@ -93,6 +103,7 @@ extern const Info MAIN_REAL_WII_REMOTE_REPEAT_REPORTS; // Main.DSP +extern const Info MAIN_DSP_THREAD; extern const Info MAIN_DSP_CAPTURE_LOG; extern const Info MAIN_DSP_JIT; extern const Info MAIN_DUMP_AUDIO; @@ -100,6 +111,12 @@ extern const Info MAIN_DUMP_AUDIO_SILENT; extern const Info MAIN_DUMP_UCODE; extern const Info MAIN_AUDIO_BACKEND; extern const Info MAIN_AUDIO_VOLUME; +extern const Info MAIN_AUDIO_MUTED; +#ifdef _WIN32 +extern const Info MAIN_WASAPI_DEVICE; +#endif + +bool ShouldUseDPL2Decoder(); // Main.Display diff --git a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp index cce987ea40..23f3b3e783 100644 --- a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp +++ b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp @@ -25,8 +25,8 @@ bool IsSettingSaveable(const Config::Location& config_location) if (config_location.system == Config::System::Main) { - for (const std::string_view section : - {"NetPlay", "General", "GBA", "Display", "Network", "Analytics", "AndroidOverlayButtons"}) + for (const std::string_view section : {"NetPlay", "General", "GBA", "Display", "Network", + "Analytics", "AndroidOverlayButtons", "DSP"}) { if (config_location.section == section) return true; @@ -57,6 +57,9 @@ bool IsSettingSaveable(const Config::Location& config_location) &Config::MAIN_ALLOW_SD_WRITES.GetLocation(), &Config::MAIN_DPL2_DECODER.GetLocation(), &Config::MAIN_DPL2_QUALITY.GetLocation(), + &Config::MAIN_AUDIO_LATENCY.GetLocation(), + &Config::MAIN_AUDIO_STRETCH.GetLocation(), + &Config::MAIN_AUDIO_STRETCH_LATENCY.GetLocation(), &Config::MAIN_RAM_OVERRIDE_ENABLE.GetLocation(), &Config::MAIN_MEM1_SIZE.GetLocation(), &Config::MAIN_MEM2_SIZE.GetLocation(), @@ -64,6 +67,7 @@ bool IsSettingSaveable(const Config::Location& config_location) &Config::MAIN_ENABLE_SAVESTATES.GetLocation(), &Config::MAIN_FALLBACK_REGION.GetLocation(), &Config::MAIN_REAL_WII_REMOTE_REPEAT_REPORTS.GetLocation(), + &Config::MAIN_DSP_HLE.GetLocation(), // Main.Interface diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp index 5b6bd5713e..fafae00781 100644 --- a/Source/Core/Core/ConfigManager.cpp +++ b/Source/Core/Core/ConfigManager.cpp @@ -93,7 +93,6 @@ void SConfig::SaveSettings() SaveGameListSettings(ini); SaveCoreSettings(ini); SaveMovieSettings(ini); - SaveDSPSettings(ini); SaveInputSettings(ini); SaveFifoPlayerSettings(ini); SaveBluetoothPassthroughSettings(ini); @@ -207,7 +206,6 @@ void SConfig::SaveCoreSettings(IniFile& ini) core->Set("CPUCore", cpu_core); core->Set("Fastmem", bFastmem); core->Set("CPUThread", bCPUThread); - core->Set("DSPHLE", bDSPHLE); core->Set("SyncOnSkipIdle", bSyncGPUOnSkipIdleHack); core->Set("SyncGPU", bSyncGPU); core->Set("SyncGpuMaxDistance", iSyncGpuMaxDistance); @@ -219,10 +217,6 @@ void SConfig::SaveCoreSettings(IniFile& ini) core->Set("AccurateNaNs", bAccurateNaNs); core->Set("SelectedLanguage", SelectedLanguage); core->Set("OverrideRegionSettings", bOverrideRegionSettings); - core->Set("DPL2Decoder", bDPL2Decoder); - core->Set("AudioLatency", iLatency); - core->Set("AudioStretch", m_audio_stretch); - core->Set("AudioStretchMaxLatency", m_audio_stretch_max_latency); core->Set("AgpCartAPath", m_strGbaCartA); core->Set("AgpCartBPath", m_strGbaCartB); core->Set("SlotA", m_EXIDevice[0]); @@ -266,23 +260,6 @@ void SConfig::SaveMovieSettings(IniFile& ini) movie->Set("ShowRTC", m_ShowRTC); } -void SConfig::SaveDSPSettings(IniFile& ini) -{ - IniFile::Section* dsp = ini.GetOrCreateSection("DSP"); - - dsp->Set("EnableJIT", m_DSPEnableJIT); - dsp->Set("DumpAudio", m_DumpAudio); - dsp->Set("DumpAudioSilent", m_DumpAudioSilent); - dsp->Set("DumpUCode", m_DumpUCode); - dsp->Set("Backend", sBackend); - dsp->Set("Volume", m_Volume); - dsp->Set("CaptureLog", m_DSPCaptureLog); - -#ifdef _WIN32 - dsp->Set("WASAPIDevice", sWASAPIDevice); -#endif -} - void SConfig::SaveInputSettings(IniFile& ini) { IniFile::Section* input = ini.GetOrCreateSection("Input"); @@ -358,7 +335,6 @@ void SConfig::LoadSettings() LoadGameListSettings(ini); LoadCoreSettings(ini); LoadMovieSettings(ini); - LoadDSPSettings(ini); LoadInputSettings(ini); LoadFifoPlayerSettings(ini); LoadBluetoothPassthroughSettings(ini); @@ -470,17 +446,12 @@ void SConfig::LoadCoreSettings(IniFile& ini) #endif core->Get("JITFollowBranch", &bJITFollowBranch, true); core->Get("Fastmem", &bFastmem, true); - core->Get("DSPHLE", &bDSPHLE, true); core->Get("TimingVariance", &iTimingVariance, 40); core->Get("CPUThread", &bCPUThread, true); core->Get("SyncOnSkipIdle", &bSyncGPUOnSkipIdleHack, true); core->Get("SelectedLanguage", &SelectedLanguage, DiscIO::ToGameCubeLanguage(Config::GetDefaultLanguage())); core->Get("OverrideRegionSettings", &bOverrideRegionSettings, false); - core->Get("DPL2Decoder", &bDPL2Decoder, false); - core->Get("AudioLatency", &iLatency, 20); - core->Get("AudioStretch", &m_audio_stretch, false); - core->Get("AudioStretchMaxLatency", &m_audio_stretch_max_latency, 80); core->Get("AgpCartAPath", &m_strGbaCartA); core->Get("AgpCartBPath", &m_strGbaCartB); core->Get("SlotA", (int*)&m_EXIDevice[0], ExpansionInterface::EXIDEVICE_MEMORYCARDFOLDER); @@ -538,25 +509,6 @@ void SConfig::LoadMovieSettings(IniFile& ini) movie->Get("ShowRTC", &m_ShowRTC, false); } -void SConfig::LoadDSPSettings(IniFile& ini) -{ - IniFile::Section* dsp = ini.GetOrCreateSection("DSP"); - - dsp->Get("EnableJIT", &m_DSPEnableJIT, true); - dsp->Get("DumpAudio", &m_DumpAudio, false); - dsp->Get("DumpAudioSilent", &m_DumpAudioSilent, false); - dsp->Get("DumpUCode", &m_DumpUCode, false); - dsp->Get("Backend", &sBackend, AudioCommon::GetDefaultSoundBackend()); - dsp->Get("Volume", &m_Volume, 100); - dsp->Get("CaptureLog", &m_DSPCaptureLog, false); - -#ifdef _WIN32 - dsp->Get("WASAPIDevice", &sWASAPIDevice, "default"); -#endif - - m_IsMuted = false; -} - void SConfig::LoadInputSettings(IniFile& ini) { IniFile::Section* input = ini.GetOrCreateSection("Input"); @@ -749,7 +701,6 @@ void SConfig::LoadDefaults() bCPUThread = false; bSyncGPUOnSkipIdleHack = true; bRunCompareServer = false; - bDSPHLE = true; bFastmem = true; bFloatExceptions = false; bDivideByZeroExceptions = false; @@ -764,10 +715,6 @@ void SConfig::LoadDefaults() SelectedLanguage = 0; bOverrideRegionSettings = false; bWii = false; - bDPL2Decoder = false; - iLatency = 20; - m_audio_stretch = false; - m_audio_stretch_max_latency = 80; bLoopFifoReplay = true; @@ -1057,8 +1004,3 @@ IniFile SConfig::LoadGameIni(const std::string& id, std::optional revision) game_ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + filename, true); return game_ini; } - -bool SConfig::ShouldUseDPL2Decoder() const -{ - return bDPL2Decoder && !bDSPHLE; -} diff --git a/Source/Core/Core/ConfigManager.h b/Source/Core/Core/ConfigManager.h index 4ed0924b4f..6f4bfdc690 100644 --- a/Source/Core/Core/ConfigManager.h +++ b/Source/Core/Core/ConfigManager.h @@ -47,15 +47,6 @@ enum SIDevices : int; struct BootParameters; -// DSP Backend Types -#define BACKEND_NULLSOUND _trans("No Audio Output") -#define BACKEND_ALSA "ALSA" -#define BACKEND_CUBEB "Cubeb" -#define BACKEND_OPENAL "OpenAL" -#define BACKEND_PULSEAUDIO "Pulse" -#define BACKEND_OPENSLES "OpenSLES" -#define BACKEND_WASAPI _trans("WASAPI (Exclusive Mode)") - enum class GPUDeterminismMode { Auto, @@ -116,17 +107,10 @@ struct SConfig int iTimingVariance = 40; // in milli secounds bool bCPUThread = true; - bool bDSPThread = false; - bool bDSPHLE = true; bool bSyncGPUOnSkipIdleHack = true; bool bHLE_BS2 = true; bool bCopyWiiSaveNetplay = true; - bool bDPL2Decoder = false; - int iLatency = 20; - bool m_audio_stretch = false; - int m_audio_stretch_max_latency = 80; - bool bRunCompareServer = false; bool bRunCompareClient = false; @@ -176,9 +160,6 @@ struct SConfig bool bEnableCustomRTC; u32 m_customRTCValue; - // DPL2 - bool ShouldUseDPL2Decoder() const; - DiscIO::Region m_region; std::string m_strGPUDeterminismMode; @@ -299,21 +280,6 @@ struct SConfig bool m_PauseOnFocusLost; - // DSP settings - bool m_DSPEnableJIT; - bool m_DSPCaptureLog; - bool m_DumpAudio; - bool m_DumpAudioSilent; - bool m_IsMuted; - bool m_DumpUCode; - int m_Volume; - std::string sBackend; - -#ifdef _WIN32 - // WSAPI settings - std::string sWASAPIDevice; -#endif - // Input settings bool m_BackgroundInput; bool m_AdapterRumble[4]; @@ -347,7 +313,6 @@ private: void SaveInterfaceSettings(IniFile& ini); void SaveGameListSettings(IniFile& ini); void SaveCoreSettings(IniFile& ini); - void SaveDSPSettings(IniFile& ini); void SaveInputSettings(IniFile& ini); void SaveMovieSettings(IniFile& ini); void SaveFifoPlayerSettings(IniFile& ini); @@ -360,7 +325,6 @@ private: void LoadInterfaceSettings(IniFile& ini); void LoadGameListSettings(IniFile& ini); void LoadCoreSettings(IniFile& ini); - void LoadDSPSettings(IniFile& ini); void LoadInputSettings(IniFile& ini); void LoadMovieSettings(IniFile& ini); void LoadFifoPlayerSettings(IniFile& ini); diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index 96a3aab34e..0f252402c9 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -38,6 +38,7 @@ #include "Core/Boot/Boot.h" #include "Core/BootManager.h" +#include "Core/Config/MainSettings.h" #include "Core/ConfigManager.h" #include "Core/CoreTiming.h" #include "Core/DSPEmulator.h" @@ -565,11 +566,11 @@ static void EmuThread(std::unique_ptr boot, WindowSystemInfo wsi g_renderer->EndUIFrame(); if (cpu_info.HTT) - SConfig::GetInstance().bDSPThread = cpu_info.num_cores > 4; + Config::SetBaseOrCurrent(Config::MAIN_DSP_THREAD, cpu_info.num_cores > 4); else - SConfig::GetInstance().bDSPThread = cpu_info.num_cores > 2; + Config::SetBaseOrCurrent(Config::MAIN_DSP_THREAD, cpu_info.num_cores > 2); - if (!DSP::GetDSPEmulator()->Initialize(core_parameter.bWii, core_parameter.bDSPThread)) + if (!DSP::GetDSPEmulator()->Initialize(core_parameter.bWii, Config::Get(Config::MAIN_DSP_THREAD))) { PanicAlertFmt("Failed to initialize DSP emulation!"); return; @@ -921,9 +922,9 @@ void UpdateTitle(u32 ElapseTime) (VideoInterface::GetTargetRefreshRate() * ElapseTime)); // Settings are shown the same for both extended and summary info - const std::string SSettings = - fmt::format("{} {} | {} | {}", PowerPC::GetCPUName(), _CoreParameter.bCPUThread ? "DC" : "SC", - g_video_backend->GetDisplayName(), _CoreParameter.bDSPHLE ? "HLE" : "LLE"); + const std::string SSettings = fmt::format( + "{} {} | {} | {}", PowerPC::GetCPUName(), _CoreParameter.bCPUThread ? "DC" : "SC", + g_video_backend->GetDisplayName(), Config::Get(Config::MAIN_DSP_HLE) ? "HLE" : "LLE"); std::string SFPS; if (Movie::IsPlayingInput()) diff --git a/Source/Core/Core/DolphinAnalytics.cpp b/Source/Core/Core/DolphinAnalytics.cpp index 3689e158be..7b324af174 100644 --- a/Source/Core/Core/DolphinAnalytics.cpp +++ b/Source/Core/Core/DolphinAnalytics.cpp @@ -353,13 +353,13 @@ void DolphinAnalytics::MakePerGameBuilder() builder.AddData("id", MakeUniqueId(SConfig::GetInstance().GetGameID())); // Configuration. - builder.AddData("cfg-dsp-hle", SConfig::GetInstance().bDSPHLE); - builder.AddData("cfg-dsp-jit", SConfig::GetInstance().m_DSPEnableJIT); - builder.AddData("cfg-dsp-thread", SConfig::GetInstance().bDSPThread); + builder.AddData("cfg-dsp-hle", Config::Get(Config::MAIN_DSP_HLE)); + builder.AddData("cfg-dsp-jit", Config::Get(Config::MAIN_DSP_JIT)); + builder.AddData("cfg-dsp-thread", Config::Get(Config::MAIN_DSP_THREAD)); builder.AddData("cfg-cpu-thread", SConfig::GetInstance().bCPUThread); builder.AddData("cfg-fastmem", SConfig::GetInstance().bFastmem); builder.AddData("cfg-syncgpu", SConfig::GetInstance().bSyncGPU); - builder.AddData("cfg-audio-backend", SConfig::GetInstance().sBackend); + builder.AddData("cfg-audio-backend", Config::Get(Config::MAIN_AUDIO_BACKEND)); builder.AddData("cfg-oc-enable", SConfig::GetInstance().m_OCEnable); builder.AddData("cfg-oc-factor", SConfig::GetInstance().m_OCFactor); builder.AddData("cfg-render-to-main", Config::Get(Config::MAIN_RENDER_TO_MAIN)); diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/ROM.cpp b/Source/Core/Core/HW/DSPHLE/UCodes/ROM.cpp index b99da60d52..e41a5b19c0 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/ROM.cpp +++ b/Source/Core/Core/HW/DSPHLE/UCodes/ROM.cpp @@ -13,6 +13,7 @@ #include "Common/CommonTypes.h" #include "Common/Hash.h" #include "Common/Logging/Log.h" +#include "Core/Config/MainSettings.h" #include "Core/ConfigManager.h" #include "Core/DSP/DSPCodeUtil.h" #include "Core/HW/DSPHLE/DSPHLE.h" @@ -102,7 +103,7 @@ void ROMUCode::BootUCode() Common::HashEctor(static_cast(HLEMemory_Get_Pointer(m_current_ucode.m_ram_address)), m_current_ucode.m_length); - if (SConfig::GetInstance().m_DumpUCode) + if (Config::Get(Config::MAIN_DUMP_UCODE)) { DSP::DumpDSPCode(static_cast(HLEMemory_Get_Pointer(m_current_ucode.m_ram_address)), m_current_ucode.m_length, ector_crc); diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/UCodes.cpp b/Source/Core/Core/HW/DSPHLE/UCodes/UCodes.cpp index 7af03c0c52..3c31d61ffa 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/UCodes.cpp +++ b/Source/Core/Core/HW/DSPHLE/UCodes/UCodes.cpp @@ -16,6 +16,7 @@ #include "Common/Hash.h" #include "Common/Logging/Log.h" #include "Common/Swap.h" +#include "Core/Config/MainSettings.h" #include "Core/ConfigManager.h" #include "Core/DSP/DSPCodeUtil.h" #include "Core/HW/DSPHLE/DSPHLE.h" @@ -183,7 +184,7 @@ void UCodeInterface::PrepareBootUCode(u32 mail) Common::HashEctor(static_cast(HLEMemory_Get_Pointer(m_next_ucode.iram_mram_addr)), m_next_ucode.iram_size); - if (SConfig::GetInstance().m_DumpUCode) + if (Config::Get(Config::MAIN_DUMP_UCODE)) { DSP::DumpDSPCode(Memory::GetPointer(m_next_ucode.iram_mram_addr), m_next_ucode.iram_size, ector_crc); diff --git a/Source/Core/Core/HW/DSPLLE/DSPHost.cpp b/Source/Core/Core/HW/DSPLLE/DSPHost.cpp index 26b3b37035..b55b5b4ca3 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPHost.cpp +++ b/Source/Core/Core/HW/DSPLLE/DSPHost.cpp @@ -8,6 +8,7 @@ #include "Common/CommonTypes.h" #include "Common/Hash.h" #include "Common/Logging/Log.h" +#include "Core/Config/MainSettings.h" #include "Core/ConfigManager.h" #include "Core/DSP/DSPAnalyzer.h" #include "Core/DSP/DSPCodeUtil.h" @@ -53,7 +54,7 @@ void OSD_AddMessage(std::string str, u32 ms) bool OnThread() { - return SConfig::GetInstance().bDSPThread; + return Config::Get(Config::MAIN_DSP_THREAD); } bool IsWiiHost() @@ -78,7 +79,7 @@ void CodeLoaded(DSPCore& dsp, const u8* ptr, size_t size) const u32 iram_crc = Common::HashEctor(ptr, size); state.SetIRAMCRC(iram_crc); - if (SConfig::GetInstance().m_DumpUCode) + if (Config::Get(Config::MAIN_DUMP_UCODE)) { DSP::DumpDSPCode(ptr, size, iram_crc); } diff --git a/Source/Core/Core/HW/DSPLLE/DSPLLE.cpp b/Source/Core/Core/HW/DSPLLE/DSPLLE.cpp index 07efb5b5ad..ebe529bfe7 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPLLE.cpp +++ b/Source/Core/Core/HW/DSPLLE/DSPLLE.cpp @@ -15,6 +15,7 @@ #include "Common/Logging/Log.h" #include "Common/MemoryUtil.h" #include "Common/Thread.h" +#include "Core/Config/MainSettings.h" #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/DSP/DSPAccelerator.h" @@ -120,11 +121,11 @@ static bool FillDSPInitOptions(DSPInitOptions* opts) opts->core_type = DSPInitOptions::CoreType::Interpreter; #ifdef _M_X86 - if (SConfig::GetInstance().m_DSPEnableJIT) + if (Config::Get(Config::MAIN_DSP_JIT)) opts->core_type = DSPInitOptions::CoreType::JIT64; #endif - if (SConfig::GetInstance().m_DSPCaptureLog) + if (Config::Get(Config::MAIN_DSP_CAPTURE_LOG)) { const std::string pcap_path = File::GetUserPath(D_DUMPDSP_IDX) + "dsp.pcap"; opts->capture_logger = new PCAPDSPCaptureLogger(pcap_path); @@ -263,7 +264,7 @@ void DSPLLE::DSP_Update(int cycles) DSP_StopSoundStream(); m_is_dsp_on_thread = false; m_request_disable_thread = false; - SConfig::GetInstance().bDSPThread = false; + Config::SetBaseOrCurrent(Config::MAIN_DSP_THREAD, false); } } diff --git a/Source/Core/Core/HW/HW.cpp b/Source/Core/Core/HW/HW.cpp index aefafc085d..828e1d2c71 100644 --- a/Source/Core/Core/HW/HW.cpp +++ b/Source/Core/Core/HW/HW.cpp @@ -6,6 +6,7 @@ #include "Common/ChunkFile.h" #include "Common/CommonTypes.h" +#include "Core/Config/MainSettings.h" #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/CoreTiming.h" @@ -42,7 +43,7 @@ void Init() ExpansionInterface::Init(); // Needs to be initialized before Memory Memory::Init(); // Needs to be initialized before AddressSpace AddressSpace::Init(); - DSP::Init(SConfig::GetInstance().bDSPHLE); + DSP::Init(Config::Get(Config::MAIN_DSP_HLE)); DVDInterface::Init(); GPFifo::Init(); CPU::Init(SConfig::GetInstance().cpu_core); diff --git a/Source/Core/Core/IOS/MIOS.cpp b/Source/Core/Core/IOS/MIOS.cpp index 7150aea600..a532718420 100644 --- a/Source/Core/Core/IOS/MIOS.cpp +++ b/Source/Core/Core/IOS/MIOS.cpp @@ -11,6 +11,7 @@ #include "Common/Logging/Log.h" #include "Common/MsgHandler.h" #include "Common/Swap.h" +#include "Core/Config/MainSettings.h" #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/DSPEmulator.h" @@ -40,8 +41,9 @@ static void ReinitHardware() PowerPC::Reset(); Wiimote::ResetAllWiimotes(); // Note: this is specific to Dolphin and is required because we initialised it in Wii mode. - DSP::Reinit(SConfig::GetInstance().bDSPHLE); - DSP::GetDSPEmulator()->Initialize(SConfig::GetInstance().bWii, SConfig::GetInstance().bDSPThread); + DSP::Reinit(Config::Get(Config::MAIN_DSP_HLE)); + DSP::GetDSPEmulator()->Initialize(SConfig::GetInstance().bWii, + Config::Get(Config::MAIN_DSP_THREAD)); SystemTimers::ChangePPCClock(SystemTimers::Mode::GC); } diff --git a/Source/Core/DolphinQt/HotkeyScheduler.cpp b/Source/Core/DolphinQt/HotkeyScheduler.cpp index c54af094ce..333562d83f 100644 --- a/Source/Core/DolphinQt/HotkeyScheduler.cpp +++ b/Source/Core/DolphinQt/HotkeyScheduler.cpp @@ -17,6 +17,7 @@ #include "Core/Config/FreeLookSettings.h" #include "Core/Config/GraphicsSettings.h" +#include "Core/Config/MainSettings.h" #include "Core/Config/UISettings.h" #include "Core/ConfigManager.h" #include "Core/Core.h" @@ -329,9 +330,9 @@ void HotkeyScheduler::Run() auto ShowVolume = []() { OSD::AddMessage(std::string("Volume: ") + - (SConfig::GetInstance().m_IsMuted ? + (Config::Get(Config::MAIN_AUDIO_MUTED) ? "Muted" : - std::to_string(SConfig::GetInstance().m_Volume) + "%")); + std::to_string(Config::Get(Config::MAIN_AUDIO_VOLUME)) + "%")); }; // Volume diff --git a/Source/Core/DolphinQt/MenuBar.cpp b/Source/Core/DolphinQt/MenuBar.cpp index 7ac7029247..48a18dbbb0 100644 --- a/Source/Core/DolphinQt/MenuBar.cpp +++ b/Source/Core/DolphinQt/MenuBar.cpp @@ -22,6 +22,7 @@ #include "Common/CDUtils.h" #include "Core/Boot/Boot.h" #include "Core/CommonTitles.h" +#include "Core/Config/MainSettings.h" #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/Debugger/RSO.h" @@ -789,9 +790,9 @@ void MenuBar::AddMovieMenu() auto* dump_audio = movie_menu->addAction(tr("Dump Audio")); dump_audio->setCheckable(true); - dump_audio->setChecked(SConfig::GetInstance().m_DumpAudio); + dump_audio->setChecked(Config::Get(Config::MAIN_DUMP_AUDIO)); connect(dump_audio, &QAction::toggled, - [](bool value) { SConfig::GetInstance().m_DumpAudio = value; }); + [](bool value) { Config::SetBaseOrCurrent(Config::MAIN_DUMP_AUDIO, value); }); } void MenuBar::AddJITMenu() diff --git a/Source/Core/DolphinQt/Settings.cpp b/Source/Core/DolphinQt/Settings.cpp index 3958a9a255..0232929e52 100644 --- a/Source/Core/DolphinQt/Settings.cpp +++ b/Source/Core/DolphinQt/Settings.cpp @@ -365,14 +365,14 @@ bool Settings::IsKeepWindowOnTopEnabled() const int Settings::GetVolume() const { - return SConfig::GetInstance().m_Volume; + return Config::Get(Config::MAIN_AUDIO_VOLUME); } void Settings::SetVolume(int volume) { if (GetVolume() != volume) { - SConfig::GetInstance().m_Volume = volume; + Config::SetBaseOrCurrent(Config::MAIN_AUDIO_VOLUME, volume); emit VolumeChanged(volume); } } diff --git a/Source/Core/DolphinQt/Settings/AudioPane.cpp b/Source/Core/DolphinQt/Settings/AudioPane.cpp index 723a1cf697..f6f2629fe3 100644 --- a/Source/Core/DolphinQt/Settings/AudioPane.cpp +++ b/Source/Core/DolphinQt/Settings/AudioPane.cpp @@ -22,7 +22,6 @@ #include "AudioCommon/WASAPIStream.h" #include "Core/Config/MainSettings.h" -#include "Core/ConfigManager.h" #include "Core/Core.h" #include "DolphinQt/Config/SettingsWindow.h" @@ -200,18 +199,18 @@ void AudioPane::LoadSettings() auto& settings = Settings::Instance(); // DSP - if (SConfig::GetInstance().bDSPHLE) + if (Config::Get(Config::MAIN_DSP_HLE)) { m_dsp_hle->setChecked(true); } else { - m_dsp_lle->setChecked(SConfig::GetInstance().m_DSPEnableJIT); - m_dsp_interpreter->setChecked(!SConfig::GetInstance().m_DSPEnableJIT); + m_dsp_lle->setChecked(Config::Get(Config::MAIN_DSP_JIT)); + m_dsp_interpreter->setChecked(!Config::Get(Config::MAIN_DSP_JIT)); } // Backend - const auto current = SConfig::GetInstance().sBackend; + const auto current = Config::Get(Config::MAIN_AUDIO_BACKEND); bool selection_set = false; for (const auto& backend : AudioCommon::GetSoundBackends()) { @@ -231,7 +230,7 @@ void AudioPane::LoadSettings() OnVolumeChanged(settings.GetVolume()); // DPL2 - m_dolby_pro_logic->setChecked(SConfig::GetInstance().bDPL2Decoder); + m_dolby_pro_logic->setChecked(Config::Get(Config::MAIN_DPL2_DECODER)); m_dolby_quality_slider->setValue(int(Config::Get(Config::MAIN_DPL2_QUALITY))); m_dolby_quality_latency_label->setText( GetDPL2ApproximateLatencyLabel(Config::Get(Config::MAIN_DPL2_QUALITY))); @@ -242,23 +241,23 @@ void AudioPane::LoadSettings() // Latency if (m_latency_control_supported) - m_latency_spin->setValue(SConfig::GetInstance().iLatency); + m_latency_spin->setValue(Config::Get(Config::MAIN_AUDIO_LATENCY)); // Stretch - m_stretching_enable->setChecked(SConfig::GetInstance().m_audio_stretch); - m_stretching_buffer_slider->setValue(SConfig::GetInstance().m_audio_stretch_max_latency); + m_stretching_enable->setChecked(Config::Get(Config::MAIN_AUDIO_STRETCH)); + m_stretching_buffer_slider->setValue(Config::Get(Config::MAIN_AUDIO_STRETCH_LATENCY)); m_stretching_buffer_slider->setEnabled(m_stretching_enable->isChecked()); m_stretching_buffer_indicator->setText(tr("%1 ms").arg(m_stretching_buffer_slider->value())); #ifdef _WIN32 - if (SConfig::GetInstance().sWASAPIDevice == "default") + if (Config::Get(Config::MAIN_WASAPI_DEVICE) == "default") { m_wasapi_device_combo->setCurrentIndex(0); } else { m_wasapi_device_combo->setCurrentText( - QString::fromStdString(SConfig::GetInstance().sWASAPIDevice)); + QString::fromStdString(Config::Get(Config::MAIN_WASAPI_DEVICE))); } #endif } @@ -268,24 +267,23 @@ void AudioPane::SaveSettings() auto& settings = Settings::Instance(); // DSP - if (SConfig::GetInstance().bDSPHLE != m_dsp_hle->isChecked() || - SConfig::GetInstance().m_DSPEnableJIT != m_dsp_lle->isChecked()) + if (Config::Get(Config::MAIN_DSP_HLE) != m_dsp_hle->isChecked() || + Config::Get(Config::MAIN_DSP_JIT) != m_dsp_lle->isChecked()) { OnDspChanged(); } - SConfig::GetInstance().bDSPHLE = m_dsp_hle->isChecked(); Config::SetBaseOrCurrent(Config::MAIN_DSP_HLE, m_dsp_hle->isChecked()); - SConfig::GetInstance().m_DSPEnableJIT = m_dsp_lle->isChecked(); Config::SetBaseOrCurrent(Config::MAIN_DSP_JIT, m_dsp_lle->isChecked()); // Backend const auto selection = m_backend_combo->itemData(m_backend_combo->currentIndex()).toString().toStdString(); - auto& backend = SConfig::GetInstance().sBackend; + std::string backend = Config::Get(Config::MAIN_AUDIO_BACKEND); if (selection != backend) { backend = selection; + Config::SetBaseOrCurrent(Config::MAIN_AUDIO_BACKEND, selection); OnBackendChanged(); } @@ -297,7 +295,7 @@ void AudioPane::SaveSettings() } // DPL2 - SConfig::GetInstance().bDPL2Decoder = m_dolby_pro_logic->isChecked(); + Config::SetBaseOrCurrent(Config::MAIN_DPL2_DECODER, m_dolby_pro_logic->isChecked()); Config::SetBase(Config::MAIN_DPL2_QUALITY, static_cast(m_dolby_quality_slider->value())); m_dolby_quality_latency_label->setText( @@ -309,16 +307,16 @@ void AudioPane::SaveSettings() // Latency if (m_latency_control_supported) - SConfig::GetInstance().iLatency = m_latency_spin->value(); + Config::SetBaseOrCurrent(Config::MAIN_AUDIO_LATENCY, m_latency_spin->value()); // Stretch - SConfig::GetInstance().m_audio_stretch = m_stretching_enable->isChecked(); - SConfig::GetInstance().m_audio_stretch_max_latency = m_stretching_buffer_slider->value(); + Config::SetBaseOrCurrent(Config::MAIN_AUDIO_STRETCH, m_stretching_enable->isChecked()); + Config::SetBaseOrCurrent(Config::MAIN_AUDIO_STRETCH_LATENCY, m_stretching_buffer_slider->value()); m_stretching_buffer_label->setEnabled(m_stretching_enable->isChecked()); m_stretching_buffer_slider->setEnabled(m_stretching_enable->isChecked()); m_stretching_buffer_indicator->setEnabled(m_stretching_enable->isChecked()); m_stretching_buffer_indicator->setText( - tr("%1 ms").arg(SConfig::GetInstance().m_audio_stretch_max_latency)); + tr("%1 ms").arg(Config::Get(Config::MAIN_AUDIO_STRETCH_LATENCY))); #ifdef _WIN32 std::string device = "default"; @@ -326,7 +324,7 @@ void AudioPane::SaveSettings() if (m_wasapi_device_combo->currentIndex() != 0) device = m_wasapi_device_combo->currentText().toStdString(); - SConfig::GetInstance().sWASAPIDevice = device; + Config::SetBaseOrCurrent(Config::MAIN_WASAPI_DEVICE, device); #endif AudioCommon::UpdateSoundStream(); @@ -334,7 +332,7 @@ void AudioPane::SaveSettings() void AudioPane::OnDspChanged() { - const auto backend = SConfig::GetInstance().sBackend; + const auto backend = Config::Get(Config::MAIN_AUDIO_BACKEND); m_dolby_pro_logic->setEnabled(AudioCommon::SupportsDPL2Decoder(backend) && !m_dsp_hle->isChecked()); @@ -344,7 +342,7 @@ void AudioPane::OnDspChanged() void AudioPane::OnBackendChanged() { - const auto backend = SConfig::GetInstance().sBackend; + const auto backend = Config::Get(Config::MAIN_AUDIO_BACKEND); m_dolby_pro_logic->setEnabled(AudioCommon::SupportsDPL2Decoder(backend) && !m_dsp_hle->isChecked()); @@ -382,13 +380,14 @@ void AudioPane::OnEmulationStateChanged(bool running) m_dsp_interpreter->setEnabled(!running); m_backend_label->setEnabled(!running); m_backend_combo->setEnabled(!running); - if (AudioCommon::SupportsDPL2Decoder(SConfig::GetInstance().sBackend) && !m_dsp_hle->isChecked()) + if (AudioCommon::SupportsDPL2Decoder(Config::Get(Config::MAIN_AUDIO_BACKEND)) && + !m_dsp_hle->isChecked()) { m_dolby_pro_logic->setEnabled(!running); EnableDolbyQualityWidgets(!running && m_dolby_pro_logic->isChecked()); } if (m_latency_control_supported && - AudioCommon::SupportsLatencyControl(SConfig::GetInstance().sBackend)) + AudioCommon::SupportsLatencyControl(Config::Get(Config::MAIN_AUDIO_BACKEND))) { m_latency_label->setEnabled(!running); m_latency_spin->setEnabled(!running);