From 0afb9631b53de1a747fc9ba46ed37781b04ef492 Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Sun, 2 Apr 2023 17:29:07 +0100 Subject: Add some explicit latency to sample count reporting Some games have very tight scheduling requirements for their audio which can't really be matched on the host, adding a constant to the reported value helps to provide some leeway. --- src/audio_core/sink/sink_stream.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/audio_core/sink/sink_stream.cpp b/src/audio_core/sink/sink_stream.cpp index f99dbd8ec..13c73b5d7 100644 --- a/src/audio_core/sink/sink_stream.cpp +++ b/src/audio_core/sink/sink_stream.cpp @@ -266,7 +266,8 @@ u64 SinkStream::GetExpectedPlayedSampleCount() { auto exp_played_sample_count{min_played_sample_count + (TargetSampleRate * time_delta) / std::chrono::seconds{1}}; - return std::min(exp_played_sample_count, max_played_sample_count); + // Add 15ms of latency in sample reporting to allow for some leeway in scheduler timings + return std::min(exp_played_sample_count, max_played_sample_count) + TargetSampleCount * 3; } void SinkStream::WaitFreeSpace() { -- cgit v1.2.3