From b883a611abfdd1d50b380943035facb590c3d990 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sun, 11 Sep 2022 16:41:31 +0200 Subject: [PATCH] Fix resizing aux input storage on buffer size This nested `resize_with()` of course wouldn't resize the inner vectors of the outer ones were already the correct size. --- src/wrapper/clap/wrapper.rs | 15 +++++++++------ src/wrapper/vst3/wrapper.rs | 20 +++++++++++--------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/wrapper/clap/wrapper.rs b/src/wrapper/clap/wrapper.rs index 2de3e92a..42d5c96f 100644 --- a/src/wrapper/clap/wrapper.rs +++ b/src/wrapper/clap/wrapper.rs @@ -1719,12 +1719,15 @@ impl Wrapper

{ // inputs. The slices will be assigned in the process function as this object may have // been moved before then. let mut aux_input_storage = wrapper.aux_input_storage.borrow_mut(); - aux_input_storage.resize_with(bus_config.aux_input_busses.num_busses as usize, || { - vec![ - vec![0.0; max_frames_count as usize]; - bus_config.aux_input_busses.num_channels as usize - ] - }); + aux_input_storage + .resize_with(bus_config.aux_input_busses.num_busses as usize, Vec::new); + for bus_storage in aux_input_storage.iter_mut() { + bus_storage + .resize_with(bus_config.aux_input_busses.num_channels as usize, Vec::new); + for channel_storage in bus_storage { + channel_storage.resize(max_frames_count as usize, 0.0); + } + } let mut aux_input_buffers = wrapper.aux_input_buffers.borrow_mut(); aux_input_buffers.resize_with( diff --git a/src/wrapper/vst3/wrapper.rs b/src/wrapper/vst3/wrapper.rs index 1c226459..0e9fa245 100644 --- a/src/wrapper/vst3/wrapper.rs +++ b/src/wrapper/vst3/wrapper.rs @@ -413,15 +413,17 @@ impl IComponent for Wrapper

{ // sidechain inputs. The slices will be assigned in the process function as this // object may have been moved before then. let mut aux_input_storage = self.inner.aux_input_storage.borrow_mut(); - aux_input_storage.resize_with( - bus_config.aux_input_busses.num_busses as usize, - || { - vec![ - vec![0.0; buffer_config.max_buffer_size as usize]; - bus_config.aux_input_busses.num_channels as usize - ] - }, - ); + aux_input_storage + .resize_with(bus_config.aux_input_busses.num_busses as usize, Vec::new); + for bus_storage in aux_input_storage.iter_mut() { + bus_storage.resize_with( + bus_config.aux_input_busses.num_channels as usize, + Vec::new, + ); + for channel_storage in bus_storage { + channel_storage.resize(buffer_config.max_buffer_size as usize, 0.0); + } + } let mut aux_input_buffers = self.inner.aux_input_buffers.borrow_mut(); aux_input_buffers.resize_with(