diff --git a/Source/Core/AudioCommon/AlsaSoundStream.cpp b/Source/Core/AudioCommon/AlsaSoundStream.cpp index a2842b5fec..6345b7646b 100644 --- a/Source/Core/AudioCommon/AlsaSoundStream.cpp +++ b/Source/Core/AudioCommon/AlsaSoundStream.cpp @@ -78,10 +78,9 @@ void AlsaSound::SoundLoop() m_thread_status.store(ALSAThreadStatus::STOPPED); } -void AlsaSound::Clear(bool muted) +void AlsaSound::SetRunning(bool running) { - m_muted = muted; - m_thread_status.store(muted ? ALSAThreadStatus::PAUSED : ALSAThreadStatus::RUNNING); + m_thread_status.store(running ? ALSAThreadStatus::RUNNING : ALSAThreadStatus::PAUSED); cv.notify_one(); // Notify thread that status has changed } diff --git a/Source/Core/AudioCommon/AlsaSoundStream.h b/Source/Core/AudioCommon/AlsaSoundStream.h index 162713f84a..dfe0faf3fb 100644 --- a/Source/Core/AudioCommon/AlsaSoundStream.h +++ b/Source/Core/AudioCommon/AlsaSoundStream.h @@ -26,7 +26,7 @@ public: void SoundLoop() override; void Stop() override; void Update() override; - void Clear(bool) override; + void SetRunning(bool running) override; static bool isValid() { return true; } private: diff --git a/Source/Core/AudioCommon/AudioCommon.cpp b/Source/Core/AudioCommon/AudioCommon.cpp index 18aa75d1ae..77da1e4c70 100644 --- a/Source/Core/AudioCommon/AudioCommon.cpp +++ b/Source/Core/AudioCommon/AudioCommon.cpp @@ -159,10 +159,10 @@ void UpdateSoundStream() } } -void ClearAudioBuffer(bool mute) +void SetSoundStreamRunning(bool running) { if (g_sound_stream) - g_sound_stream->Clear(mute); + g_sound_stream->SetRunning(running); } void SendAIBuffer(const short* samples, unsigned int num_samples) diff --git a/Source/Core/AudioCommon/AudioCommon.h b/Source/Core/AudioCommon/AudioCommon.h index 6216d9e0a2..37f1e63eb8 100644 --- a/Source/Core/AudioCommon/AudioCommon.h +++ b/Source/Core/AudioCommon/AudioCommon.h @@ -24,7 +24,7 @@ bool SupportsDPL2Decoder(const std::string& backend); bool SupportsLatencyControl(const std::string& backend); bool SupportsVolumeChanges(const std::string& backend); void UpdateSoundStream(); -void ClearAudioBuffer(bool mute); +void SetSoundStreamRunning(bool running); void SendAIBuffer(const short* samples, unsigned int num_samples); void StartAudioDump(); void StopAudioDump(); diff --git a/Source/Core/AudioCommon/NullSoundStream.cpp b/Source/Core/AudioCommon/NullSoundStream.cpp index d55c61bbc3..98f8871a80 100644 --- a/Source/Core/AudioCommon/NullSoundStream.cpp +++ b/Source/Core/AudioCommon/NullSoundStream.cpp @@ -35,11 +35,6 @@ void NullSound::Update() m_mixer->Mix(m_realtime_buffer.data(), (unsigned int)num_samples_to_render); } -void NullSound::Clear(bool mute) -{ - m_muted = mute; -} - void NullSound::Stop() { } diff --git a/Source/Core/AudioCommon/NullSoundStream.h b/Source/Core/AudioCommon/NullSoundStream.h index a3d0393e13..aec04cc096 100644 --- a/Source/Core/AudioCommon/NullSoundStream.h +++ b/Source/Core/AudioCommon/NullSoundStream.h @@ -14,7 +14,6 @@ public: void SoundLoop() override; void SetVolume(int volume) override; void Stop() override; - void Clear(bool mute) override; void Update() override; static bool isValid() { return true; } diff --git a/Source/Core/AudioCommon/OpenALStream.cpp b/Source/Core/AudioCommon/OpenALStream.cpp index 191452b7f3..ed295ff18c 100644 --- a/Source/Core/AudioCommon/OpenALStream.cpp +++ b/Source/Core/AudioCommon/OpenALStream.cpp @@ -161,17 +161,15 @@ void OpenALStream::Update() m_sound_sync_event.Set(); } -void OpenALStream::Clear(bool mute) +void OpenALStream::SetRunning(bool running) { - m_muted = mute; - - if (m_muted) + if (running) { - palSourceStop(m_source); + palSourcePlay(m_source); } else { - palSourcePlay(m_source); + palSourceStop(m_source); } } diff --git a/Source/Core/AudioCommon/OpenALStream.h b/Source/Core/AudioCommon/OpenALStream.h index 3b9364c571..69c7701de1 100644 --- a/Source/Core/AudioCommon/OpenALStream.h +++ b/Source/Core/AudioCommon/OpenALStream.h @@ -59,7 +59,7 @@ public: void SoundLoop() override; void SetVolume(int volume) override; void Stop() override; - void Clear(bool mute) override; + void SetRunning(bool running) override; void Update() override; static bool isValid(); diff --git a/Source/Core/AudioCommon/SoundStream.h b/Source/Core/AudioCommon/SoundStream.h index 22328ef923..549a89178d 100644 --- a/Source/Core/AudioCommon/SoundStream.h +++ b/Source/Core/AudioCommon/SoundStream.h @@ -13,10 +13,9 @@ class SoundStream { protected: std::unique_ptr m_mixer; - bool m_muted; public: - SoundStream() : m_mixer(new Mixer(48000)), m_muted(false) {} + SoundStream() : m_mixer(new Mixer(48000)) {} virtual ~SoundStream() {} static bool isValid() { return false; } Mixer* GetMixer() const { return m_mixer.get(); } @@ -25,6 +24,5 @@ public: virtual void SoundLoop() {} virtual void Stop() {} virtual void Update() {} - virtual void Clear(bool mute) { m_muted = mute; } - bool IsMuted() const { return m_muted; } + virtual void SetRunning(bool running) {} }; diff --git a/Source/Core/AudioCommon/XAudio2Stream.cpp b/Source/Core/AudioCommon/XAudio2Stream.cpp index 827dfdf887..b87a0e0a06 100644 --- a/Source/Core/AudioCommon/XAudio2Stream.cpp +++ b/Source/Core/AudioCommon/XAudio2Stream.cpp @@ -210,16 +210,14 @@ void XAudio2::SetVolume(int volume) m_mastering_voice->SetVolume(m_volume); } -void XAudio2::Clear(bool mute) +void XAudio2::SetRunning(bool running) { - m_muted = mute; - if (m_voice_context) { - if (m_muted) - m_voice_context->Stop(); - else + if (running) m_voice_context->Play(); + else + m_voice_context->Stop(); } } diff --git a/Source/Core/AudioCommon/XAudio2Stream.h b/Source/Core/AudioCommon/XAudio2Stream.h index 7fcb8f7b00..ce8e137097 100644 --- a/Source/Core/AudioCommon/XAudio2Stream.h +++ b/Source/Core/AudioCommon/XAudio2Stream.h @@ -59,7 +59,7 @@ public: bool Start() override; void Stop() override; - void Clear(bool mute) override; + void SetRunning(bool running) override; void SetVolume(int volume) override; static bool isValid() { return InitLibrary(); } diff --git a/Source/Core/AudioCommon/XAudio2_7Stream.cpp b/Source/Core/AudioCommon/XAudio2_7Stream.cpp index 938ce5109d..bff7c7dfa1 100644 --- a/Source/Core/AudioCommon/XAudio2_7Stream.cpp +++ b/Source/Core/AudioCommon/XAudio2_7Stream.cpp @@ -198,16 +198,14 @@ void XAudio2_7::SetVolume(int volume) m_mastering_voice->SetVolume(m_volume); } -void XAudio2_7::Clear(bool mute) +void XAudio2_7::SetRunning(bool running) { - m_muted = mute; - if (m_voice_context) { - if (m_muted) - m_voice_context->Stop(); - else + if (running) m_voice_context->Play(); + else + m_voice_context->Stop(); } } diff --git a/Source/Core/AudioCommon/XAudio2_7Stream.h b/Source/Core/AudioCommon/XAudio2_7Stream.h index 7a7193ea16..82270003a7 100644 --- a/Source/Core/AudioCommon/XAudio2_7Stream.h +++ b/Source/Core/AudioCommon/XAudio2_7Stream.h @@ -64,7 +64,7 @@ public: bool Start() override; void Stop() override; - void Clear(bool mute) override; + void SetRunning(bool running) override; void SetVolume(int volume) override; static bool isValid() { return InitLibrary(); } diff --git a/Source/Core/Core/HW/CPU.cpp b/Source/Core/Core/HW/CPU.cpp index 93b768f6fd..b836a9ad7e 100644 --- a/Source/Core/Core/HW/CPU.cpp +++ b/Source/Core/Core/HW/CPU.cpp @@ -147,7 +147,7 @@ static void RunAdjacentSystems(bool running) { // NOTE: We're assuming these will not try to call Break or EnableStepping. Fifo::EmulatorState(running); - AudioCommon::ClearAudioBuffer(!running); + AudioCommon::SetSoundStreamRunning(running); } void Stop()