diff options
author | Fernando S <fsahmkow27@gmail.com> | 2022-11-30 16:41:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-30 16:41:32 +0100 |
commit | 4e89979c87dfa77f0c55b03a5aaf00706276c2f0 (patch) | |
tree | 50fcec585d4b33e0d2a3ed6e25d40d1c3bf19370 /src/audio_core/sink | |
parent | Merge pull request #9349 from lat9nq/cmake-322 (diff) | |
parent | audio_core: sink_stream: Hold the suspend lock when process is stalled. (diff) | |
download | yuzu-4e89979c87dfa77f0c55b03a5aaf00706276c2f0.tar yuzu-4e89979c87dfa77f0c55b03a5aaf00706276c2f0.tar.gz yuzu-4e89979c87dfa77f0c55b03a5aaf00706276c2f0.tar.bz2 yuzu-4e89979c87dfa77f0c55b03a5aaf00706276c2f0.tar.lz yuzu-4e89979c87dfa77f0c55b03a5aaf00706276c2f0.tar.xz yuzu-4e89979c87dfa77f0c55b03a5aaf00706276c2f0.tar.zst yuzu-4e89979c87dfa77f0c55b03a5aaf00706276c2f0.zip |
Diffstat (limited to '')
-rw-r--r-- | src/audio_core/sink/sink_stream.cpp | 11 | ||||
-rw-r--r-- | src/audio_core/sink/sink_stream.h | 5 |
2 files changed, 9 insertions, 7 deletions
diff --git a/src/audio_core/sink/sink_stream.cpp b/src/audio_core/sink/sink_stream.cpp index 849f862b0..67e194e3c 100644 --- a/src/audio_core/sink/sink_stream.cpp +++ b/src/audio_core/sink/sink_stream.cpp @@ -266,19 +266,20 @@ void SinkStream::ProcessAudioOutAndRender(std::span<s16> output_buffer, std::siz } void SinkStream::Stall() { - if (stalled) { + std::scoped_lock lk{stall_guard}; + if (stalled_lock) { return; } - stalled = true; - system.StallProcesses(); + stalled_lock = system.StallProcesses(); } void SinkStream::Unstall() { - if (!stalled) { + std::scoped_lock lk{stall_guard}; + if (!stalled_lock) { return; } system.UnstallProcesses(); - stalled = false; + stalled_lock.unlock(); } } // namespace AudioCore::Sink diff --git a/src/audio_core/sink/sink_stream.h b/src/audio_core/sink/sink_stream.h index 38a4b2f51..5fea72ab7 100644 --- a/src/audio_core/sink/sink_stream.h +++ b/src/audio_core/sink/sink_stream.h @@ -6,6 +6,7 @@ #include <array> #include <atomic> #include <memory> +#include <mutex> #include <span> #include <vector> @@ -240,8 +241,8 @@ private: f32 system_volume{1.0f}; /// Set via IAudioDevice service calls f32 device_volume{1.0f}; - /// True if coretiming has been stalled - bool stalled{false}; + std::mutex stall_guard; + std::unique_lock<std::mutex> stalled_lock; }; using SinkStreamPtr = std::unique_ptr<SinkStream>; |