From cf72a796f4b04b98b53ab868cd7fb303729b2e49 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Wed, 7 Sep 2022 18:38:07 +0200 Subject: [PATCH] Fix GUI context state loading in standalones --- src/wrapper/standalone/wrapper.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/wrapper/standalone/wrapper.rs b/src/wrapper/standalone/wrapper.rs index cbec7f7b..215aef6c 100644 --- a/src/wrapper/standalone/wrapper.rs +++ b/src/wrapper/standalone/wrapper.rs @@ -456,9 +456,19 @@ impl Wrapper { self.notify_param_values_changed(); - // TODO: Normally we'd also call initialize after deserializing state, but - // that's not guaranteed to be realtime safe. Should we do it anyways? - self.plugin.write().reset(); + // FIXME: This is obviously not realtime safe, but loading presets without + // doing this could lead to inconsistencies. It's the plugin's + // responsibility to not perform any realtime-unsafe work when the + // initialize function is called a second time if it supports + // runtime preset loading. + permit_alloc(|| { + plugin.initialize( + &self.bus_config, + &self.buffer_config, + &mut self.make_init_context(), + ) + }); + plugin.reset(); // We'll pass the state object back to the GUI thread so deallocation can // happen there without potentially blocking the audio thread