Skip to content

Commit 9323b17

Browse files
committed
Don't crash if input & output counts don't match what we requested
1 parent ec96cca commit 9323b17

1 file changed

Lines changed: 2 additions & 9 deletions

File tree

plinth-plugin/src/formats/clap/plugin_instance.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -275,14 +275,7 @@ impl<P: ClapPlugin> PluginInstance<P> {
275275
return CLAP_PROCESS_ERROR;
276276
}
277277

278-
// TODO: Support other bus layouts
279-
if P::HAS_AUX_INPUT {
280-
assert_eq!(process.audio_inputs_count, 2);
281-
} else {
282-
assert_eq!(process.audio_inputs_count, 1);
283-
}
284-
285-
assert_eq!(process.audio_outputs_count, 1);
278+
assert!(process.audio_outputs_count >= 1);
286279

287280
let input_buffers = unsafe { std::slice::from_raw_parts(process.audio_inputs, process.audio_inputs_count as usize) };
288281
let output_buffers = unsafe { std::slice::from_raw_parts(process.audio_outputs, process.audio_outputs_count as usize) };
@@ -296,7 +289,7 @@ impl<P: ClapPlugin> PluginInstance<P> {
296289
let input = unsafe { PtrSignal::from_pointers(input_buffer.channel_count as usize, process.frames_count as usize, input_buffer.data32 as _) };
297290
let mut output = unsafe { PtrSignalMut::from_pointers(output_buffer.channel_count as usize, process.frames_count as usize, output_buffer.data32) };
298291

299-
let aux = if P::HAS_AUX_INPUT {
292+
let aux = if P::HAS_AUX_INPUT && process.audio_inputs_count >= 2 {
300293
let aux_buffer = input_buffers[1];
301294
assert_eq!(aux_buffer.channel_count, 2);
302295

0 commit comments

Comments
 (0)