>,
}
-/// 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> {
- inner: &'a WrapperInner,
- input_events_guard: RwLockWriteGuard<'a, VecDeque>,
-}
-
-impl 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);
- if old_latency != samples {
- let task_posted = unsafe { self.inner.event_loop.read().assume_init_ref() }
- .do_maybe_async(inner::Task::TriggerRestart(
- vst3_sys::vst::RestartFlags::kLatencyChanged as i32,
- ));
- nih_debug_assert!(task_posted, "The task queue is full, dropping task...");
- }
- }
-
- fn next_midi_event(&mut self) -> Option {
- self.input_events_guard.pop_front()
- }
-}
-
impl Wrapper {
pub fn new() -> Box {
Self::allocate(WrapperInner::new())
diff --git a/src/wrapper/vst3/context.rs b/src/wrapper/vst3/context.rs
new file mode 100644
index 00000000..0038ffdd
--- /dev/null
+++ b/src/wrapper/vst3/context.rs
@@ -0,0 +1,49 @@
+// nih-plug: plugins, but rewritten in Rust
+// Copyright (C) 2022 Robbert van der Helm
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
+use parking_lot::RwLockWriteGuard;
+use std::collections::VecDeque;
+use std::sync::atomic::Ordering;
+
+use super::inner::{Task, WrapperInner};
+use crate::context::{EventLoop, ProcessContext};
+use crate::plugin::{NoteEvent, Plugin};
+
+/// 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 inner: &'a WrapperInner,
+ pub input_events_guard: RwLockWriteGuard<'a, VecDeque>,
+}
+
+impl 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);
+ if old_latency != samples {
+ let task_posted = unsafe { self.inner.event_loop.read().assume_init_ref() }
+ .do_maybe_async(Task::TriggerRestart(
+ vst3_sys::vst::RestartFlags::kLatencyChanged as i32,
+ ));
+ nih_debug_assert!(task_posted, "The task queue is full, dropping task...");
+ }
+ }
+
+ fn next_midi_event(&mut self) -> Option {
+ self.input_events_guard.pop_front()
+ }
+}
diff --git a/src/wrapper/vst3/inner.rs b/src/wrapper/vst3/inner.rs
index 38e715b6..2a891f97 100644
--- a/src/wrapper/vst3/inner.rs
+++ b/src/wrapper/vst3/inner.rs
@@ -23,8 +23,8 @@ use std::sync::Arc;
use vst3_sys::base::{kInvalidArgument, kResultOk, tresult};
use vst3_sys::vst::IComponentHandler;
+use super::context::WrapperProcessContext;
use super::util::{VstPtr, BYPASS_PARAM_HASH, BYPASS_PARAM_ID};
-use super::WrapperProcessContext;
use crate::buffer::Buffer;
use crate::context::{EventLoop, GuiContext, MainThreadExecutor, OsEventLoop};
use crate::param::internals::ParamPtr;