diff options
| author | 2022-11-29 20:32:06 -0800 | |
|---|---|---|
| committer | 2022-11-29 20:32:06 -0800 | |
| commit | 8fd4e44014119a1c155de64d63d455390f852a22 (patch) | |
| tree | 48a00a3e059d61897d2296f7ebcd29e012404954 | |
| parent | core: Use atomic instead of a lock to protect is_paused. (diff) | |
| download | yuzu-8fd4e44014119a1c155de64d63d455390f852a22.tar.gz yuzu-8fd4e44014119a1c155de64d63d455390f852a22.tar.xz yuzu-8fd4e44014119a1c155de64d63d455390f852a22.zip | |
audio_core: sink_stream: Hold the suspend lock when process is stalled.
- Prevents us from clashing with other callers trying to un/stall.
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 | |||
| 266 | } | 266 | } |
| 267 | 267 | ||
| 268 | void SinkStream::Stall() { | 268 | void SinkStream::Stall() { |
| 269 | if (stalled) { | 269 | std::scoped_lock lk{stall_guard}; |
| 270 | if (stalled_lock) { | ||
| 270 | return; | 271 | return; |
| 271 | } | 272 | } |
| 272 | stalled = true; | 273 | stalled_lock = system.StallProcesses(); |
| 273 | system.StallProcesses(); | ||
| 274 | } | 274 | } |
| 275 | 275 | ||
| 276 | void SinkStream::Unstall() { | 276 | void SinkStream::Unstall() { |
| 277 | if (!stalled) { | 277 | std::scoped_lock lk{stall_guard}; |
| 278 | if (!stalled_lock) { | ||
| 278 | return; | 279 | return; |
| 279 | } | 280 | } |
| 280 | system.UnstallProcesses(); | 281 | system.UnstallProcesses(); |
| 281 | stalled = false; | 282 | stalled_lock.unlock(); |
| 282 | } | 283 | } |
| 283 | 284 | ||
| 284 | } // namespace AudioCore::Sink | 285 | } // 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 @@ | |||
| 6 | #include <array> | 6 | #include <array> |
| 7 | #include <atomic> | 7 | #include <atomic> |
| 8 | #include <memory> | 8 | #include <memory> |
| 9 | #include <mutex> | ||
| 9 | #include <span> | 10 | #include <span> |
| 10 | #include <vector> | 11 | #include <vector> |
| 11 | 12 | ||
| @@ -240,8 +241,8 @@ private: | |||
| 240 | f32 system_volume{1.0f}; | 241 | f32 system_volume{1.0f}; |
| 241 | /// Set via IAudioDevice service calls | 242 | /// Set via IAudioDevice service calls |
| 242 | f32 device_volume{1.0f}; | 243 | f32 device_volume{1.0f}; |
| 243 | /// True if coretiming has been stalled | 244 | std::mutex stall_guard; |
| 244 | bool stalled{false}; | 245 | std::unique_lock<std::mutex> stalled_lock; |
| 245 | }; | 246 | }; |
| 246 | 247 | ||
| 247 | using SinkStreamPtr = std::unique_ptr<SinkStream>; | 248 | using SinkStreamPtr = std::unique_ptr<SinkStream>; |