From 209c19b74f2cd66bbf75f65a5e81340cbefae4df Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Fri, 4 Feb 2022 22:53:42 +0100 Subject: [PATCH] Get rid of lifetime parameters for VST3 wrapper This lifetime didn't make any sense anyways since these buffers don't adhere to Rust's lifetime rules. Getting rid of these will let us make nicer wrappers around the process context. --- src/wrapper/vst3.rs | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/wrapper/vst3.rs b/src/wrapper/vst3.rs index 4322d353..55b1cfe5 100644 --- a/src/wrapper/vst3.rs +++ b/src/wrapper/vst3.rs @@ -85,7 +85,7 @@ macro_rules! check_null_ptr_msg { /// The actual wrapper bits. We need this as an `Arc` so we can safely use our event loop API. /// Since we can't combine that with VST3's interior reference counting this just has to be moved to /// its own struct. -struct WrapperInner<'a, P: Plugin> { +struct WrapperInner { /// The wrapped plugin instance. plugin: Pin>>, @@ -121,7 +121,7 @@ struct WrapperInner<'a, P: Plugin> { /// apointer to pointers, so this needs to be preallocated in the setup call and kept around /// between process calls. This buffer owns the vector, because otherwise it would need to store /// a mutable reference to the data contained in this mutex. - output_buffer: RwLock>, + output_buffer: RwLock>, /// The incoming events for the plugin, if `P::ACCEPTS_MIDI` is set. /// /// TODO: Maybe load these lazily at some point instead of needing to spool them all to this @@ -143,8 +143,9 @@ struct WrapperInner<'a, P: Plugin> { } #[VST3(implements(IComponent, IEditController, IAudioProcessor))] -pub(crate) struct Wrapper<'a, P: Plugin> { - inner: Arc>, +pub(crate) struct Wrapper { + inner: Arc>, +} } /// Tasks that can be sent from the plugin to be executed on the main thread in a non-blocking @@ -182,7 +183,7 @@ impl From> for VstPtr unsafe impl Send for VstPtr {} unsafe impl Sync for VstPtr {} -impl WrapperInner<'_, P> { +impl WrapperInner

{ // XXX: The unsafe blocks in this function are unnecessary. but rust-analyzer gets a bit // confused by all of these vtables #[allow(unused_unsafe)] @@ -256,7 +257,7 @@ impl WrapperInner<'_, P> { // FIXME: Right now this is safe, but if we are going to have a singleton main thread queue // serving multiple plugin instances, Arc can't be used because its reference count // is separate from the internal COM-style reference count. - let wrapper: Arc> = wrapper.into(); + let wrapper: Arc> = wrapper.into(); // XXX: This unsafe block is unnecessary. rust-analyzer gets a bit confused and this this // `write()` function is from `IBStream` which it definitely is not. *unsafe { wrapper.event_loop.write() } = @@ -295,13 +296,13 @@ impl WrapperInner<'_, P> { } } -impl Wrapper<'_, P> { +impl Wrapper

{ pub fn new() -> Box { Self::allocate(WrapperInner::new()) } } -impl MainThreadExecutor for WrapperInner<'_, P> { +impl MainThreadExecutor for WrapperInner

{ unsafe fn execute(&self, task: Task) { // This function is always called from the main thread // TODO: When we add GUI resizing and context menus, this should propagate those events to @@ -320,7 +321,7 @@ impl MainThreadExecutor for WrapperInner<'_, P> { } } -impl ProcessContext for WrapperInner<'_, P> { +impl ProcessContext for WrapperInner

{ fn set_latency_samples(&self, samples: u32) { // Only trigger a restart if it's actually needed let old_latency = self.current_latency.swap(samples, Ordering::SeqCst); @@ -337,7 +338,7 @@ impl ProcessContext for WrapperInner<'_, P> { } } -impl IPluginBase for Wrapper<'_, P> { +impl IPluginBase for Wrapper

{ unsafe fn initialize(&self, _context: *mut c_void) -> tresult { // We currently don't need or allow any initialization logic kResultOk @@ -348,7 +349,7 @@ impl IPluginBase for Wrapper<'_, P> { } } -impl IComponent for Wrapper<'_, P> { +impl IComponent for Wrapper

{ unsafe fn get_controller_class_id(&self, _tuid: *mut vst3_sys::IID) -> tresult { // We won't separate the edit controller to keep the implemetnation a bit smaller kNoInterface @@ -661,7 +662,7 @@ impl IComponent for Wrapper<'_, P> { } } -impl IEditController for Wrapper<'_, P> { +impl IEditController for Wrapper

{ unsafe fn set_component_state(&self, _state: SharedVstPtr) -> tresult { // We have a single file component, so we don't need to do anything here kResultOk @@ -867,7 +868,7 @@ impl IEditController for Wrapper<'_, P> { } } -impl IAudioProcessor for Wrapper<'_, P> { +impl IAudioProcessor for Wrapper

{ unsafe fn set_bus_arrangements( &self, inputs: *mut vst3_sys::vst::SpeakerArrangement,