From a49f4f0f62bedf06a2fd8aff27fd2175fa6f7a0d Mon Sep 17 00:00:00 2001 From: Filoppi Date: Fri, 14 May 2021 13:31:45 +0300 Subject: [PATCH] Post merge fixup --- Source/Core/AudioCommon/AudioCommon.cpp | 53 ++++++------------- Source/Core/AudioCommon/Mixer.cpp | 2 +- .../Core/ConfigLoaders/IsSettingSaveable.cpp | 6 +-- Source/Core/Core/HW/AudioInterface.cpp | 3 +- Source/Core/Core/HW/WiimoteEmu/Speaker.cpp | 4 +- Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp | 1 - Source/Core/Core/State.cpp | 2 +- 7 files changed, 23 insertions(+), 48 deletions(-) diff --git a/Source/Core/AudioCommon/AudioCommon.cpp b/Source/Core/AudioCommon/AudioCommon.cpp index 5852868d9c04..383bec5076fa 100644 --- a/Source/Core/AudioCommon/AudioCommon.cpp +++ b/Source/Core/AudioCommon/AudioCommon.cpp @@ -60,49 +60,33 @@ static std::unique_ptr CreateSoundStreamForBackend(std::string_view void InitSoundStream() { + std::lock_guard guard(g_sound_stream_mutex); + + std::string backend = SConfig::GetInstance().sBackend; + g_sound_stream = CreateSoundStreamForBackend(backend); + g_selected_sound_stream_failed = false; + + if (!g_sound_stream) { - WARN_LOG_FMT(AUDIO, "Unknown backend {}, using {} instead.", backend, GetDefaultSoundBackend()); + WARN_LOG_FMT(AUDIO, "Unknown backend {}, using {} instead (default)", backend, + GetDefaultSoundBackend()); backend = GetDefaultSoundBackend(); - g_sound_stream = CreateSoundStreamForBackend(GetDefaultSoundBackend()); + g_sound_stream = CreateSoundStreamForBackend(backend); } if (!g_sound_stream || !g_sound_stream->Init()) { - WARN_LOG_FMT(AUDIO, "Could not initialize backend {}, using {} instead.", backend, - BACKEND_NULLSOUND); + WARN_LOG_FMT(AUDIO, "Could not initialize backend {}, using {} instead", backend, + NullSound::GetName()); g_sound_stream = std::make_unique(); - g_sound_stream->Init(); + g_sound_stream->Init(); // NullSound can't fail + g_selected_sound_stream_failed = true; } } +// This needs to be called after AudioInterface::Init where input sample rates are set void PostInitSoundStream() { - // This needs to be called after AudioInterface::Init where input sample rates are set - UpdateSoundStream(); - std::lock_guard guard(g_sound_stream_mutex); - - std::string backend = SConfig::GetInstance().sBackend; - g_sound_stream = CreateSoundStreamForBackend(backend); - g_selected_sound_stream_failed = false; - - if (!g_sound_stream) - { - WARN_LOG_FMT(AUDIO, "Unknown backend {}, using {} instead (default)", backend, - GetDefaultSoundBackend()); - backend = GetDefaultSoundBackend(); - g_sound_stream = CreateSoundStreamForBackend(backend); - } - - if (!g_sound_stream || !g_sound_stream->Init()) - { - WARN_LOG_FMT(AUDIO, "Could not initialize backend {}, using {} instead", backend, - NullSound::GetName()); - g_sound_stream = std::make_unique(); - g_sound_stream->Init(); // NullSound can't fail - g_selected_sound_stream_failed = true; - } - } - UpdateSoundStreamSettings(true); // This can fail, but we don't really care as it just won't produce any sounds, // also the user might be able to fix it up by changing their device settings @@ -111,13 +95,6 @@ void PostInitSoundStream() // and true again, so basically the backend is "restarted" with every emulation state change SetSoundStreamRunning(true, true); - //To review: are these still needed after merge with master? - // Ideally these two calls would be done in AudioInterface::Init so that we don't - // need to have a dependency on AudioInterface here, but this has to be done - // after creating g_sound_stream (above) and before starting audio dumping (below) - g_sound_stream->GetMixer()->SetDMAInputSampleRate(AudioInterface::GetAIDSampleRate()); - g_sound_stream->GetMixer()->SetStreamingInputSampleRate(AudioInterface::GetAISSampleRate()); - if (SConfig::GetInstance().m_DumpAudio && !s_audio_dump_started) StartAudioDump(); } diff --git a/Source/Core/AudioCommon/Mixer.cpp b/Source/Core/AudioCommon/Mixer.cpp index a1fbd1ec6a90..6f74197ed31e 100644 --- a/Source/Core/AudioCommon/Mixer.cpp +++ b/Source/Core/AudioCommon/Mixer.cpp @@ -45,7 +45,7 @@ Mixer::Mixer(u32 sample_rate) Mixer::~Mixer() { - INFO_LOG_FMT(AUDIO_INTERFACE, "Mixer is initialized"); + INFO_LOG_FMT(AUDIO_INTERFACE, "Mixer is uninitialized"); } void Mixer::SetPaused(bool paused) diff --git a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp index 3bc100b87278..82fa831e6027 100644 --- a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp +++ b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp @@ -44,9 +44,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_DPL2_BASS_REDIRECTION.location, - &Config::MAIN_AUDIO_MIXER_MIN_LATENCY.location, - &Config::MAIN_AUDIO_MIXER_MAX_LATENCY.location, + &Config::MAIN_DPL2_BASS_REDIRECTION.GetLocation(), + &Config::MAIN_AUDIO_MIXER_MIN_LATENCY.GetLocation(), + &Config::MAIN_AUDIO_MIXER_MAX_LATENCY.GetLocation(), &Config::MAIN_RAM_OVERRIDE_ENABLE.GetLocation(), &Config::MAIN_MEM1_SIZE.GetLocation(), &Config::MAIN_MEM2_SIZE.GetLocation(), diff --git a/Source/Core/Core/HW/AudioInterface.cpp b/Source/Core/Core/HW/AudioInterface.cpp index 1f9b3de53adf..d7ee6e07d501 100644 --- a/Source/Core/Core/HW/AudioInterface.cpp +++ b/Source/Core/Core/HW/AudioInterface.cpp @@ -154,9 +154,8 @@ void Init() event_type_ai = CoreTiming::RegisterEvent("AICallback", Update); - //To review: this is now duplicate? g_sound_stream->GetMixer()->SetDMAInputSampleRate(GetAIDSampleRate()); - g_sound_stream->GetMixer()->SetStreamInputSampleRate(GetAISSampleRate()); + g_sound_stream->GetMixer()->SetStreamingInputSampleRate(GetAISSampleRate()); } void Shutdown() diff --git a/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp b/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp index 1a9e9fb34208..c7c59361aee4 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp @@ -91,7 +91,7 @@ void stopdamnwav() } #endif -void SpeakerLogic::SpeakerData(const u8* data, int length) +void SpeakerLogic::SpeakerData(const u8* data, int length, float speaker_pan) { if (reg_data.sample_rate == 0 || length == 0) return; @@ -174,7 +174,7 @@ void SpeakerLogic::SpeakerData(const u8* data, int length) // We should play the samples from the wiimote at the native volume they came with, // because you can lower their volume from the wii settings, and because they are // already extremely low quality, so any additional quality loss isn't welcome. - float speaker_pan = std::clamp(float(m_speaker_pan_setting.GetValue()) / 100, -1.f, 1.f); + speaker_pan = std::clamp(speaker_pan, -1.f, 1.f); const u32 l_volume = std::min(u32(std::min(1.f - speaker_pan, 1.f) * volume), 255u); const u32 r_volume = std::min(u32(std::min(1.f + speaker_pan, 1.f) * volume), 255u); diff --git a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp index a62116779d82..c5ddfb225506 100644 --- a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp @@ -166,7 +166,6 @@ void Wiimote::Reset() m_i2c_bus.AddSlave(&m_speaker_logic); m_i2c_bus.AddSlave(&m_camera_logic); - //To review: is this needed now? m_speaker_logic.m_index = m_index; // Reset extension connections to NONE: diff --git a/Source/Core/Core/State.cpp b/Source/Core/Core/State.cpp index 876e94773826..8e832d8e2896 100644 --- a/Source/Core/Core/State.cpp +++ b/Source/Core/Core/State.cpp @@ -74,7 +74,7 @@ static Common::Event g_compressAndDumpStateSyncEvent; static std::thread g_save_thread; // Don't forget to increase this after doing changes on the savestate system -constexpr u32 STATE_VERSION = 131; // Last changed in PR ???? +constexpr u32 STATE_VERSION = 130; // Last changed in PR 9545 // Maps savestate versions to Dolphin versions. // Versions after 42 don't need to be added to this list,