From 8fd4e44014119a1c155de64d63d455390f852a22 Mon Sep 17 00:00:00 2001 From: bunnei Date: Tue, 29 Nov 2022 20:32:06 -0800 Subject: audio_core: sink_stream: Hold the suspend lock when process is stalled. - Prevents us from clashing with other callers trying to un/stall. --- src/audio_core/sink/sink_stream.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/audio_core/sink/sink_stream.cpp') 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 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 -- cgit v1.2.3