diff --git a/Externals/FreeSurround/source/FreeSurroundDecoder.cpp b/Externals/FreeSurround/source/FreeSurroundDecoder.cpp index d07d763eb6c1..07a456a2198b 100644 --- a/Externals/FreeSurround/source/FreeSurroundDecoder.cpp +++ b/Externals/FreeSurround/source/FreeSurroundDecoder.cpp @@ -92,7 +92,7 @@ void DPL2FSDecoder::Init(channel_setup chsetup, unsigned int blsize, memcpy(&outbuf[i], &outbuf[prev_size - C], sizeof(float) * C); } } - for (unsigned int k = 0; k < std::min(C, unsigned int(signal.size())); k++) + for (unsigned int k = 0; k < std::min(C, static_cast(signal.size())); k++) signal[k].resize(N); signal.resize(C, std::vector(N)); 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..fe178f360fa2 100644 --- a/Source/Core/AudioCommon/Mixer.cpp +++ b/Source/Core/AudioCommon/Mixer.cpp @@ -45,7 +45,8 @@ Mixer::Mixer(u32 sample_rate) Mixer::~Mixer() { - INFO_LOG_FMT(AUDIO_INTERFACE, "Mixer is initialized"); + INFO_LOG_FMT(AUDIO_INTERFACE, "Mixer is uninitialized"); + Core::RemoveOnStateChangedCallback(&m_on_state_changed_handle); } void Mixer::SetPaused(bool paused) diff --git a/Source/Core/AudioCommon/Mixer.h b/Source/Core/AudioCommon/Mixer.h index 7a82615f9a5f..05f51c8cbf76 100644 --- a/Source/Core/AudioCommon/Mixer.h +++ b/Source/Core/AudioCommon/Mixer.h @@ -89,8 +89,8 @@ class Mixer final { public: MixerFifo(Mixer* mixer, unsigned sample_rate, bool big_endians, bool constantly_pushed = true) - : m_mixer(mixer), m_input_sample_rate(sample_rate), - m_big_endians(big_endians), m_constantly_pushed(constantly_pushed) + : m_mixer(mixer), m_input_sample_rate(sample_rate), m_constantly_pushed(constantly_pushed), + m_big_endians(big_endians) { } void DoState(PointerWrap& p); @@ -191,7 +191,7 @@ class Mixer final u32 m_sample_rate; // Only changed by main or emulation thread when the backend is not running bool m_stretching = false; - bool m_update_surround_latency = false; + bool m_update_surround_latency = false; //To delete? AudioCommon::AudioStretcher m_stretcher; AudioCommon::SurroundDecoder m_surround_decoder; 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, diff --git a/Source/Core/DolphinLib.props b/Source/Core/DolphinLib.props index 13c155801fd7..66411947d2fb 100644 --- a/Source/Core/DolphinLib.props +++ b/Source/Core/DolphinLib.props @@ -2,6 +2,7 @@ + @@ -667,12 +668,14 @@ + +