Merge with trunk R2920.
[ardour.git] / libs / ardour / route.cc
index 0453129f75ffe202d228dd63b81de791e0a03bf4..084c4e58b5e949fb8e6e13eaa8d5157e61c83f78 100644 (file)
@@ -53,7 +53,7 @@ using namespace ARDOUR;
 using namespace PBD;
 
 uint32_t Route::order_key_cnt = 0;
-
+sigc::signal<void> Route::SyncOrderKeys;
 
 Route::Route (Session& sess, string name, int input_min, int input_max, int output_min, int output_max, Flag flg, DataType default_type)
        : IO (sess, name, input_min, input_max, output_min, output_max, default_type),
@@ -80,10 +80,11 @@ Route::init ()
        _muted = false;
        _soloed = false;
        _solo_safe = false;
+       _recordable = true;
+       _active = true;
        _phase_invert = false;
        _denormal_protection = false;
        order_keys[strdup (N_("signal"))] = order_key_cnt++;
-       _active = true;
        _silent = false;
        _meter_point = MeterPostFader;
        _initial_delay = 0;
@@ -161,9 +162,34 @@ void
 Route::set_order_key (const char* name, long n)
 {
        order_keys[strdup(name)] = n;
+
+       if (Config->get_sync_all_route_ordering()) {
+               for (OrderKeys::iterator x = order_keys.begin(); x != order_keys.end(); ++x) {
+                       x->second = n;
+               }
+       } 
+
        _session.set_dirty ();
 }
 
+void
+Route::sync_order_keys ()
+{
+       uint32_t key;
+       
+       if (order_keys.empty()) {
+               return;
+       }
+       
+       OrderKeys::iterator x = order_keys.begin();
+       key = x->second;
+       ++x;
+
+       for (; x != order_keys.end(); ++x) {
+               x->second = key;
+       }
+}
+
 void
 Route::inc_gain (gain_t fraction, void *src)
 {
@@ -316,7 +342,7 @@ Route::process_output_buffers (BufferSet& bufs,
           -------------------------------------------------------------------------------------------------- */
 
        if (meter && (_meter_point == MeterInput)) {
-               _meter->run(bufs, start_frame, end_frame, nframes, offset);
+               _meter->run_in_place(bufs, start_frame, end_frame, nframes, offset);
        }
 
        if (!_soloed && _mute_affects_pre_fader && (mute_gain != dmg)) {
@@ -460,13 +486,9 @@ Route::process_output_buffers (BufferSet& bufs,
                
            // OR recording 
                
-               // h/w monitoring not in use 
-               
-               (!Config->get_monitoring_model() == HardwareMonitoring && 
-
                 // AND software monitoring required
 
-                Config->get_monitoring_model() == SoftwareMonitoring)) { 
+               Config->get_monitoring_model() == SoftwareMonitoring) { 
                
                if (apply_gain_automation) {
                        
@@ -1221,6 +1243,8 @@ Route::apply_some_plugin_counts (list<ProcessorCount>& iclist)
 
        for (i = iclist.begin(); i != iclist.end(); ++i) {
                
+               cerr << "now applying for " << (*i).processor->name() << " in = " << (*i).in.n_audio() << " out = " << (*i).out.n_audio() << endl;
+
                if ((*i).processor->configure_io ((*i).in, (*i).out)) {
                        return -1;
                }
@@ -1249,6 +1273,9 @@ Route::check_some_plugin_counts (list<ProcessorCount>& iclist, ChanCount require
 
        for (i = iclist.begin(); i != iclist.end(); ++i) {
 
+
+               cerr << "Checking whether " << (*i).processor->name() << " can support " << required_inputs.n_audio() << " inputs\n";
+
                if ((*i).processor->can_support_input_configuration (required_inputs) < 0) {
                        if (err) {
                                err->index = index;
@@ -1260,6 +1287,8 @@ Route::check_some_plugin_counts (list<ProcessorCount>& iclist, ChanCount require
                (*i).in = required_inputs;
                (*i).out = (*i).processor->output_for_input_configuration (required_inputs);
 
+               cerr << "config looks like " << (*i).processor->name() << " in = " << (*i).in.n_audio() << " out = " << (*i).out.n_audio() << endl;
+
                required_inputs = (*i).out;
                
                ++index;
@@ -1634,10 +1663,14 @@ Route::add_processor_from_xml (const XMLNode& node)
                        if ((prop = node.property ("type")) != 0) {
 
                                boost::shared_ptr<Processor> processor;
+                               bool have_insert = false;
 
-                               if (prop->value() == "ladspa" || prop->value() == "Ladspa" || prop->value() == "vst") {
-
+                               if (prop->value() == "ladspa" || prop->value() == "Ladspa" || 
+                                   prop->value() == "vst" ||
+                                   prop->value() == "audiounit") {
+                                       
                                        processor.reset (new PluginInsert(_session, node));
+                                       have_insert = true;
                                        
                                } else if (prop->value() == "port") {
 
@@ -1646,19 +1679,20 @@ Route::add_processor_from_xml (const XMLNode& node)
                                } else if (prop->value() == "send") {
 
                                        processor.reset (new Send (_session, node));
+                                       have_insert = true;
 
                                } else {
 
                                        error << string_compose(_("unknown Processor type \"%1\"; ignored"), prop->value()) << endmsg;
                                }
-
+                               
                                add_processor (processor);
                                
                        } else {
                                error << _("Processor XML node has no type property") << endmsg;
                        }
                }
-               
+
                catch (failed_constructor &err) {
                        warning << _("processor could not be created. Ignored.") << endmsg;
                        return;
@@ -1704,7 +1738,8 @@ Route::_set_state (const XMLNode& node, bool call_base)
        if ((prop = node.property (X_("denormal-protection"))) != 0) {
                set_denormal_protection (prop->value()=="yes"?true:false, this);
        }
-
+       
+       _active = true;
        if ((prop = node.property (X_("active"))) != 0) {
                set_active (prop->value() == "yes");
        }
@@ -2067,7 +2102,7 @@ Route::set_control_outs (const vector<string>& ports)
        /* now connect to the named ports */
        
        for (size_t n = 0; n < limit; ++n) {
-               if (_control_outs->connect_output (_control_outs->output (n), ports[n], this)) {
+               if (_control_outs->connect_output (_control_outs->output (n), ports[n % ports.size()], this)) {
                        error << string_compose (_("could not connect %1 to %2"), _control_outs->output(n)->name(), ports[n]) << endmsg;
                        return -1;
                }