1
0
Fork 0

Reorder Context methods

This commit is contained in:
Robbert van der Helm 2022-10-22 13:13:08 +02:00
parent 5a974219b8
commit b1f24bfad9
4 changed files with 30 additions and 30 deletions

View file

@ -16,6 +16,9 @@ use crate::wrapper::state::PluginState;
// The implementing wrapper needs to be able to handle concurrent requests, and it should perform
// the actual callback within [MainThreadQueue::do_maybe_async].
pub trait InitContext<P: Plugin> {
/// Get the current plugin API.
fn plugin_api(&self) -> PluginApi;
/// Run a task directly on this thread. This ensures that the task has finished executing before
/// the plugin finishes initializing.
///
@ -25,9 +28,6 @@ pub trait InitContext<P: Plugin> {
/// behavior when doing offline rendering.
fn execute(&self, task: P::BackgroundTask);
/// Get the current plugin API.
fn plugin_api(&self) -> PluginApi;
/// Update the current latency of the plugin. If the plugin is currently processing audio, then
/// this may cause audio playback to be restarted.
fn set_latency_samples(&self, samples: u32);
@ -51,6 +51,9 @@ pub trait InitContext<P: Plugin> {
// The implementing wrapper needs to be able to handle concurrent requests, and it should perform
// the actual callback within [MainThreadQueue::do_maybe_async].
pub trait ProcessContext<P: Plugin> {
/// Get the current plugin API.
fn plugin_api(&self) -> PluginApi;
/// Run a task on a background thread. This allows defering expensive background tasks for
/// alter. As long as creating the `task` is realtime-safe, this operation is too.
///
@ -61,9 +64,6 @@ pub trait ProcessContext<P: Plugin> {
/// your task executor.
fn execute_async(&self, task: P::BackgroundTask);
/// Get the current plugin API.
fn plugin_api(&self) -> PluginApi;
/// Get information about the current transport position and status.
fn transport(&self) -> &Transport;

View file

@ -114,14 +114,14 @@ impl<P: ClapPlugin> GuiContext for WrapperGuiContext<P> {
}
impl<P: ClapPlugin> InitContext<P> for WrapperInitContext<'_, P> {
fn execute(&self, task: P::BackgroundTask) {
(self.wrapper.task_executor.lock())(task);
}
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)
}
@ -132,15 +132,15 @@ impl<P: ClapPlugin> InitContext<P> for WrapperInitContext<'_, P> {
}
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...");
}
fn plugin_api(&self) -> PluginApi {
PluginApi::Clap
}
#[inline]
fn transport(&self) -> &Transport {
&self.transport

View file

@ -79,14 +79,14 @@ impl<P: Plugin, B: Backend> GuiContext for WrapperGuiContext<P, B> {
}
impl<P: Plugin, B: Backend> InitContext<P> for WrapperInitContext<'_, P, B> {
fn execute(&self, task: P::BackgroundTask) {
(self.wrapper.task_executor_wrapper.task_executor.lock())(task);
}
fn plugin_api(&self) -> PluginApi {
PluginApi::Standalone
}
fn execute(&self, task: P::BackgroundTask) {
(self.wrapper.task_executor_wrapper.task_executor.lock())(task);
}
fn set_latency_samples(&self, _samples: u32) {
nih_debug_assert_failure!("TODO: WrapperInitContext::set_latency_samples()");
}
@ -97,15 +97,15 @@ impl<P: Plugin, B: Backend> InitContext<P> for WrapperInitContext<'_, P, B> {
}
impl<P: Plugin, B: Backend> ProcessContext<P> for WrapperProcessContext<'_, P, B> {
fn plugin_api(&self) -> PluginApi {
PluginApi::Standalone
}
fn execute_async(&self, task: P::BackgroundTask) {
let task_posted = self.wrapper.event_loop.do_maybe_async(task);
nih_debug_assert!(task_posted, "The task queue is full, dropping task...");
}
fn plugin_api(&self) -> PluginApi {
PluginApi::Standalone
}
#[inline]
fn transport(&self) -> &Transport {
&self.transport

View file

@ -116,14 +116,14 @@ impl<P: Vst3Plugin> GuiContext for WrapperGuiContext<P> {
}
impl<P: Vst3Plugin> InitContext<P> for WrapperInitContext<'_, P> {
fn execute(&self, task: P::BackgroundTask) {
(self.inner.task_executor.lock())(task);
}
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)
}
@ -134,15 +134,15 @@ impl<P: Vst3Plugin> InitContext<P> for WrapperInitContext<'_, P> {
}
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...");
}
fn plugin_api(&self) -> PluginApi {
PluginApi::Vst3
}
#[inline]
fn transport(&self) -> &Transport {
&self.transport