mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-08-05 07:39:23 +00:00
Report underflow samples in verbose mode
Report the number of silence samples inserted due to underflow every second, along with the other metrics. PR #5870 <https://github.com/Genymobile/scrcpy/pull/5870>
This commit is contained in:
parent
457c7fe5cf
commit
1d25338119
2 changed files with 8 additions and 1 deletions
|
@ -213,6 +213,7 @@ sc_audio_regulator_push(struct sc_audio_regulator *ar, const AVFrame *frame) {
|
||||||
if (played) {
|
if (played) {
|
||||||
underflow = atomic_exchange_explicit(&ar->underflow, 0,
|
underflow = atomic_exchange_explicit(&ar->underflow, 0,
|
||||||
memory_order_relaxed);
|
memory_order_relaxed);
|
||||||
|
ar->underflow_report += underflow;
|
||||||
|
|
||||||
max_buffered_samples = ar->target_buffering * 11 / 10
|
max_buffered_samples = ar->target_buffering * 11 / 10
|
||||||
+ 60 * ar->sample_rate / 1000 /* 60 ms */;
|
+ 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;
|
int abs_max_diff = distance / 50;
|
||||||
diff = CLAMP(diff, -abs_max_diff, abs_max_diff);
|
diff = CLAMP(diff, -abs_max_diff, abs_max_diff);
|
||||||
LOGV("[Audio] Buffering: target=%" PRIu32 " avg=%f cur=%" PRIu32
|
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);
|
int ret = swr_set_compensation(swr_ctx, diff, distance);
|
||||||
if (ret < 0) {
|
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->played, false);
|
||||||
atomic_init(&ar->received, false);
|
atomic_init(&ar->received, false);
|
||||||
atomic_init(&ar->underflow, 0);
|
atomic_init(&ar->underflow, 0);
|
||||||
|
ar->underflow_report = 0;
|
||||||
ar->compensation_active = false;
|
ar->compensation_active = false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -46,6 +46,9 @@ struct sc_audio_regulator {
|
||||||
// Number of silence samples inserted since the last received packet
|
// Number of silence samples inserted since the last received packet
|
||||||
atomic_uint_least32_t underflow;
|
atomic_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)
|
// Non-zero compensation applied (only used by the receiver thread)
|
||||||
bool compensation_active;
|
bool compensation_active;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue