1
0
Fork 0

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.
This commit is contained in:
Robbert van der Helm 2023-02-02 16:15:43 +01:00
parent d7cefcd29a
commit 9c48e7f59b
2 changed files with 18 additions and 6 deletions

View file

@ -1869,7 +1869,11 @@ impl<P: ClapPlugin> Wrapper<P> {
.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<P: ClapPlugin> Wrapper<P> {
channel_slices
.resize_with(bus_config.aux_input_busses.num_channels as usize, || {
&mut []
})
});
channel_slices.fill_with(|| &mut []);
});
}
@ -1911,7 +1916,8 @@ impl<P: ClapPlugin> Wrapper<P> {
channel_slices
.resize_with(bus_config.aux_output_busses.num_channels as usize, || {
&mut []
})
});
channel_slices.fill_with(|| &mut []);
});
}

View file

@ -405,7 +405,11 @@ impl<P: Vst3Plugin> IComponent for Wrapper<P> {
.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<P: Vst3Plugin> IComponent for Wrapper<P> {
channel_slices.resize_with(
bus_config.aux_input_busses.num_channels as usize,
|| &mut [],
)
);
channel_slices.fill_with(|| &mut []);
});
}
@ -449,7 +454,8 @@ impl<P: Vst3Plugin> IComponent for Wrapper<P> {
channel_slices.resize_with(
bus_config.aux_output_busses.num_channels as usize,
|| &mut [],
)
);
channel_slices.fill_with(|| &mut []);
});
}