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

@ -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<REFERENCE_TIME>(
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<s16*>(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;