Rearrange the wrapper context modules
This matches the order in `src/context.rs`.
This commit is contained in:
parent
b1f24bfad9
commit
faa9742eee
|
@ -9,13 +9,6 @@ use crate::midi::NoteEvent;
|
||||||
use crate::params::internals::ParamPtr;
|
use crate::params::internals::ParamPtr;
|
||||||
use crate::plugin::ClapPlugin;
|
use crate::plugin::ClapPlugin;
|
||||||
|
|
||||||
/// A [`GuiContext`] implementation for the wrapper. This is passed to the plugin in
|
|
||||||
/// [`Editor::spawn()`][crate::prelude::Editor::spawn()] so it can interact with the rest of the plugin and
|
|
||||||
/// with the host for things like setting parameters.
|
|
||||||
pub(crate) struct WrapperGuiContext<P: ClapPlugin> {
|
|
||||||
pub(super) wrapper: Arc<Wrapper<P>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A [`InitContext`] implementation for the wrapper. This is a separate object so it can hold on
|
/// A [`InitContext`] 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
|
/// to lock guards for event queues. Otherwise reading these events would require constant
|
||||||
/// unnecessary atomic operations to lock the uncontested RwLocks.
|
/// unnecessary atomic operations to lock the uncontested RwLocks.
|
||||||
|
@ -33,6 +26,63 @@ pub(crate) struct WrapperProcessContext<'a, P: ClapPlugin> {
|
||||||
pub(super) transport: Transport,
|
pub(super) transport: Transport,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A [`GuiContext`] implementation for the wrapper. This is passed to the plugin in
|
||||||
|
/// [`Editor::spawn()`][crate::prelude::Editor::spawn()] so it can interact with the rest of the plugin and
|
||||||
|
/// with the host for things like setting parameters.
|
||||||
|
pub(crate) struct WrapperGuiContext<P: ClapPlugin> {
|
||||||
|
pub(super) wrapper: Arc<Wrapper<P>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<P: ClapPlugin> InitContext<P> for WrapperInitContext<'_, P> {
|
||||||
|
fn plugin_api(&self) -> PluginApi {
|
||||||
|
PluginApi::Clap
|
||||||
|
}
|
||||||
|
|
||||||
|
fn execute(&self, task: P::BackgroundTask) {
|
||||||
|
(self.wrapper.task_executor.lock())(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_latency_samples(&self, samples: u32) {
|
||||||
|
self.wrapper.set_latency_samples(samples)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_current_voice_capacity(&self, capacity: u32) {
|
||||||
|
self.wrapper.set_current_voice_capacity(capacity)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<P: ClapPlugin> ProcessContext<P> for WrapperProcessContext<'_, P> {
|
||||||
|
fn plugin_api(&self) -> PluginApi {
|
||||||
|
PluginApi::Clap
|
||||||
|
}
|
||||||
|
|
||||||
|
fn execute_async(&self, task: P::BackgroundTask) {
|
||||||
|
let task_posted = self.wrapper.do_maybe_async(Task::PluginTask(task));
|
||||||
|
nih_debug_assert!(task_posted, "The task queue is full, dropping task...");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn transport(&self) -> &Transport {
|
||||||
|
&self.transport
|
||||||
|
}
|
||||||
|
|
||||||
|
fn next_event(&mut self) -> Option<NoteEvent> {
|
||||||
|
self.input_events_guard.pop_front()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn send_event(&mut self, event: NoteEvent) {
|
||||||
|
self.output_events_guard.push_back(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_latency_samples(&self, samples: u32) {
|
||||||
|
self.wrapper.set_latency_samples(samples)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_current_voice_capacity(&self, capacity: u32) {
|
||||||
|
self.wrapper.set_current_voice_capacity(capacity)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<P: ClapPlugin> GuiContext for WrapperGuiContext<P> {
|
impl<P: ClapPlugin> GuiContext for WrapperGuiContext<P> {
|
||||||
fn plugin_api(&self) -> PluginApi {
|
fn plugin_api(&self) -> PluginApi {
|
||||||
PluginApi::Clap
|
PluginApi::Clap
|
||||||
|
@ -112,53 +162,3 @@ impl<P: ClapPlugin> GuiContext for WrapperGuiContext<P> {
|
||||||
self.wrapper.set_state_object(state)
|
self.wrapper.set_state_object(state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<P: ClapPlugin> InitContext<P> for WrapperInitContext<'_, P> {
|
|
||||||
fn plugin_api(&self) -> PluginApi {
|
|
||||||
PluginApi::Clap
|
|
||||||
}
|
|
||||||
|
|
||||||
fn execute(&self, task: P::BackgroundTask) {
|
|
||||||
(self.wrapper.task_executor.lock())(task);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_latency_samples(&self, samples: u32) {
|
|
||||||
self.wrapper.set_latency_samples(samples)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_current_voice_capacity(&self, capacity: u32) {
|
|
||||||
self.wrapper.set_current_voice_capacity(capacity)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<P: ClapPlugin> ProcessContext<P> for WrapperProcessContext<'_, P> {
|
|
||||||
fn plugin_api(&self) -> PluginApi {
|
|
||||||
PluginApi::Clap
|
|
||||||
}
|
|
||||||
|
|
||||||
fn execute_async(&self, task: P::BackgroundTask) {
|
|
||||||
let task_posted = self.wrapper.do_maybe_async(Task::PluginTask(task));
|
|
||||||
nih_debug_assert!(task_posted, "The task queue is full, dropping task...");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn transport(&self) -> &Transport {
|
|
||||||
&self.transport
|
|
||||||
}
|
|
||||||
|
|
||||||
fn next_event(&mut self) -> Option<NoteEvent> {
|
|
||||||
self.input_events_guard.pop_front()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn send_event(&mut self, event: NoteEvent) {
|
|
||||||
self.output_events_guard.push_back(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_latency_samples(&self, samples: u32) {
|
|
||||||
self.wrapper.set_latency_samples(samples)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_current_voice_capacity(&self, capacity: u32) {
|
|
||||||
self.wrapper.set_current_voice_capacity(capacity)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -9,17 +9,6 @@ use crate::midi::NoteEvent;
|
||||||
use crate::params::internals::ParamPtr;
|
use crate::params::internals::ParamPtr;
|
||||||
use crate::plugin::Plugin;
|
use crate::plugin::Plugin;
|
||||||
|
|
||||||
/// A [`GuiContext`] implementation for the wrapper. This is passed to the plugin in
|
|
||||||
/// [`Editor::spawn()`][crate::prelude::Editor::spawn()] so it can interact with the rest of the plugin and
|
|
||||||
/// with the host for things like setting parameters.
|
|
||||||
pub(crate) struct WrapperGuiContext<P: Plugin, B: Backend> {
|
|
||||||
pub(super) wrapper: Arc<Wrapper<P, B>>,
|
|
||||||
|
|
||||||
/// This allows us to send tasks to the parent view that will be handled at the start of its
|
|
||||||
/// next frame.
|
|
||||||
pub(super) gui_task_sender: channel::Sender<GuiTask>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A [`InitContext`] implementation for the standalone wrapper. This is a separate object so it
|
/// A [`InitContext`] implementation for the standalone wrapper. This is a separate object so it
|
||||||
/// can hold on to lock guards for event queues. Otherwise reading these events would require
|
/// can hold on to lock guards for event queues. Otherwise reading these events would require
|
||||||
/// constant unnecessary atomic operations to lock the uncontested RwLocks.
|
/// constant unnecessary atomic operations to lock the uncontested RwLocks.
|
||||||
|
@ -41,41 +30,15 @@ pub(crate) struct WrapperProcessContext<'a, P: Plugin, B: Backend> {
|
||||||
pub(super) transport: Transport,
|
pub(super) transport: Transport,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<P: Plugin, B: Backend> GuiContext for WrapperGuiContext<P, B> {
|
/// A [`GuiContext`] implementation for the wrapper. This is passed to the plugin in
|
||||||
fn plugin_api(&self) -> PluginApi {
|
/// [`Editor::spawn()`][crate::prelude::Editor::spawn()] so it can interact with the rest of the plugin and
|
||||||
PluginApi::Standalone
|
/// with the host for things like setting parameters.
|
||||||
}
|
pub(crate) struct WrapperGuiContext<P: Plugin, B: Backend> {
|
||||||
|
pub(super) wrapper: Arc<Wrapper<P, B>>,
|
||||||
|
|
||||||
fn request_resize(&self) -> bool {
|
/// This allows us to send tasks to the parent view that will be handled at the start of its
|
||||||
let (unscaled_width, unscaled_height) = self.wrapper.editor.as_ref().unwrap().lock().size();
|
/// next frame.
|
||||||
|
pub(super) gui_task_sender: channel::Sender<GuiTask>,
|
||||||
// This will cause the editor to be resized at the start of the next frame
|
|
||||||
let push_successful = self
|
|
||||||
.gui_task_sender
|
|
||||||
.send(GuiTask::Resize(unscaled_width, unscaled_height))
|
|
||||||
.is_ok();
|
|
||||||
nih_debug_assert!(push_successful, "Could not queue window resize");
|
|
||||||
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe fn raw_begin_set_parameter(&self, _param: ParamPtr) {
|
|
||||||
// Since there's no automation being recorded here, gestures don't mean anything
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe fn raw_set_parameter_normalized(&self, param: ParamPtr, normalized: f32) {
|
|
||||||
self.wrapper.set_parameter(param, normalized);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe fn raw_end_set_parameter(&self, _param: ParamPtr) {}
|
|
||||||
|
|
||||||
fn get_state(&self) -> crate::wrapper::state::PluginState {
|
|
||||||
self.wrapper.get_state_object()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_state(&self, state: crate::wrapper::state::PluginState) {
|
|
||||||
self.wrapper.set_state_object(state)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<P: Plugin, B: Backend> InitContext<P> for WrapperInitContext<'_, P, B> {
|
impl<P: Plugin, B: Backend> InitContext<P> for WrapperInitContext<'_, P, B> {
|
||||||
|
@ -135,3 +98,40 @@ impl<P: Plugin, B: Backend> ProcessContext<P> for WrapperProcessContext<'_, P, B
|
||||||
// This is only supported by CLAP
|
// This is only supported by CLAP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<P: Plugin, B: Backend> GuiContext for WrapperGuiContext<P, B> {
|
||||||
|
fn plugin_api(&self) -> PluginApi {
|
||||||
|
PluginApi::Standalone
|
||||||
|
}
|
||||||
|
|
||||||
|
fn request_resize(&self) -> bool {
|
||||||
|
let (unscaled_width, unscaled_height) = self.wrapper.editor.as_ref().unwrap().lock().size();
|
||||||
|
|
||||||
|
// This will cause the editor to be resized at the start of the next frame
|
||||||
|
let push_successful = self
|
||||||
|
.gui_task_sender
|
||||||
|
.send(GuiTask::Resize(unscaled_width, unscaled_height))
|
||||||
|
.is_ok();
|
||||||
|
nih_debug_assert!(push_successful, "Could not queue window resize");
|
||||||
|
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe fn raw_begin_set_parameter(&self, _param: ParamPtr) {
|
||||||
|
// Since there's no automation being recorded here, gestures don't mean anything
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe fn raw_set_parameter_normalized(&self, param: ParamPtr, normalized: f32) {
|
||||||
|
self.wrapper.set_parameter(param, normalized);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe fn raw_end_set_parameter(&self, _param: ParamPtr) {}
|
||||||
|
|
||||||
|
fn get_state(&self) -> crate::wrapper::state::PluginState {
|
||||||
|
self.wrapper.get_state_object()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_state(&self, state: crate::wrapper::state::PluginState) {
|
||||||
|
self.wrapper.set_state_object(state)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -11,13 +11,6 @@ use crate::params::internals::ParamPtr;
|
||||||
use crate::plugin::Vst3Plugin;
|
use crate::plugin::Vst3Plugin;
|
||||||
use crate::wrapper::state::PluginState;
|
use crate::wrapper::state::PluginState;
|
||||||
|
|
||||||
/// A [`GuiContext`] implementation for the wrapper. This is passed to the plugin in
|
|
||||||
/// [`Editor::spawn()`][crate::prelude::Editor::spawn()] so it can interact with the rest of the plugin and
|
|
||||||
/// with the host for things like setting parameters.
|
|
||||||
pub(crate) struct WrapperGuiContext<P: Vst3Plugin> {
|
|
||||||
pub(super) inner: Arc<WrapperInner<P>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A [`InitContext`] implementation for the wrapper. This is a separate object so it can hold on to
|
/// A [`InitContext`] 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
|
/// lock guards for event queues. Otherwise reading these events would require constant unnecessary
|
||||||
/// atomic operations to lock the uncontested locks.
|
/// atomic operations to lock the uncontested locks.
|
||||||
|
@ -35,6 +28,63 @@ pub(crate) struct WrapperProcessContext<'a, P: Vst3Plugin> {
|
||||||
pub(super) transport: Transport,
|
pub(super) transport: Transport,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A [`GuiContext`] implementation for the wrapper. This is passed to the plugin in
|
||||||
|
/// [`Editor::spawn()`][crate::prelude::Editor::spawn()] so it can interact with the rest of the plugin and
|
||||||
|
/// with the host for things like setting parameters.
|
||||||
|
pub(crate) struct WrapperGuiContext<P: Vst3Plugin> {
|
||||||
|
pub(super) inner: Arc<WrapperInner<P>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<P: Vst3Plugin> InitContext<P> for WrapperInitContext<'_, P> {
|
||||||
|
fn plugin_api(&self) -> PluginApi {
|
||||||
|
PluginApi::Vst3
|
||||||
|
}
|
||||||
|
|
||||||
|
fn execute(&self, task: P::BackgroundTask) {
|
||||||
|
(self.inner.task_executor.lock())(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_latency_samples(&self, samples: u32) {
|
||||||
|
self.inner.set_latency_samples(samples)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_current_voice_capacity(&self, _capacity: u32) {
|
||||||
|
// This is only supported by CLAP
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<P: Vst3Plugin> ProcessContext<P> for WrapperProcessContext<'_, P> {
|
||||||
|
fn plugin_api(&self) -> PluginApi {
|
||||||
|
PluginApi::Vst3
|
||||||
|
}
|
||||||
|
|
||||||
|
fn execute_async(&self, task: P::BackgroundTask) {
|
||||||
|
let task_posted = self.inner.do_maybe_async(Task::PluginTask(task));
|
||||||
|
nih_debug_assert!(task_posted, "The task queue is full, dropping task...");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn transport(&self) -> &Transport {
|
||||||
|
&self.transport
|
||||||
|
}
|
||||||
|
|
||||||
|
fn next_event(&mut self) -> Option<NoteEvent> {
|
||||||
|
self.input_events_guard.pop_front()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn send_event(&mut self, event: NoteEvent) {
|
||||||
|
self.output_events_guard.push_back(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_latency_samples(&self, samples: u32) {
|
||||||
|
self.inner.set_latency_samples(samples)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_current_voice_capacity(&self, _capacity: u32) {
|
||||||
|
// This is only supported by CLAP
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<P: Vst3Plugin> GuiContext for WrapperGuiContext<P> {
|
impl<P: Vst3Plugin> GuiContext for WrapperGuiContext<P> {
|
||||||
fn plugin_api(&self) -> PluginApi {
|
fn plugin_api(&self) -> PluginApi {
|
||||||
PluginApi::Vst3
|
PluginApi::Vst3
|
||||||
|
@ -114,53 +164,3 @@ impl<P: Vst3Plugin> GuiContext for WrapperGuiContext<P> {
|
||||||
self.inner.set_state_object(state)
|
self.inner.set_state_object(state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<P: Vst3Plugin> InitContext<P> for WrapperInitContext<'_, P> {
|
|
||||||
fn plugin_api(&self) -> PluginApi {
|
|
||||||
PluginApi::Vst3
|
|
||||||
}
|
|
||||||
|
|
||||||
fn execute(&self, task: P::BackgroundTask) {
|
|
||||||
(self.inner.task_executor.lock())(task);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_latency_samples(&self, samples: u32) {
|
|
||||||
self.inner.set_latency_samples(samples)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_current_voice_capacity(&self, _capacity: u32) {
|
|
||||||
// This is only supported by CLAP
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<P: Vst3Plugin> ProcessContext<P> for WrapperProcessContext<'_, P> {
|
|
||||||
fn plugin_api(&self) -> PluginApi {
|
|
||||||
PluginApi::Vst3
|
|
||||||
}
|
|
||||||
|
|
||||||
fn execute_async(&self, task: P::BackgroundTask) {
|
|
||||||
let task_posted = self.inner.do_maybe_async(Task::PluginTask(task));
|
|
||||||
nih_debug_assert!(task_posted, "The task queue is full, dropping task...");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn transport(&self) -> &Transport {
|
|
||||||
&self.transport
|
|
||||||
}
|
|
||||||
|
|
||||||
fn next_event(&mut self) -> Option<NoteEvent> {
|
|
||||||
self.input_events_guard.pop_front()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn send_event(&mut self, event: NoteEvent) {
|
|
||||||
self.output_events_guard.push_back(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_latency_samples(&self, samples: u32) {
|
|
||||||
self.inner.set_latency_samples(samples)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_current_voice_capacity(&self, _capacity: u32) {
|
|
||||||
// This is only supported by CLAP
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue