Disable clock drift compensation for tiny values

For less than 1ms, the estimated drift is just noise.
This commit is contained in:
Romain Vimont 2023-03-11 18:21:46 +01:00
parent c22c87eded
commit 73727e7fdf

View file

@ -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;