diff --git a/src/plugin.rs b/src/plugin.rs index bb73d1a3..2aab1ab8 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -10,7 +10,10 @@ use crate::params::Params; use crate::wrapper::clap::features::ClapFeature; use crate::wrapper::state::PluginState; -pub type TaskExecutor
= Box = Box {
impl for WrapperInitContext<'_, P> {
fn execute(&self, task: P::BackgroundTask) {
- (self.wrapper.task_executor)(task);
+ (self.wrapper.task_executor.lock())(task);
}
fn plugin_api(&self) -> PluginApi {
diff --git a/src/wrapper/clap/wrapper.rs b/src/wrapper/clap/wrapper.rs
index 5c4f24a1..1fff8391 100644
--- a/src/wrapper/clap/wrapper.rs
+++ b/src/wrapper/clap/wrapper.rs
@@ -107,7 +107,7 @@ pub struct Wrapper ,
/// The plugin's background task executor closure.
- pub task_executor: TaskExecutor ,
+ pub task_executor: Mutex {
unsafe fn execute(&self, task: Task ) {
// This function is always called from the main thread, from [Self::on_main_thread].
match task {
- Task::PluginTask(task) => (self.task_executor)(task),
+ Task::PluginTask(task) => (self.task_executor.lock())(task),
Task::LatencyChanged => match &*self.host_latency.borrow() {
Some(host_latency) => {
// XXX: The CLAP docs mention that you should request a restart if this happens
@@ -387,7 +387,7 @@ impl {
impl {
pub fn new(host_callback: *const clap_host) -> Arc {
impl for WrapperInitContext<'_, P, B> {
fn execute(&self, task: P::BackgroundTask) {
- (self.wrapper.task_executor_wrapper.task_executor)(task);
+ (self.wrapper.task_executor_wrapper.task_executor.lock())(task);
}
fn plugin_api(&self) -> PluginApi {
diff --git a/src/wrapper/standalone/wrapper.rs b/src/wrapper/standalone/wrapper.rs
index a430eb8c..c3952d4f 100644
--- a/src/wrapper/standalone/wrapper.rs
+++ b/src/wrapper/standalone/wrapper.rs
@@ -141,12 +141,12 @@ impl WindowHandler for WrapperWindowHandler {
/// Adapter to make `TaskExecutor ` work as a `MainThreadExecutor`.
pub struct TaskExecutorWrapper ,
+ pub task_executor: Mutex {
unsafe fn execute(&self, task: P::BackgroundTask) {
- (self.task_executor)(task)
+ (self.task_executor.lock())(task)
}
}
@@ -156,7 +156,7 @@ impl {
pub fn new(backend: B, config: WrapperConfig) -> Result {
impl for WrapperInitContext<'_, P> {
fn execute(&self, task: P::BackgroundTask) {
- (self.inner.task_executor)(task);
+ (self.inner.task_executor.lock())(task);
}
fn plugin_api(&self) -> PluginApi {
diff --git a/src/wrapper/vst3/inner.rs b/src/wrapper/vst3/inner.rs
index d0216e6c..8c8b70eb 100644
--- a/src/wrapper/vst3/inner.rs
+++ b/src/wrapper/vst3/inner.rs
@@ -34,7 +34,7 @@ pub(crate) struct WrapperInner ,
/// The plugin's background task executor closure.
- pub task_executor: TaskExecutor ,
+ pub task_executor: Mutex {
#[allow(unused_unsafe)]
pub fn new() -> Arc {
// function for checking if a to be scheduled task can be handled right there and
// then).
match task {
- Task::PluginTask(task) => (self.task_executor)(task),
+ Task::PluginTask(task) => (self.task_executor.lock())(task),
Task::TriggerRestart(flags) => match &*self.component_handler.borrow() {
Some(handler) => {
handler.restart_component(flags);