diff options
Diffstat (limited to '')
-rw-r--r-- | src/audio_core/renderer/system_manager.cpp | 30 |
1 files changed, 6 insertions, 24 deletions
diff --git a/src/audio_core/renderer/system_manager.cpp b/src/audio_core/renderer/system_manager.cpp index f66b2b890..300ecdbf1 100644 --- a/src/audio_core/renderer/system_manager.cpp +++ b/src/audio_core/renderer/system_manager.cpp @@ -15,14 +15,9 @@ MICROPROFILE_DEFINE(Audio_RenderSystemManager, "Audio", "Render System Manager", MP_RGB(60, 19, 97)); namespace AudioCore::AudioRenderer { -constexpr std::chrono::nanoseconds RENDER_TIME{5'000'000UL}; SystemManager::SystemManager(Core::System& core_) - : core{core_}, adsp{core.AudioCore().GetADSP()}, mailbox{adsp.GetRenderMailbox()}, - thread_event{Core::Timing::CreateEvent( - "AudioRendererSystemManager", [this](std::uintptr_t, s64 time, std::chrono::nanoseconds) { - return ThreadFunc2(time); - })} {} + : core{core_}, adsp{core.AudioCore().GetADSP()}, mailbox{adsp.GetRenderMailbox()} {} SystemManager::~SystemManager() { Stop(); @@ -32,9 +27,7 @@ bool SystemManager::InitializeUnsafe() { if (!active) { if (adsp.Start()) { active = true; - thread = std::jthread([this](std::stop_token stop_token) { ThreadFunc(); }); - core.CoreTiming().ScheduleLoopingEvent(std::chrono::nanoseconds(0), RENDER_TIME, - thread_event); + thread = std::jthread([this](std::stop_token stop_token) { ThreadFunc(stop_token); }); } } @@ -45,10 +38,8 @@ void SystemManager::Stop() { if (!active) { return; } - core.CoreTiming().UnscheduleEvent(thread_event, {}); active = false; - update.store(true); - update.notify_all(); + thread.request_stop(); thread.join(); adsp.Stop(); } @@ -93,12 +84,12 @@ bool SystemManager::Remove(System& system_) { return true; } -void SystemManager::ThreadFunc() { - constexpr char name[]{"AudioRenderSystemManager"}; +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}; @@ -111,16 +102,7 @@ void SystemManager::ThreadFunc() { adsp.Signal(); adsp.Wait(); - - update.wait(false); - update.store(false); } } -std::optional<std::chrono::nanoseconds> SystemManager::ThreadFunc2(s64 time) { - update.store(true); - update.notify_all(); - return std::nullopt; -} - } // namespace AudioCore::AudioRenderer |