From 1db31514d6086478a586eae601a297b9d9495928 Mon Sep 17 00:00:00 2001 From: Ayoub-glitsh Date: Fri, 24 Apr 2026 17:02:06 +0100 Subject: [PATCH] fix #821: raise default max_packet_size for multitrack support The default max_packet_size of 2048 bytes is too small for multitrack audio. For example, 8 channels at 48kHz with the default 5ms packet length requires ~3904 bytes (240 samples x 8 channels x 2 bytes + RTP header), causing packetizer to fail with 'can't prepare packet'. Changes: - Raise ContextConfig default max_packet_size from 2048 to 16384 bytes, which covers up to ~34 channels at 48kHz/5ms/16-bit PCM - Improve error message in Packetizer::create_packet_() to include payload_size and buffer_capacity, and hint to increase max_packet_size --- src/internal_modules/roc_audio/packetizer.cpp | 7 ++++++- src/internal_modules/roc_node/context.h | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/internal_modules/roc_audio/packetizer.cpp b/src/internal_modules/roc_audio/packetizer.cpp index 0d97fea2c..c0c909c29 100644 --- a/src/internal_modules/roc_audio/packetizer.cpp +++ b/src/internal_modules/roc_audio/packetizer.cpp @@ -185,7 +185,12 @@ packet::PacketPtr Packetizer::create_packet_() { } if (!composer_.prepare(*packet, buffer, payload_size_)) { - roc_log(LogError, "packetizer: can't prepare packet"); + roc_log(LogError, + "packetizer: can't prepare packet:" + " packet buffer is too small for the requested payload:" + " payload_size=%lu buffer_capacity=%lu" + " (increase max_packet_size in context config)", + (unsigned long)payload_size_, (unsigned long)buffer.capacity()); return NULL; } packet->add_flags(packet::Packet::FlagPrepared); diff --git a/src/internal_modules/roc_node/context.h b/src/internal_modules/roc_node/context.h index c2657103d..6f52b437e 100644 --- a/src/internal_modules/roc_node/context.h +++ b/src/internal_modules/roc_node/context.h @@ -35,7 +35,7 @@ struct ContextConfig { size_t max_frame_size; ContextConfig() - : max_packet_size(2048) + : max_packet_size(16384) , max_frame_size(4096) { } };