1
0
Fork 0

Put the no_alloc guard around entire process call

This commit is contained in:
Robbert van der Helm 2022-02-06 15:24:18 +01:00
parent f644ae8df8
commit 3bd3696abe

View file

@ -1129,6 +1129,9 @@ impl<P: Plugin> IAudioProcessor for Wrapper<P> {
unsafe fn process(&self, data: *mut vst3_sys::vst::ProcessData) -> tresult { unsafe fn process(&self, data: *mut vst3_sys::vst::ProcessData) -> tresult {
check_null_ptr!(data); 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 // We need to handle incoming automation first
let data = &*data; let data = &*data;
let sample_rate = self let sample_rate = self
@ -1145,8 +1148,8 @@ impl<P: Plugin> IAudioProcessor for Wrapper<P> {
let param_hash = param_change_queue.get_parameter_id(); let param_hash = param_change_queue.get_parameter_id();
let num_changes = param_change_queue.get_point_count(); let num_changes = param_change_queue.get_point_count();
// TODO: Handle sample accurate parameter changes, possibly in a similar way to // TODO: Handle sample accurate parameter changes, possibly in a similar way
// the smoothing // to the smoothing
let mut sample_offset = 0i32; let mut sample_offset = 0i32;
let mut value = 0.0f64; let mut value = 0.0f64;
if num_changes > 0 if num_changes > 0
@ -1235,7 +1238,9 @@ impl<P: Plugin> IAudioProcessor for Wrapper<P> {
{ {
let output_slices = output_buffer.as_raw_vec(); let output_slices = output_buffer.as_raw_vec();
nih_debug_assert_eq!(num_output_channels, output_slices.len()); 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 // 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 // their lifetime is equal to this structs. This is still safe because they are
// only dereferenced here later as part of this process function. // only dereferenced here later as part of this process function.
@ -1247,8 +1252,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 // 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 // ourselves. If the pointers do not alias, then we'll do the copy here and then the
// can just do normal in place processing. // plugin can just do normal in place processing.
if !data.inputs.is_null() { if !data.inputs.is_null() {
let num_input_channels = (*data.inputs).num_channels as usize; let num_input_channels = (*data.inputs).num_channels as usize;
nih_debug_assert!( nih_debug_assert!(
@ -1272,18 +1277,15 @@ impl<P: Plugin> IAudioProcessor for Wrapper<P> {
let mut plugin = self.inner.plugin.write(); let mut plugin = self.inner.plugin.write();
let mut context = self.inner.make_process_context(); let mut context = self.inner.make_process_context();
// Panic on allocations if the `assert_process_allocs` feature has been enabled, and make match plugin.process(&mut output_buffer, &mut context) {
// sure that FTZ is set up correctly
process_wrapper(
move || match plugin.process(&mut output_buffer, &mut context) {
ProcessStatus::Error(err) => { ProcessStatus::Error(err) => {
nih_debug_assert_failure!("Process error: {}", err); nih_debug_assert_failure!("Process error: {}", err);
kResultFalse kResultFalse
} }
_ => kResultOk, _ => kResultOk,
}, }
) })
} }
unsafe fn get_tail_samples(&self) -> u32 { unsafe fn get_tail_samples(&self) -> u32 {