From 7b5f73735dc5997af0718d581afe996cf8c9b738 Mon Sep 17 00:00:00 2001 From: Mikhail Baranov Date: Sat, 28 Feb 2026 23:20:32 +0100 Subject: [PATCH] cli tools: fix frame size estimation when frame_length isn't provided In multi channel scenario a frame sz become too big and Frame Factory refuses to allocate frames. Here the max frame size is estimated similar way to max packet sz estimation. --- src/tools/roc_copy/main.cpp | 7 ++++++- src/tools/roc_send/main.cpp | 11 +++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/tools/roc_copy/main.cpp b/src/tools/roc_copy/main.cpp index f1d1555c6..f119638a8 100644 --- a/src/tools/roc_copy/main.cpp +++ b/src/tools/roc_copy/main.cpp @@ -124,7 +124,12 @@ size_t compute_max_frame_size(const sndio::IoConfig& io_config) { audio::ChanLayout_Surround, audio::ChanOrder_Smpte, audio::ChanMask_Surround_7_1_4, 48000); - return spec.ns_2_samples_overall(io_config.frame_length) * sizeof(audio::sample_t); + core::nanoseconds_t len = io_config.frame_length; + if (len == 0) { + len = 10 * core::Millisecond; + } + + return spec.ns_2_samples_overall(len) * sizeof(audio::sample_t); } bool parse_input_uri(const gengetopt_args_info& args, address::IoUri& input_uri) { diff --git a/src/tools/roc_send/main.cpp b/src/tools/roc_send/main.cpp index 4a3d6100a..628cab17f 100644 --- a/src/tools/roc_send/main.cpp +++ b/src/tools/roc_send/main.cpp @@ -113,6 +113,17 @@ bool build_context_config(const gengetopt_args_info& args, roc_log(LogError, "invalid --max-frame-size: should be > 0"); return false; } + } else { + audio::SampleSpec spec = io_config.sample_spec; + spec.use_defaults(audio::Format_Pcm, audio::PcmSubformat_Raw, + audio::ChanLayout_Surround, audio::ChanOrder_Smpte, + audio::ChanMask_Surround_7_1_4, 48000); + core::nanoseconds_t len = io_config.frame_length; + if (len == 0) { + len = 10 * core::Millisecond; + } + context_config.max_frame_size = + spec.ns_2_samples_overall(len) * sizeof(audio::sample_t); } return true;