aboutsummaryrefslogtreecommitdiff
path: root/src/audio_core/stream.cpp
diff options
context:
space:
mode:
authoryuzubot <yuzu@yuzu-emu.org>2022-01-30 13:02:17 +0000
committeryuzubot <yuzu@yuzu-emu.org>2022-01-30 13:02:17 +0000
commitda2d8feb25bac77b2459266d91acc99d427bcd63 (patch)
tree9d21f0469bede2fafbbc47578f26fb43407516bd /src/audio_core/stream.cpp
parent6a1f0458b601268775c872f9f4de9c4f6f513e80 (diff)
"Merge Tagged PR 7346"
Diffstat (limited to 'src/audio_core/stream.cpp')
-rw-r--r--src/audio_core/stream.cpp9
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, {});
}