set latency of sidechain port
[ardour.git] / libs / ardour / route.cc
index 5335d69502c258970b91d1dc012ace0e05c79c0a..6209b9f91159a11507e14b31c7dfeee9a1109fcd 100644 (file)
@@ -84,8 +84,8 @@ PBD::Signal3<int,boost::shared_ptr<Route>, boost::shared_ptr<PluginInsert>, Rout
 
 /** Base class for all routable/mixable objects (tracks and busses) */
 Route::Route (Session& sess, string name, PresentationInfo::Flag flag, DataType default_type)
-       : GraphNode (sess._process_graph)
-       , Stripable (sess, name, PresentationInfo (flag))
+       : Stripable (sess, name, PresentationInfo (flag))
+       , GraphNode (sess._process_graph)
        , Muteable (sess, name)
        , Automatable (sess)
        , _active (true)
@@ -317,6 +317,8 @@ Route::process_output_buffers (BufferSet& bufs,
                return;
        }
 
+       _mute_control->automation_run (start_frame, nframes);
+
        /* figure out if we're going to use gain automation */
        if (gain_automation_ok) {
                _amp->set_gain_automation_buffer (_session.gain_automation_buffer ());
@@ -442,6 +444,11 @@ Route::process_output_buffers (BufferSet& bufs,
                if (boost::dynamic_pointer_cast<Send>(*i) != 0) {
                        boost::dynamic_pointer_cast<Send>(*i)->set_delay_in(_signal_latency - latency);
                }
+               if (boost::dynamic_pointer_cast<PluginInsert>(*i) != 0) {
+                       const framecnt_t longest_session_latency = _initial_delay + _signal_latency;
+                       boost::dynamic_pointer_cast<PluginInsert>(*i)->set_sidechain_latency (
+                                       _initial_delay + latency, longest_session_latency - latency);
+               }
 
                (*i)->run (bufs, start_frame - latency, end_frame - latency, nframes, *i != _processors.back());
                bufs.set_count ((*i)->output_streams());
@@ -1617,8 +1624,8 @@ Route::try_configure_processors_unlocked (ChanCount in, ProcessorStreams* err)
 
                        if (boost::dynamic_pointer_cast<Delivery> (*p)
                                        && boost::dynamic_pointer_cast<Delivery> (*p)->role() == Delivery::Main
-                                       && !(is_monitor() || is_auditioner())
-                                       && ( _strict_io || Profile->get_mixbus ())) {
+                                       && !is_auditioner()
+                                       && (is_monitor() || _strict_io || Profile->get_mixbus ())) {
                                /* with strict I/O the panner + output are forced to
                                 * follow the last processor's output.
                                 *
@@ -2237,7 +2244,7 @@ Route::state(bool full_state)
        node->add_property("default-type", _default_type.to_string());
        node->add_property ("strict-io", _strict_io);
 
-       Stripable::add_state (*node);
+       node->add_child_nocopy (_presentation_info.get_state());
 
        node->add_property("active", _active?"yes":"no");
        string p;
@@ -2826,9 +2833,14 @@ Route::set_processor_state (const XMLNode& node)
        }
 
        {
-               Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
                Glib::Threads::RWLock::WriterLock lm (_processor_lock);
+               /* re-assign _processors w/o process-lock.
+                * if there's an IO-processor present in _processors but
+                * not in new_order, it will be deleted and ~IO takes
+                * a process lock.
+                */
                _processors = new_order;
+               Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
 
                if (must_configure) {
                        configure_processors_unlocked (0, &lm);