Change VST3 wrapper trait bounds to Vst3Plugin
To be consistent with the CLAP wrapper
This commit is contained in:
parent
6d1e581c26
commit
41663a404a
4 changed files with 19 additions and 19 deletions
|
@ -5,17 +5,17 @@ use std::sync::atomic::Ordering;
|
|||
use super::inner::{Task, WrapperInner};
|
||||
use crate::context::ProcessContext;
|
||||
use crate::event_loop::EventLoop;
|
||||
use crate::plugin::{NoteEvent, Plugin};
|
||||
use crate::plugin::{NoteEvent, Vst3Plugin};
|
||||
|
||||
/// A [ProcessContext] implementation for the wrapper. This is a separate object so it can hold on
|
||||
/// to lock guards for event queues. Otherwise reading these events would require constant
|
||||
/// unnecessary atomic operations to lock the uncontested RwLocks.
|
||||
pub(crate) struct WrapperProcessContext<'a, P: Plugin> {
|
||||
pub(crate) struct WrapperProcessContext<'a, P: Vst3Plugin> {
|
||||
pub inner: &'a WrapperInner<P>,
|
||||
pub input_events_guard: RwLockWriteGuard<'a, VecDeque<NoteEvent>>,
|
||||
}
|
||||
|
||||
impl<P: Plugin> ProcessContext for WrapperProcessContext<'_, P> {
|
||||
impl<P: Vst3Plugin> ProcessContext for WrapperProcessContext<'_, P> {
|
||||
fn set_latency_samples(&self, samples: u32) {
|
||||
// Only trigger a restart if it's actually needed
|
||||
let old_latency = self.inner.current_latency.swap(samples, Ordering::SeqCst);
|
||||
|
|
|
@ -14,13 +14,13 @@ use crate::buffer::Buffer;
|
|||
use crate::context::GuiContext;
|
||||
use crate::event_loop::{EventLoop, MainThreadExecutor, OsEventLoop};
|
||||
use crate::param::internals::ParamPtr;
|
||||
use crate::plugin::{BufferConfig, BusConfig, Editor, NoteEvent, Plugin, ProcessStatus};
|
||||
use crate::plugin::{BufferConfig, BusConfig, Editor, NoteEvent, ProcessStatus, Vst3Plugin};
|
||||
use crate::wrapper::util::hash_param_id;
|
||||
|
||||
/// The actual wrapper bits. We need this as an `Arc<T>` 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.
|
||||
pub(crate) struct WrapperInner<P: Plugin> {
|
||||
pub(crate) struct WrapperInner<P: Vst3Plugin> {
|
||||
/// The wrapped plugin instance.
|
||||
pub plugin: RwLock<P>,
|
||||
/// The plugin's editor, if it has one. This object does not do anything on its own, but we need
|
||||
|
@ -100,7 +100,7 @@ pub enum Task {
|
|||
TriggerRestart(i32),
|
||||
}
|
||||
|
||||
impl<P: Plugin> WrapperInner<P> {
|
||||
impl<P: Vst3Plugin> WrapperInner<P> {
|
||||
#[allow(unused_unsafe)]
|
||||
pub fn new() -> Arc<Self> {
|
||||
let plugin = RwLock::new(P::default());
|
||||
|
@ -229,7 +229,7 @@ impl<P: Plugin> WrapperInner<P> {
|
|||
// lifetime since we currently try to stay GUI framework agnostic. Because of that, the only
|
||||
// alternative is to pass an `Arc<Self as GuiContext>` to the plugin and hope it doesn't do anything
|
||||
// weird with it.
|
||||
impl<P: Plugin> GuiContext for WrapperInner<P> {
|
||||
impl<P: Vst3Plugin> GuiContext for WrapperInner<P> {
|
||||
// All of these functions are supposed to be called from the main thread, so we'll put some
|
||||
// trust in the caller and assume that this is indeed the case
|
||||
unsafe fn raw_begin_set_parameter(&self, param: ParamPtr) {
|
||||
|
@ -291,7 +291,7 @@ impl<P: Plugin> GuiContext for WrapperInner<P> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<P: Plugin> MainThreadExecutor<Task> for WrapperInner<P> {
|
||||
impl<P: Vst3Plugin> MainThreadExecutor<Task> for WrapperInner<P> {
|
||||
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
|
||||
|
|
|
@ -11,7 +11,7 @@ use vst3_sys::VST3;
|
|||
|
||||
use super::inner::WrapperInner;
|
||||
use super::util::{ObjectPtr, VstPtr};
|
||||
use crate::plugin::{Editor, Plugin};
|
||||
use crate::plugin::{Editor, Vst3Plugin};
|
||||
use crate::ParentWindowHandle;
|
||||
|
||||
// Alias needed for the VST3 attribute macro
|
||||
|
@ -32,7 +32,7 @@ const VST3_PLATFORM_X11_WINDOW: &str = "X11EmbedWindowID";
|
|||
/// The plugin's [IPlugView] instance created in [IEditController::create_view] if `P` has an
|
||||
/// editor. This is managed separately so the lifetime bounds match up.
|
||||
#[VST3(implements(IPlugView))]
|
||||
pub(crate) struct WrapperView<P: Plugin> {
|
||||
pub(crate) struct WrapperView<P: Vst3Plugin> {
|
||||
inner: Arc<WrapperInner<P>>,
|
||||
editor: Arc<dyn Editor>,
|
||||
editor_handle: RwLock<Option<Box<dyn Any>>>,
|
||||
|
@ -41,13 +41,13 @@ pub(crate) struct WrapperView<P: Plugin> {
|
|||
pub plug_frame: RwLock<Option<VstPtr<dyn IPlugFrame>>>,
|
||||
}
|
||||
|
||||
impl<P: Plugin> WrapperView<P> {
|
||||
impl<P: Vst3Plugin> WrapperView<P> {
|
||||
pub fn new(inner: Arc<WrapperInner<P>>, editor: Arc<dyn Editor>) -> Box<Self> {
|
||||
Self::allocate(inner, editor, RwLock::new(None), RwLock::new(None))
|
||||
}
|
||||
}
|
||||
|
||||
impl<P: Plugin> IPlugView for WrapperView<P> {
|
||||
impl<P: Vst3Plugin> IPlugView for WrapperView<P> {
|
||||
#[cfg(all(target_family = "unix", not(target_os = "macos")))]
|
||||
unsafe fn is_platform_type_supported(&self, type_: vst3_sys::base::FIDString) -> tresult {
|
||||
let type_ = CStr::from_ptr(type_);
|
||||
|
|
|
@ -21,7 +21,7 @@ use super::view::WrapperView;
|
|||
use crate::param::internals::ParamPtr;
|
||||
use crate::param::range::Range;
|
||||
use crate::param::Param;
|
||||
use crate::plugin::{BufferConfig, BusConfig, NoteEvent, Plugin, ProcessStatus};
|
||||
use crate::plugin::{BufferConfig, BusConfig, NoteEvent, ProcessStatus, Vst3Plugin};
|
||||
use crate::wrapper::state::{ParamValue, State};
|
||||
use crate::wrapper::util::{process_wrapper, u16strlcpy};
|
||||
|
||||
|
@ -29,17 +29,17 @@ use crate::wrapper::util::{process_wrapper, u16strlcpy};
|
|||
use vst3_sys as vst3_com;
|
||||
|
||||
#[VST3(implements(IComponent, IEditController, IAudioProcessor))]
|
||||
pub(crate) struct Wrapper<P: Plugin> {
|
||||
pub(crate) struct Wrapper<P: Vst3Plugin> {
|
||||
inner: Arc<WrapperInner<P>>,
|
||||
}
|
||||
|
||||
impl<P: Plugin> Wrapper<P> {
|
||||
impl<P: Vst3Plugin> Wrapper<P> {
|
||||
pub fn new() -> Box<Self> {
|
||||
Self::allocate(WrapperInner::new())
|
||||
}
|
||||
}
|
||||
|
||||
impl<P: Plugin> IPluginBase for Wrapper<P> {
|
||||
impl<P: Vst3Plugin> IPluginBase for Wrapper<P> {
|
||||
unsafe fn initialize(&self, _context: *mut c_void) -> tresult {
|
||||
// We currently don't need or allow any initialization logic
|
||||
kResultOk
|
||||
|
@ -50,7 +50,7 @@ impl<P: Plugin> IPluginBase for Wrapper<P> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<P: Plugin> IComponent for Wrapper<P> {
|
||||
impl<P: Vst3Plugin> IComponent for Wrapper<P> {
|
||||
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
|
||||
|
@ -375,7 +375,7 @@ impl<P: Plugin> IComponent for Wrapper<P> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<P: Plugin> IEditController for Wrapper<P> {
|
||||
impl<P: Vst3Plugin> IEditController for Wrapper<P> {
|
||||
unsafe fn set_component_state(&self, _state: SharedVstPtr<dyn IBStream>) -> tresult {
|
||||
// We have a single file component, so we don't need to do anything here
|
||||
kResultOk
|
||||
|
@ -587,7 +587,7 @@ impl<P: Plugin> IEditController for Wrapper<P> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<P: Plugin> IAudioProcessor for Wrapper<P> {
|
||||
impl<P: Vst3Plugin> IAudioProcessor for Wrapper<P> {
|
||||
unsafe fn set_bus_arrangements(
|
||||
&self,
|
||||
inputs: *mut vst3_sys::vst::SpeakerArrangement,
|
||||
|
|
Loading…
Add table
Reference in a new issue