From 9b9105f6aecf05fc2c135abcf17de3300b12d222 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Wed, 11 Sep 2024 15:22:50 +0200 Subject: [PATCH] tx audio R-S warning: use the correct max_len The data_len var used to compute packet_count may be lesser than its initial value (tx->mtu - hdrs_len) because it might have been decreased to number of remaining bytes of the last packet. Returned back data_len to the do-loop and compute the value as max_len. --- src/transmit.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/transmit.cpp b/src/transmit.cpp index 10ae8f087..75def74b7 100644 --- a/src/transmit.cpp +++ b/src/transmit.cpp @@ -872,9 +872,10 @@ 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; + const int max_len = tx->mtu - hdrs_len; do { const char *data = chan_data + pos; + int data_len = max_len; if (pos + data_len >= (unsigned int) buffer->get_data_len(channel)) { data_len = buffer->get_data_len(channel) - pos; @@ -915,7 +916,7 @@ audio_tx_send_chan(struct tx *tx, struct rtp *rtp_session, uint32_t timestamp, } // issue a warning if R-S is inadequate const int packet_count = - (buffer->get_data_len(channel) + data_len - 1) / data_len; + (buffer->get_data_len(channel) + max_len - 1) / max_len; if (packet_count > 3) { return; }