1
0
Fork 0

Delay the process_wrapper() use

The other parts also don't allocate, but parking_lot doesn't play nicely
when spawning an editor thread. In that case its hashmap may get resized
on the audio thread which is not what we want, but it won't cause any
real problems.
This commit is contained in:
Robbert van der Helm 2022-02-06 00:51:18 +01:00
parent 5c9ac31408
commit 29a9c41389

View file

@ -1124,9 +1124,6 @@ impl<P: Plugin> IAudioProcessor for Wrapper<P> {
unsafe fn process(&self, data: *mut vst3_sys::vst::ProcessData) -> tresult {
check_null_ptr!(data);
// Panic on allocations if the `assert_process_allocs` feature has been enabled, and make
// sure that FTZ is set up correctly
process_wrapper(|| {
// We need to handle incoming automation first
let data = &*data;
let sample_rate = self
@ -1233,9 +1230,7 @@ impl<P: Plugin> IAudioProcessor for Wrapper<P> {
{
let output_slices = output_buffer.as_raw_vec();
nih_debug_assert_eq!(num_output_channels, output_slices.len());
for (output_channel_idx, output_channel_slice) in
output_slices.iter_mut().enumerate()
{
for (output_channel_idx, output_channel_slice) in output_slices.iter_mut().enumerate() {
// SAFETY: These pointers may not be valid outside of this function even though
// their lifetime is equal to this structs. This is still safe because they are
// only dereferenced here later as part of this process function.
@ -1247,8 +1242,8 @@ impl<P: Plugin> IAudioProcessor for Wrapper<P> {
}
// Most hosts process data in place, in which case we don't need to do any copying
// ourselves. If the pointers do not alias, then we'll do the copy here and then the
// plugin can just do normal in place processing.
// ourselves. If the pointers do not alias, then we'll do the copy here and then the plugin
// can just do normal in place processing.
if !data.inputs.is_null() {
let num_input_channels = (*data.inputs).num_channels as usize;
nih_debug_assert!(
@ -1270,21 +1265,20 @@ impl<P: Plugin> IAudioProcessor for Wrapper<P> {
}
}
match self
.inner
.plugin
.write()
// SAFETY: Same here
.process(&mut output_buffer, &mut self.inner.make_process_context())
{
let mut plugin = self.inner.plugin.write();
let mut context = self.inner.make_process_context();
// Panic on allocations if the `assert_process_allocs` feature has been enabled, and make
// sure that FTZ is set up correctly
process_wrapper(
move || match plugin.process(&mut output_buffer, &mut context) {
ProcessStatus::Error(err) => {
nih_debug_assert_failure!("Process error: {}", err);
kResultFalse
}
_ => kResultOk,
}
})
},
)
}
unsafe fn get_tail_samples(&self) -> u32 {