diff options
author | Robin Gareus <robin@gareus.org> | 2017-03-06 23:49:40 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2017-03-07 00:13:56 +0100 |
commit | e1095310a8186bbd977534285df0ab29423d3aa3 (patch) | |
tree | eae28a2a01773762ae77bf7b12c1270df7d468cb /libs/ardour/mac_vst_plugin.cc | |
parent | 589c13c0eb9f6003a7e8cf923110459c897ea4b0 (diff) |
Rework VST initialization:
Set the AEffect* plugin pointer before calling effOpen.
effOpen may call back into the host (masterCallback) and invoke
actions which depend on _plugin (eg. to call back into the plugin again)
Diffstat (limited to 'libs/ardour/mac_vst_plugin.cc')
-rw-r--r-- | libs/ardour/mac_vst_plugin.cc | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/libs/ardour/mac_vst_plugin.cc b/libs/ardour/mac_vst_plugin.cc index 8fc87aaeec..b8f82325c6 100644 --- a/libs/ardour/mac_vst_plugin.cc +++ b/libs/ardour/mac_vst_plugin.cc @@ -40,9 +40,10 @@ MacVSTPlugin::MacVSTPlugin (AudioEngine& e, Session& session, VSTHandle* h, int if ((_state = mac_vst_instantiate (_handle, Session::vst_callback, this)) == 0) { throw failed_constructor (); } + open_plugin (); Session::vst_current_loading_id = 0; - set_plugin (_state->plugin); + init_plugin (); } MacVSTPlugin::MacVSTPlugin (const MacVSTPlugin &other) @@ -54,17 +55,16 @@ MacVSTPlugin::MacVSTPlugin (const MacVSTPlugin &other) if ((_state = mac_vst_instantiate (_handle, Session::vst_callback, this)) == 0) { throw failed_constructor (); } + open_plugin (); Session::vst_current_loading_id = 0; - _plugin = _state->plugin; - XMLNode* root = new XMLNode (other.state_node_name ()); LocaleGuard lg; other.add_state (root); set_state (*root, Stateful::loading_state_version); delete root; - set_plugin (_state->plugin); + init_plugin (); } MacVSTPlugin::~MacVSTPlugin () @@ -72,6 +72,13 @@ MacVSTPlugin::~MacVSTPlugin () mac_vst_close (_state); } +void +MacVSTPlugin::open_plugin () +{ + VSTPlugin::open_plugin (); + _plugin->dispatcher (mac_vst->plugin, effCanDo, 0, 0, const_cast<char*> ("hasCockosViewAsConfig"), 0.0f); +} + PluginPtr MacVSTPluginInfo::load (Session& session) { @@ -120,6 +127,7 @@ MacVSTPluginInfo::get_presets (bool user_only) const Session::vst_current_loading_id = atoi (unique_id); AEffect* plugin = handle->main_entry (Session::vst_callback); Session::vst_current_loading_id = 0; + plugin->user = NULL; plugin->dispatcher (plugin, effOpen, 0, 0, 0, 0); // :( int const vst_version = plugin->dispatcher (plugin, effGetVstVersion, 0, 0, NULL, 0); |