diff options
| author | Kelebek1 <eeeedddccc@hotmail.co.uk> | 2023-05-10 17:59:21 +0100 |
|---|---|---|
| committer | Kelebek1 <eeeedddccc@hotmail.co.uk> | 2023-05-18 13:03:32 +0100 |
| commit | ba0d258a3f3d43dbeb021292e21dae92e473c2e1 (patch) | |
| tree | dcdacfe32430c6a33553dc7ae440c4a7011ef9ab /src/audio_core/renderer/system_manager.cpp | |
| parent | c4675c246b69051ba4866cada436e58e5db78f8e (diff) | |
Smooth out the DSP callback by adding a 5ms wait time limit
Diffstat (limited to 'src/audio_core/renderer/system_manager.cpp')
| -rw-r--r-- | src/audio_core/renderer/system_manager.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/audio_core/renderer/system_manager.cpp b/src/audio_core/renderer/system_manager.cpp index 07d8ed093e..300ecdbf13 100644 --- a/src/audio_core/renderer/system_manager.cpp +++ b/src/audio_core/renderer/system_manager.cpp @@ -27,7 +27,7 @@ bool SystemManager::InitializeUnsafe() { if (!active) { if (adsp.Start()) { active = true; - thread = std::jthread([this](std::stop_token stop_token) { ThreadFunc(); }); + thread = std::jthread([this](std::stop_token stop_token) { ThreadFunc(stop_token); }); } } @@ -39,8 +39,7 @@ void SystemManager::Stop() { return; } active = false; - update.store(true); - update.notify_all(); + thread.request_stop(); thread.join(); adsp.Stop(); } @@ -85,12 +84,12 @@ bool SystemManager::Remove(System& system_) { return true; } -void SystemManager::ThreadFunc() { +void SystemManager::ThreadFunc(std::stop_token stop_token) { static constexpr char name[]{"AudioRenderSystemManager"}; MicroProfileOnThreadCreate(name); Common::SetCurrentThreadName(name); Common::SetCurrentThreadPriority(Common::ThreadPriority::High); - while (active) { + while (active && !stop_token.stop_requested()) { { std::scoped_lock l{mutex1}; |
