Skip to content

Commit 7b5f737

Browse files
committed
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.
1 parent 4d4abbb commit 7b5f737

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

src/tools/roc_copy/main.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,12 @@ size_t compute_max_frame_size(const sndio::IoConfig& io_config) {
124124
audio::ChanLayout_Surround, audio::ChanOrder_Smpte,
125125
audio::ChanMask_Surround_7_1_4, 48000);
126126

127-
return spec.ns_2_samples_overall(io_config.frame_length) * sizeof(audio::sample_t);
127+
core::nanoseconds_t len = io_config.frame_length;
128+
if (len == 0) {
129+
len = 10 * core::Millisecond;
130+
}
131+
132+
return spec.ns_2_samples_overall(len) * sizeof(audio::sample_t);
128133
}
129134

130135
bool parse_input_uri(const gengetopt_args_info& args, address::IoUri& input_uri) {

src/tools/roc_send/main.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,17 @@ bool build_context_config(const gengetopt_args_info& args,
113113
roc_log(LogError, "invalid --max-frame-size: should be > 0");
114114
return false;
115115
}
116+
} else {
117+
audio::SampleSpec spec = io_config.sample_spec;
118+
spec.use_defaults(audio::Format_Pcm, audio::PcmSubformat_Raw,
119+
audio::ChanLayout_Surround, audio::ChanOrder_Smpte,
120+
audio::ChanMask_Surround_7_1_4, 48000);
121+
core::nanoseconds_t len = io_config.frame_length;
122+
if (len == 0) {
123+
len = 10 * core::Millisecond;
124+
}
125+
context_config.max_frame_size =
126+
spec.ns_2_samples_overall(len) * sizeof(audio::sample_t);
116127
}
117128

118129
return true;

0 commit comments

Comments
 (0)