Display and control your Android device
Report underflow samples in verbose mode
Romain Vimont1d2533811984
diff --git a/app/src/audio_regulator.c b/app/src/audio_regulator.cindex f11ed0e7..66900b51 100644--- a/app/src/audio_regulator.c+++ b/app/src/audio_regulator.c@@ -213,6 +213,7 @@ sc_audio_regulator_push(struct sc_audio_regulator *ar, const AVFrame *frame) {if (played) {underflow = atomic_exchange_explicit(&ar->underflow, 0,memory_order_relaxed);+ ar->underflow_report += underflow;max_buffered_samples = ar->target_buffering * 11 / 10+ 60 * ar->sample_rate / 1000 /* 60 ms */;@@ -315,7 +316,9 @@ sc_audio_regulator_push(struct sc_audio_regulator *ar, const AVFrame *frame) {int abs_max_diff = distance / 50;diff = CLAMP(diff, -abs_max_diff, abs_max_diff);LOGV("[Audio] Buffering: target=%" PRIu32 " avg=%f cur=%" PRIu32- " compensation=%d", ar->target_buffering, avg, can_read, diff);+ " compensation=%d (underflow=%" PRIu32 ")",+ ar->target_buffering, avg, can_read, diff, ar->underflow_report);+ ar->underflow_report = 0;int ret = swr_set_compensation(swr_ctx, diff, distance);if (ret < 0) {@@ -398,6 +401,7 @@ sc_audio_regulator_init(struct sc_audio_regulator *ar, size_t sample_size,atomic_init(&ar->played, false);atomic_init(&ar->received, false);atomic_init(&ar->underflow, 0);+ ar->underflow_report = 0;ar->compensation_active = false;return true;diff --git a/app/src/audio_regulator.h b/app/src/audio_regulator.hindex 03cf6325..79238fbe 100644--- a/app/src/audio_regulator.h+++ b/app/src/audio_regulator.h@@ -46,6 +46,9 @@ struct sc_audio_regulator {// Number of silence samples inserted since the last received packetatomic_uint_least32_t underflow;+ // Number of silence samples inserted since the last log+ uint32_t underflow_report;+// Non-zero compensation applied (only used by the receiver thread)bool compensation_active;