From 86f0f0ca114a10f273d857e942144c568d6a720d Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 21 Sep 2022 16:13:18 +0200 Subject: [PATCH] Fix VST2 state restore for plugins without custom UI VST preset restore has to happen in the GUI thread, specifically the plugin's own UI event-loop (which on Linux and Windows is not usually Ardour's Thread 1). However if there is no plugin GUI, it should be safe to use Ardour's UI thread. --- libs/ardour/vst_plugin.cc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/libs/ardour/vst_plugin.cc b/libs/ardour/vst_plugin.cc index c9aa5b1807..3228761cc3 100644 --- a/libs/ardour/vst_plugin.cc +++ b/libs/ardour/vst_plugin.cc @@ -40,6 +40,7 @@ #include "ardour/session.h" #include "ardour/filesystem_paths.h" #include "ardour/audio_buffer.h" +#include "ardour/plugin_insert.h" #include "pbd/i18n.h" @@ -464,7 +465,13 @@ VSTPlugin::load_plugin_preset (PresetRecord r) sscanf (r.uri.c_str(), "VST:%d:%d", &id, &index); #endif _state->want_program = index; - LoadPresetProgram (); /* EMIT SIGNAL */ /* used for macvst */ + if (!has_editor () || 0 == plugin_insert ()->window_proxy ()) { + vststate_maybe_set_program (_state); + _state->want_chunk = 0; + _state->want_program = -1; + } else { + LoadPresetProgram (); /* EMIT SIGNAL */ /* used for macvst */ + } return true; } @@ -506,7 +513,13 @@ VSTPlugin::load_user_preset (PresetRecord r) _state->wanted_chunk = raw_data; _state->wanted_chunk_size = size; _state->want_chunk = 1; - LoadPresetProgram (); /* EMIT SIGNAL */ /* used for macvst */ + if (!has_editor () || 0 == plugin_insert ()->window_proxy ()) { + vststate_maybe_set_program (_state); + _state->want_chunk = 0; + _state->want_program = -1; + } else { + LoadPresetProgram (); /* EMIT SIGNAL */ /* used for macvst */ + } return true; } }