Call Plugin::initialize() for runtime preset load
It's the plugin's responsibility to not do any realtime unsafe work here if they support runtime preset loading.
This commit is contained in:
parent
e8764e7327
commit
6fc0b2e148
|
@ -1876,9 +1876,21 @@ impl<P: ClapPlugin> Wrapper<P> {
|
||||||
|
|
||||||
wrapper.notify_param_values_changed();
|
wrapper.notify_param_values_changed();
|
||||||
|
|
||||||
// TODO: Normally we'd also call initialize after deserializing state, but that's
|
let bus_config = wrapper.current_bus_config.load();
|
||||||
// not guaranteed to be realtime safe. Should we do it anyways?
|
let buffer_config = wrapper.current_buffer_config.load().unwrap();
|
||||||
let mut plugin = wrapper.plugin.write();
|
let mut plugin = wrapper.plugin.write();
|
||||||
|
// 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(
|
||||||
|
&bus_config,
|
||||||
|
&buffer_config,
|
||||||
|
&mut wrapper
|
||||||
|
.make_process_context(Transport::new(buffer_config.sample_rate)),
|
||||||
|
)
|
||||||
|
});
|
||||||
plugin.reset();
|
plugin.reset();
|
||||||
|
|
||||||
// We'll pass the state object back to the GUI thread so deallocation can happen
|
// We'll pass the state object back to the GUI thread so deallocation can happen
|
||||||
|
|
|
@ -1278,9 +1278,22 @@ impl<P: Vst3Plugin> IAudioProcessor for Wrapper<P> {
|
||||||
|
|
||||||
self.inner.notify_param_values_changed();
|
self.inner.notify_param_values_changed();
|
||||||
|
|
||||||
// TODO: Normally we'd also call initialize after deserializing state, but that's
|
let bus_config = self.inner.current_bus_config.load();
|
||||||
// not guaranteed to be realtime safe. Should we do it anyways?
|
let buffer_config = self.inner.current_buffer_config.load().unwrap();
|
||||||
let mut plugin = self.inner.plugin.write();
|
let mut plugin = self.inner.plugin.write();
|
||||||
|
// 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(
|
||||||
|
&bus_config,
|
||||||
|
&buffer_config,
|
||||||
|
&mut self
|
||||||
|
.inner
|
||||||
|
.make_process_context(Transport::new(buffer_config.sample_rate)),
|
||||||
|
)
|
||||||
|
});
|
||||||
plugin.reset();
|
plugin.reset();
|
||||||
|
|
||||||
// We'll pass the state object back to the GUI thread so deallocation can happen
|
// We'll pass the state object back to the GUI thread so deallocation can happen
|
||||||
|
|
Loading…
Reference in a new issue