Merge pull request #9320 from yuzu-emu/fix-audio-suspend

AudioCore: Take suspend lock when stalling the running process.
This commit is contained in:
Fernando S 2022-11-30 16:41:32 +01:00 committed by GitHub
commit 4e89979c87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 13 deletions

View file

@ -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

View file

@ -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>;