From 7784b1da6dcd37027c82e1b980b1e79645f18176 Mon Sep 17 00:00:00 2001 From: german Date: Tue, 2 Feb 2021 09:59:59 -0600 Subject: Prevent over scheduling audio events and terminate properly the motion update event --- src/audio_core/stream.cpp | 9 ++++++++- src/core/hle/service/hid/hid.cpp | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/audio_core/stream.cpp b/src/audio_core/stream.cpp index afe68c9ed..f3373fe04 100644 --- a/src/audio_core/stream.cpp +++ b/src/audio_core/stream.cpp @@ -103,7 +103,14 @@ void Stream::PlayNextBuffer(std::chrono::nanoseconds ns_late) { sink_stream.EnqueueSamples(GetNumChannels(), active_buffer->GetSamples()); - core_timing.ScheduleEvent(GetBufferReleaseNS(*active_buffer) - ns_late, release_event, {}); + const auto buffer_release_ns = GetBufferReleaseNS(*active_buffer); + + // If ns_late is higher than the update rate ignore the delay + if (ns_late > buffer_release_ns) { + ns_late = {}; + } + + core_timing.ScheduleEvent(buffer_release_ns - ns_late, release_event, {}); } void Stream::ReleaseActiveBuffer(std::chrono::nanoseconds ns_late) { diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 60e63626d..d86711fea 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp @@ -104,6 +104,7 @@ void IAppletResource::DeactivateController(HidController controller) { IAppletResource ::~IAppletResource() { system.CoreTiming().UnscheduleEvent(pad_update_event, 0); + system.CoreTiming().UnscheduleEvent(motion_update_event, 0); } void IAppletResource::GetSharedMemoryHandle(Kernel::HLERequestContext& ctx) { -- cgit v1.2.3