Make MIDI region `automation' respect the automation mode so that it is
[ardour.git] / libs / ardour / plugin_insert.cc
index af908a20365840c3c5ddeb0b53110fd32765259f..f50483beaf2e143f18424c439d5543f34766b67e 100644 (file)
@@ -62,35 +62,16 @@ using namespace PBD;
 const string PluginInsert::port_automation_node_name = "PortAutomation";
 
 PluginInsert::PluginInsert (Session& s, boost::shared_ptr<Plugin> plug)
-       : Processor (s, plug->name())
+       : Processor (s, (plug ? plug->name() : string ("toBeRenamed")))
        , _signal_analysis_collected_nframes(0)
        , _signal_analysis_collect_nframes_max(0)
 {
        /* the first is the master */
 
-       _plugins.push_back (plug);
-       set_automatable ();
+        if (plug) {
+                _plugins.push_back (plug);
+                set_automatable ();
 
-       {
-               Glib::Mutex::Lock em (_session.engine().process_lock());
-               IO::PortCountChanged (max(input_streams(), output_streams()));
-       }
-
-       ProcessorCreated (this); /* EMIT SIGNAL */
-}
-
-PluginInsert::PluginInsert (Session& s, const XMLNode& node)
-       : Processor (s, "unnamed plugin insert"),
-          _signal_analysis_collected_nframes(0),
-          _signal_analysis_collect_nframes_max(0)
-{
-       if (set_state (node, Stateful::loading_state_version)) {
-               throw failed_constructor();
-       }
-
-       _pending_active = _active;
-
-       {
                Glib::Mutex::Lock em (_session.engine().process_lock());
                IO::PortCountChanged (max(input_streams(), output_streams()));
        }
@@ -810,6 +791,8 @@ PluginInsert::set_state(const XMLNode& node, int version)
                }
        }
 
+        Processor::set_state (node, version);
+
        if (version < 3000) {
 
                for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
@@ -823,13 +806,20 @@ PluginInsert::set_state(const XMLNode& node, int version)
                set_parameter_state_2X (node, version);
                
        } else {
-               Processor::set_state (node, version);
+
                set_parameter_state (node, version);
        }
 
        // The name of the PluginInsert comes from the plugin, nothing else
        _name = plugin->get_info()->name;
 
+        /* catch up on I/O */
+
+       {
+               Glib::Mutex::Lock em (_session.engine().process_lock());
+               IO::PortCountChanged (max(input_streams(), output_streams()));
+       }
+
        return 0;
 }
 
@@ -975,30 +965,7 @@ PluginInsert::signal_latency() const
 ARDOUR::PluginType
 PluginInsert::type ()
 {
-       boost::shared_ptr<LadspaPlugin> lp;
-#ifdef VST_SUPPORT
-       boost::shared_ptr<VSTPlugin> vp;
-#endif
-#ifdef HAVE_AUDIOUNITS
-       boost::shared_ptr<AUPlugin> ap;
-#endif
-
-       PluginPtr other = plugin ();
-
-       if ((lp = boost::dynamic_pointer_cast<LadspaPlugin> (other)) != 0) {
-               return ARDOUR::LADSPA;
-#ifdef VST_SUPPORT
-       } else if ((vp = boost::dynamic_pointer_cast<VSTPlugin> (other)) != 0) {
-               return ARDOUR::VST;
-#endif
-#ifdef HAVE_AUDIOUNITS
-       } else if ((ap = boost::dynamic_pointer_cast<AUPlugin> (other)) != 0) {
-               return ARDOUR::AudioUnit;
-#endif
-       } else {
-               /* NOT REACHED */
-               return (ARDOUR::PluginType) 0;
-       }
+       return plugin()->get_info()->type;
 }
 
 PluginInsert::PluginControl::PluginControl (PluginInsert* p, const Evoral::Parameter &param, boost::shared_ptr<AutomationList> list)