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.
This commit is contained in:
sowens99
2021-10-13 20:29:04 -04:00
parent 023eb0b702
commit 8ea6bef98f
26 changed files with 132 additions and 205 deletions

View File

@ -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<SoundStream> 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