From 9c48e7f59b3aad484aac6aa52b30173b25c1dc7f Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Thu, 2 Feb 2023 16:15:43 +0100 Subject: [PATCH] Fix assertion failures when reactivating plugins `.set_slices()` makes sure all slices' lengths are equal to the first argument, so in these functions we'll need to manually overwrite any existing element with empty slices. --- src/wrapper/clap/wrapper.rs | 12 +++++++++--- src/wrapper/vst3/wrapper.rs | 12 +++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/wrapper/clap/wrapper.rs b/src/wrapper/clap/wrapper.rs index ec0a9cb7..abfa59f8 100644 --- a/src/wrapper/clap/wrapper.rs +++ b/src/wrapper/clap/wrapper.rs @@ -1869,7 +1869,11 @@ impl Wrapper

{ .output_buffer .borrow_mut() .set_slices(0, |output_slices| { - output_slices.resize_with(bus_config.num_output_channels as usize, || &mut []) + output_slices.resize_with(bus_config.num_output_channels as usize, || &mut []); + // All slices must have the same length, so if the number of output channels has + // changed since the last call then we should make sure to clear any old + // (dangling) slices to be consistent + output_slices.fill_with(|| &mut []); }); // Also allocate both the buffers and the slices pointing to those buffers for sidechain @@ -1896,7 +1900,8 @@ impl Wrapper

{ channel_slices .resize_with(bus_config.aux_input_busses.num_channels as usize, || { &mut [] - }) + }); + channel_slices.fill_with(|| &mut []); }); } @@ -1911,7 +1916,8 @@ impl Wrapper

{ channel_slices .resize_with(bus_config.aux_output_busses.num_channels as usize, || { &mut [] - }) + }); + channel_slices.fill_with(|| &mut []); }); } diff --git a/src/wrapper/vst3/wrapper.rs b/src/wrapper/vst3/wrapper.rs index 4f2c6211..31087d69 100644 --- a/src/wrapper/vst3/wrapper.rs +++ b/src/wrapper/vst3/wrapper.rs @@ -405,7 +405,11 @@ impl IComponent for Wrapper

{ .borrow_mut() .set_slices(0, |output_slices| { output_slices - .resize_with(bus_config.num_output_channels as usize, || &mut []) + .resize_with(bus_config.num_output_channels as usize, || &mut []); + // All slices must have the same length, so if the number of output + // channels has changed since the last call then we should make sure to + // clear any old (dangling) slices to be consistent + output_slices.fill_with(|| &mut []); }); // Also allocate both the buffers and the slices pointing to those buffers for @@ -434,7 +438,8 @@ impl IComponent for Wrapper

{ channel_slices.resize_with( bus_config.aux_input_busses.num_channels as usize, || &mut [], - ) + ); + channel_slices.fill_with(|| &mut []); }); } @@ -449,7 +454,8 @@ impl IComponent for Wrapper

{ channel_slices.resize_with( bus_config.aux_output_busses.num_channels as usize, || &mut [], - ) + ); + channel_slices.fill_with(|| &mut []); }); }