diff options
| author | 2022-11-30 16:41:32 +0100 | |
|---|---|---|
| committer | 2022-11-30 16:41:32 +0100 | |
| commit | 4e89979c87dfa77f0c55b03a5aaf00706276c2f0 (patch) | |
| tree | 50fcec585d4b33e0d2a3ed6e25d40d1c3bf19370 /src/core/core.cpp | |
| 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.gz yuzu-4e89979c87dfa77f0c55b03a5aaf00706276c2f0.tar.xz yuzu-4e89979c87dfa77f0c55b03a5aaf00706276c2f0.zip | |
Merge pull request #9320 from yuzu-emu/fix-audio-suspend
AudioCore: Take suspend lock when stalling the running process.
Diffstat (limited to 'src/core/core.cpp')
| -rw-r--r-- | src/core/core.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index d8934be52..94d4e2212 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -189,7 +189,7 @@ struct System::Impl { | |||
| 189 | 189 | ||
| 190 | kernel.Suspend(false); | 190 | kernel.Suspend(false); |
| 191 | core_timing.SyncPause(false); | 191 | core_timing.SyncPause(false); |
| 192 | is_paused = false; | 192 | is_paused.store(false, std::memory_order_relaxed); |
| 193 | 193 | ||
| 194 | return status; | 194 | return status; |
| 195 | } | 195 | } |
| @@ -200,14 +200,13 @@ struct System::Impl { | |||
| 200 | 200 | ||
| 201 | core_timing.SyncPause(true); | 201 | core_timing.SyncPause(true); |
| 202 | kernel.Suspend(true); | 202 | kernel.Suspend(true); |
| 203 | is_paused = true; | 203 | is_paused.store(true, std::memory_order_relaxed); |
| 204 | 204 | ||
| 205 | return status; | 205 | return status; |
| 206 | } | 206 | } |
| 207 | 207 | ||
| 208 | bool IsPaused() const { | 208 | bool IsPaused() const { |
| 209 | std::unique_lock lk(suspend_guard); | 209 | return is_paused.load(std::memory_order_relaxed); |
| 210 | return is_paused; | ||
| 211 | } | 210 | } |
| 212 | 211 | ||
| 213 | std::unique_lock<std::mutex> StallProcesses() { | 212 | std::unique_lock<std::mutex> StallProcesses() { |
| @@ -218,7 +217,7 @@ struct System::Impl { | |||
| 218 | } | 217 | } |
| 219 | 218 | ||
| 220 | void UnstallProcesses() { | 219 | void UnstallProcesses() { |
| 221 | if (!is_paused) { | 220 | if (!IsPaused()) { |
| 222 | core_timing.SyncPause(false); | 221 | core_timing.SyncPause(false); |
| 223 | kernel.Suspend(false); | 222 | kernel.Suspend(false); |
| 224 | } | 223 | } |
| @@ -465,7 +464,7 @@ struct System::Impl { | |||
| 465 | } | 464 | } |
| 466 | 465 | ||
| 467 | mutable std::mutex suspend_guard; | 466 | mutable std::mutex suspend_guard; |
| 468 | bool is_paused{}; | 467 | std::atomic_bool is_paused{}; |
| 469 | std::atomic<bool> is_shutting_down{}; | 468 | std::atomic<bool> is_shutting_down{}; |
| 470 | 469 | ||
| 471 | Timing::CoreTiming core_timing; | 470 | Timing::CoreTiming core_timing; |