Skip to content

Commit a657bc7

Browse files
committed
audio dec: color if received samples don't match
If the actual number of decoded samples doesn't match the expected number (from nominal sampling rate), use colors to catch user attention. This is similar how it is already done for video capture/display.
1 parent b44af19 commit a657bc7

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/rtp/audio_decoders.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
#include "utils/color_out.h"
7979
#include "utils/debug.h" // for DEBUG_TIMER_*
8080
#include "utils/macros.h"
81+
#include "utils/misc.h" // for get_stat_color
8182
#include "utils/packet_counter.h"
8283
#include "utils/worker.h"
8384

@@ -381,13 +382,16 @@ static void *adec_compute_and_print_stats(void *arg) {
381382
if (d->bytes_received < d->bytes_expected) {
382383
loss = " (" + to_string(d->bytes_expected - d->bytes_received) + " lost)";
383384
}
384-
log_msg(LOG_LEVEL_INFO, "[Audio decoder] Received %ld/%ld B%s, "
385-
"decoded %d samples in %.2f sec.\n",
386-
d->bytes_received,
387-
d->bytes_expected,
388-
loss.c_str(),
389-
d->frame.get_sample_count(),
390-
d->seconds);
385+
386+
const double exp_samples = d->frame.get_sample_rate() * d->seconds;
387+
const char *dec_cnt_warn_col =
388+
get_stat_color(d->frame.get_sample_count() / exp_samples);
389+
390+
MSG(INFO,
391+
"Received %ld/%ld B%s, "
392+
"decoded %s%d samples" TERM_RESET " in %.2f sec.\n",
393+
d->bytes_received, d->bytes_expected, loss.c_str(),
394+
dec_cnt_warn_col, d->frame.get_sample_count(), d->seconds);
391395

392396
char volume[STR_LEN];
393397
char *vol_start = volume;
@@ -400,8 +404,8 @@ static void *adec_compute_and_print_stats(void *arg) {
400404
&vol_start, volume + sizeof volume);
401405
}
402406

403-
log_msg(LOG_LEVEL_INFO, "[Audio decoder] Volume: %s dBFS RMS/peak%s\n",
404-
volume, d->muted_receiver ? TBOLD(TRED(" (muted)")) : "");
407+
MSG(INFO, "Volume: %s dBFS RMS/peak%s\n", volume,
408+
d->muted_receiver ? TBOLD(TRED(" (muted)")) : "");
405409

406410
delete d;
407411

0 commit comments

Comments
 (0)