From 73727e7fdfdd579f14f957dce680a3fc9e454437 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Sat, 11 Mar 2023 18:21:46 +0100 Subject: [PATCH] Disable clock drift compensation for tiny values For less than 1ms, the estimated drift is just noise. --- app/src/audio_player.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/audio_player.c b/app/src/audio_player.c index 1bff2b76..aa34c316 100644 --- a/app/src/audio_player.c +++ b/app/src/audio_player.c @@ -241,7 +241,10 @@ sc_audio_player_frame_sink_push(struct sc_frame_sink *sink, float avg = sc_average_get(&ap->avg_buffering); int diff = ap->target_buffering - avg; - if (diff < 0 && buffered_samples < ap->target_buffering) { + if (abs(diff) < ap->sample_rate / 1000) { + // Do not compensate for less than 1ms, the error is just noise + diff = 0; + } else if (diff < 0 && buffered_samples < ap->target_buffering) { // Do not accelerate if the instant buffering level is below // the average, this would increase underflow diff = 0;