From 8ff8a78592558c2b0a9cd0fbb7ea7b43b5c09a9f Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Wed, 11 Sep 2024 14:23:32 +0200 Subject: [PATCH] tx audio: warn if Reed-Solomon is inadequate refer to GH-408 --- src/transmit.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/transmit.cpp b/src/transmit.cpp index 51931cf3f..10ae8f087 100644 --- a/src/transmit.cpp +++ b/src/transmit.cpp @@ -79,6 +79,7 @@ #include "tv.h" #include "types.h" #include "utils/jpeg_reader.h" +#include "utils/macros.h" #include "utils/misc.h" // unit_evaluate #include "utils/random.h" #include "video.h" @@ -871,9 +872,9 @@ audio_tx_send_chan(struct tx *tx, struct rtp *rtp_session, uint32_t timestamp, } long data_sent = 0; + int data_len = tx->mtu - hdrs_len; do { const char *data = chan_data + pos; - int data_len = tx->mtu - hdrs_len; if (pos + data_len >= (unsigned int) buffer->get_data_len(channel)) { data_len = buffer->get_data_len(channel) - pos; @@ -908,6 +909,23 @@ audio_tx_send_chan(struct tx *tx, struct rtp *rtp_session, uint32_t timestamp, } while (pos < buffer->get_data_len(channel)); report_stats(tx, rtp_session, data_sent); + + if (buffer->get_fec_params(0).type == FEC_NONE) { + return; + } + // issue a warning if R-S is inadequate + const int packet_count = + (buffer->get_data_len(channel) + data_len - 1) / data_len; + if (packet_count > 3) { + return; + } + const char *pl_suffix = packet_count == 1 ? "" : "s"; + log_msg_once(LOG_LEVEL_WARNING, to_fourcc('t', 'x', 'a', 'F'), + MOD_NAME + "[audio] %d packet%s per audio channel may be too low " + "for Reed Solomon, consider mult instead!%s\n", + packet_count, pl_suffix, + packet_count == 3 ? " (Or increase the redundancy.)" : ""); } static bool