1
0
Fork 0

Handle idempotent latency changes

This commit is contained in:
Robbert van der Helm 2022-02-01 17:17:10 +01:00
parent e2e2c59d34
commit 473447179f

View file

@ -294,13 +294,16 @@ impl<P: Plugin> MainThreadExecutor<Task> for WrapperInner<'_, P> {
impl<P: Plugin> ProcessContext for WrapperInner<'_, P> { impl<P: Plugin> ProcessContext for WrapperInner<'_, P> {
fn set_latency_samples(&self, samples: u32) { fn set_latency_samples(&self, samples: u32) {
self.current_latency.store(samples, Ordering::SeqCst); // Only trigger a restart if it's actually needed
let old_latency = self.current_latency.swap(samples, Ordering::SeqCst);
if old_latency != samples {
let task_posted = unsafe { self.event_loop.read().assume_init_ref() }.do_maybe_async( let task_posted = unsafe { self.event_loop.read().assume_init_ref() }.do_maybe_async(
Task::TriggerRestart(vst3_sys::vst::RestartFlags::kLatencyChanged as i32), Task::TriggerRestart(vst3_sys::vst::RestartFlags::kLatencyChanged as i32),
); );
nih_debug_assert!(task_posted, "The task queue is full, dropping task..."); nih_debug_assert!(task_posted, "The task queue is full, dropping task...");
} }
} }
}
impl<P: Plugin> IPluginBase for Wrapper<'_, P> { impl<P: Plugin> IPluginBase for Wrapper<'_, P> {
unsafe fn initialize(&self, _context: *mut c_void) -> tresult { unsafe fn initialize(&self, _context: *mut c_void) -> tresult {