diff options
Diffstat (limited to 'src/audio_core/stream.cpp')
-rw-r--r-- | src/audio_core/stream.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/audio_core/stream.cpp b/src/audio_core/stream.cpp index 0abc989b2f..ca034568d4 100644 --- a/src/audio_core/stream.cpp +++ b/src/audio_core/stream.cpp @@ -87,6 +87,14 @@ static void VolumeAdjustSamples(std::vector<s16>& samples, float game_volume) { } void Stream::PlayNextBuffer(std::chrono::nanoseconds ns_late) { + auto now = std::chrono::steady_clock::now(); + auto duration = now.time_since_epoch(); + auto nanoseconds = std::chrono::duration_cast<std::chrono::nanoseconds>(duration); + + if (nanoseconds > expected_cb_time) { + ns_late = nanoseconds - expected_cb_time; + } + if (!IsPlaying()) { // Ensure we are in playing state before playing the next buffer sink_stream.Flush(); @@ -121,6 +129,7 @@ void Stream::PlayNextBuffer(std::chrono::nanoseconds ns_late) { ns_late = {}; } + expected_cb_time = nanoseconds + (buffer_release_ns - ns_late); core_timing.ScheduleEvent(buffer_release_ns - ns_late, release_event, {}); } |