Collect plugin runtime profile statistics.
[ardour.git] / libs / ardour / mac_vst_plugin.cc
index 2cb7301ce800116699daf653a57344929c4dfb18..0b52096e6aff7951ebbdaf87742cca0241a71cdc 100644 (file)
@@ -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,15 +55,15 @@ 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;
+
+       init_plugin ();
 }
 
 MacVSTPlugin::~MacVSTPlugin ()
@@ -70,6 +71,13 @@ MacVSTPlugin::~MacVSTPlugin ()
        mac_vst_close (_state);
 }
 
+void
+MacVSTPlugin::open_plugin ()
+{
+       VSTPlugin::open_plugin ();
+       _plugin->dispatcher (_plugin, effCanDo, 0, 0, const_cast<char*> ("hasCockosViewAsConfig"), 0.0f);
+}
+
 PluginPtr
 MacVSTPluginInfo::load (Session& session)
 {
@@ -118,6 +126,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->ptr1 = NULL;
 
                plugin->dispatcher (plugin, effOpen, 0, 0, 0, 0); // :(
                int const vst_version = plugin->dispatcher (plugin, effGetVstVersion, 0, 0, NULL, 0);