Remove beat entry from meter dialog (beats are not allowed in API), clean up some...
[ardour.git] / libs / ardour / route.cc
index 26b38658b4ed930a952accb451591250a19ece88..1b26dd8c7f21c6c1b771b3923b45a0d244bf18de 100644 (file)
@@ -41,6 +41,7 @@
 #include <ardour/panner.h>
 #include <ardour/dB.h>
 #include <ardour/mix.h>
+#include <ardour/profile.h>
 
 #include "i18n.h"
 
@@ -79,7 +80,6 @@ Route::init ()
        _phase_invert = false;
        _denormal_protection = false;
        order_keys[strdup (N_("signal"))] = order_key_cnt++;
-       _active = true;
        _silent = false;
        _meter_point = MeterPostFader;
        _initial_delay = 0;
@@ -185,6 +185,20 @@ Route::sync_order_keys ()
        }
 }
 
+string
+Route::ensure_track_or_route_name(string name, Session &session)
+{
+       string newname = name;
+
+       while (session.route_by_name (newname)!=NULL)
+       {
+               newname = bump_name_once (newname);
+       }
+
+       return newname;
+}
+
+
 void
 Route::inc_gain (gain_t fraction, void *src)
 {
@@ -903,8 +917,8 @@ Route::add_redirect (boost::shared_ptr<Redirect> redirect, void *src, uint32_t*
                reset_panner ();
        }
 
-
        redirects_changed (src); /* EMIT SIGNAL */
+
        return 0;
 }
 
@@ -1263,7 +1277,13 @@ Route::check_some_plugin_counts (list<InsertCount>& iclist, int32_t required_inp
                }
                
                (*i).in = required_inputs;
-               (*i).out = (*i).insert->compute_output_streams ((*i).cnt);
+
+               if (((*i).out = (*i).insert->compute_output_streams ((*i).cnt)) < 0) {
+                       if (err_streams) {
+                               *err_streams = required_inputs;
+                       }
+                       return -1;
+               }
 
                required_inputs = (*i).out;
        }
@@ -1449,7 +1469,6 @@ Route::state(bool full_state)
        
        node->add_property("default-type", _default_type.to_string());
 
-       node->add_property("active", _active?"yes":"no");
        node->add_property("muted", _muted?"yes":"no");
        node->add_property("soloed", _soloed?"yes":"no");
        node->add_property("phase-invert", _phase_invert?"yes":"no");
@@ -1560,22 +1579,30 @@ Route::add_redirect_from_xml (const XMLNode& node)
                        if ((prop = node.property ("type")) != 0) {
 
                                boost::shared_ptr<Insert> insert;
+                               bool have_insert = false;
 
-                               if (prop->value() == "ladspa" || prop->value() == "Ladspa" || prop->value() == "vst") {
-
+                               if (prop->value() == "ladspa" || prop->value() == "Ladspa" || 
+                                   prop->value() == "lv2" ||
+                                   prop->value() == "vst" ||
+                                   prop->value() == "audiounit") {
+                                       
                                        insert.reset (new PluginInsert(_session, node));
+                                       have_insert = true;
                                        
                                } else if (prop->value() == "port") {
 
 
                                        insert.reset (new PortInsert (_session, node));
+                                       have_insert = true;
 
                                } else {
 
                                        error << string_compose(_("unknown Insert type \"%1\"; ignored"), prop->value()) << endmsg;
                                }
 
-                               add_redirect (insert, this);
+                               if (have_insert) {
+                                       add_redirect (insert, this);
+                               }
                                
                        } else {
                                error << _("Insert XML node has no type property") << endmsg;
@@ -1628,10 +1655,6 @@ Route::_set_state (const XMLNode& node, bool call_base)
                set_denormal_protection (prop->value()=="yes"?true:false, this);
        }
 
-       if ((prop = node.property (X_("active"))) != 0) {
-               set_active (prop->value() == "yes");
-       }
-
        if ((prop = node.property (X_("muted"))) != 0) {
                bool yn = prop->value()=="yes"?true:false; 
 
@@ -2163,13 +2186,6 @@ Route::get_mute_config (mute_type t)
        return onoff;
 }
 
-void
-Route::set_active (bool yn)
-{
-       _active = yn; 
-        active_changed(); /* EMIT SIGNAL */
-}
-
 void
 Route::handle_transport_stopped (bool abort_ignored, bool did_locate, bool can_flush_redirects)
 {
@@ -2179,7 +2195,7 @@ Route::handle_transport_stopped (bool abort_ignored, bool did_locate, bool can_f
                Glib::RWLock::ReaderLock lm (redirect_lock);
 
                if (!did_locate) {
-                       automation_snapshot (now);
+                       automation_snapshot (now, true);
                }
 
                for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
@@ -2286,7 +2302,7 @@ Route::roll (nframes_t nframes, nframes_t start_frame, nframes_t end_frame, nfra
                if (lm.locked()) {
                        // automation snapshot can also be called from the non-rt context
                        // and it uses the redirect list, so we take the lock out here
-                       automation_snapshot (_session.transport_frame());
+                       automation_snapshot (_session.transport_frame(), false);
                }
        }
 
@@ -2427,12 +2443,16 @@ Route::set_latency_delay (nframes_t longest_session_latency)
 }
 
 void
-Route::automation_snapshot (nframes_t now)
+Route::automation_snapshot (nframes_t now, bool force)
 {
-       IO::automation_snapshot (now);
+       if (!force && !should_snapshot(now)) {
+               return;
+       }
+
+       IO::automation_snapshot (now, force);
 
        for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
-               (*i)->automation_snapshot (now);
+               (*i)->automation_snapshot (now, force);
        }
 }