mirror of
https://github.com/yuzu-emu/yuzu-android
synced 2024-12-23 12:11:22 -08:00
Merge pull request #9320 from yuzu-emu/fix-audio-suspend
AudioCore: Take suspend lock when stalling the running process.
This commit is contained in:
commit
4e89979c87
@ -266,19 +266,20 @@ void SinkStream::ProcessAudioOutAndRender(std::span<s16> output_buffer, std::siz
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SinkStream::Stall() {
|
void SinkStream::Stall() {
|
||||||
if (stalled) {
|
std::scoped_lock lk{stall_guard};
|
||||||
|
if (stalled_lock) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
stalled = true;
|
stalled_lock = system.StallProcesses();
|
||||||
system.StallProcesses();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SinkStream::Unstall() {
|
void SinkStream::Unstall() {
|
||||||
if (!stalled) {
|
std::scoped_lock lk{stall_guard};
|
||||||
|
if (!stalled_lock) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
system.UnstallProcesses();
|
system.UnstallProcesses();
|
||||||
stalled = false;
|
stalled_lock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace AudioCore::Sink
|
} // namespace AudioCore::Sink
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <mutex>
|
||||||
#include <span>
|
#include <span>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -240,8 +241,8 @@ private:
|
|||||||
f32 system_volume{1.0f};
|
f32 system_volume{1.0f};
|
||||||
/// Set via IAudioDevice service calls
|
/// Set via IAudioDevice service calls
|
||||||
f32 device_volume{1.0f};
|
f32 device_volume{1.0f};
|
||||||
/// True if coretiming has been stalled
|
std::mutex stall_guard;
|
||||||
bool stalled{false};
|
std::unique_lock<std::mutex> stalled_lock;
|
||||||
};
|
};
|
||||||
|
|
||||||
using SinkStreamPtr = std::unique_ptr<SinkStream>;
|
using SinkStreamPtr = std::unique_ptr<SinkStream>;
|
||||||
|
@ -189,7 +189,7 @@ struct System::Impl {
|
|||||||
|
|
||||||
kernel.Suspend(false);
|
kernel.Suspend(false);
|
||||||
core_timing.SyncPause(false);
|
core_timing.SyncPause(false);
|
||||||
is_paused = false;
|
is_paused.store(false, std::memory_order_relaxed);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@ -200,14 +200,13 @@ struct System::Impl {
|
|||||||
|
|
||||||
core_timing.SyncPause(true);
|
core_timing.SyncPause(true);
|
||||||
kernel.Suspend(true);
|
kernel.Suspend(true);
|
||||||
is_paused = true;
|
is_paused.store(true, std::memory_order_relaxed);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsPaused() const {
|
bool IsPaused() const {
|
||||||
std::unique_lock lk(suspend_guard);
|
return is_paused.load(std::memory_order_relaxed);
|
||||||
return is_paused;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_lock<std::mutex> StallProcesses() {
|
std::unique_lock<std::mutex> StallProcesses() {
|
||||||
@ -218,7 +217,7 @@ struct System::Impl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void UnstallProcesses() {
|
void UnstallProcesses() {
|
||||||
if (!is_paused) {
|
if (!IsPaused()) {
|
||||||
core_timing.SyncPause(false);
|
core_timing.SyncPause(false);
|
||||||
kernel.Suspend(false);
|
kernel.Suspend(false);
|
||||||
}
|
}
|
||||||
@ -465,7 +464,7 @@ struct System::Impl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mutable std::mutex suspend_guard;
|
mutable std::mutex suspend_guard;
|
||||||
bool is_paused{};
|
std::atomic_bool is_paused{};
|
||||||
std::atomic<bool> is_shutting_down{};
|
std::atomic<bool> is_shutting_down{};
|
||||||
|
|
||||||
Timing::CoreTiming core_timing;
|
Timing::CoreTiming core_timing;
|
||||||
|
Loading…
Reference in New Issue
Block a user