From 12240c8db7631db358ac113cb82e8ae28721951e Mon Sep 17 00:00:00 2001 From: Micah Johnston Date: Mon, 2 Sep 2024 23:33:24 -0500 Subject: [PATCH] clap: factor out Instance::sync_processor method --- src/format/clap/instance.rs | 44 +++++++++++++------------------------ 1 file changed, 15 insertions(+), 29 deletions(-) diff --git a/src/format/clap/instance.rs b/src/format/clap/instance.rs index c3b4b71..5999bf9 100644 --- a/src/format/clap/instance.rs +++ b/src/format/clap/instance.rs @@ -146,6 +146,18 @@ impl Instance

{ } } } + + fn sync_processor(&self, events: &mut Vec) { + for (index, value) in self.processor_params.poll() { + events.push(Event { + time: 0, + data: Data::ParamChange { + id: self.info.params[index].id, + value, + }, + }); + } + } } impl Instance

{ @@ -229,15 +241,7 @@ impl Instance

{ if let Some(processor) = &mut process_state.processor { // Flush plugin -> processor parameter changes process_state.events.clear(); - for (index, value) in instance.processor_params.poll() { - process_state.events.push(Event { - time: 0, - data: Data::ParamChange { - id: instance.info.params[index].id, - value, - }, - }); - } + instance.sync_processor(&mut process_state.events); if !process_state.events.is_empty() { process_state.buffer_ptrs.fill(NonNull::dangling().as_ptr()); @@ -326,16 +330,7 @@ impl Instance

{ } process_state.events.clear(); - - for (index, value) in instance.processor_params.poll() { - process_state.events.push(Event { - time: 0, - data: Data::ParamChange { - id: instance.info.params[index].id, - value, - }, - }); - } + instance.sync_processor(&mut process_state.events); let mut params_changed = false; @@ -693,16 +688,7 @@ impl Instance

{ process_state.buffer_ptrs.fill(NonNull::dangling().as_ptr()); process_state.events.clear(); - - for (index, value) in instance.processor_params.poll() { - process_state.events.push(Event { - time: 0, - data: Data::ParamChange { - id: instance.info.params[index].id, - value, - }, - }); - } + instance.sync_processor(&mut process_state.events); let mut params_changed = false;