Remove muting behaviour from the Amp processor. Fix some small
[ardour.git] / libs / ardour / route.cc
index e4052573b53819f14054f7c14ecfba265062d598..c0edb1a996c4b40234be723f62eba1758fb3f97b 100644 (file)
@@ -90,10 +90,7 @@ Route::Route (Session& sess, string name, Flag flg, DataType default_type)
        , _solo_control (new SoloControllable (X_("solo"), *this))
        , _mute_control (new MuteControllable (X_("mute"), *this))
        , _mute_master (new MuteMaster (sess, name))
-        , _mute_points (MuteMaster::AllPoints)
         , _have_internal_generator (false)
-        , _physically_connected (false)
-        , _graph_level (-1)
         , _solo_safe (false)
        , _default_type (default_type)
         , _remote_control_id (0)
@@ -124,7 +121,7 @@ Route::init ()
 
        /* add amp processor  */
 
-       _amp.reset (new Amp (_session, _mute_master));
+       _amp.reset (new Amp (_session));
        add_processor (_amp, PostFader);
 
        /* add standard processors: meter, main outs, monitor out */
@@ -539,8 +536,10 @@ Route::set_listen (bool yn, void* src)
                if (yn != _monitor_send->active()) {
                        if (yn) {
                                _monitor_send->activate ();
-                       } else {
+                                _mute_master->set_soloed (true);
+                        } else {
                                _monitor_send->deactivate ();
+                                _mute_master->set_soloed (false);
                        }
 
                        listen_changed (src); /* EMIT SIGNAL */
@@ -608,8 +607,6 @@ Route::mod_solo_by_others_upstream (int32_t delta)
 
         uint32_t old_sbu = _soloed_by_others_upstream;
 
-        cerr << name() << " SbU was " << old_sbu << " delta " << delta << " = ";
-
        if (delta < 0) {
                if (_soloed_by_others_upstream >= (uint32_t) abs (delta)) {
                        _soloed_by_others_upstream += delta;
@@ -620,7 +617,9 @@ Route::mod_solo_by_others_upstream (int32_t delta)
                _soloed_by_others_upstream += delta;
        }
 
-        cerr << _soloed_by_others_upstream << endl;
+        DEBUG_TRACE (DEBUG::Solo, string_compose ("%1 SbU delta %2 = %3 old = %4 sbd %5 ss %6 exclusive %7\n",
+                                                  name(), delta, _soloed_by_others_upstream, old_sbu, 
+                                                  _soloed_by_others_downstream, _self_solo, Config->get_exclusive_solo()));
 
         /* push the inverse solo change to everything that feeds us. 
            
@@ -635,28 +634,19 @@ Route::mod_solo_by_others_upstream (int32_t delta)
            not in reverse.
          */
 
-        cerr << name() << " SbU ... latched solo?  " << Config->get_solo_latched() << " delta = " << delta << endl;
-
-        bool push_inverse = false;
-
-        if (old_sbu > 0 && _soloed_by_others_upstream == 0 && _self_solo) {
-                /* we went back to non-soloed-by-others-upstream but we're still soloed push */
-                push_inverse = true;
-        }
+        if ((_self_solo || _soloed_by_others_downstream) &&
+            ((old_sbu == 0 && _soloed_by_others_upstream > 0) || 
+             (old_sbu > 0 && _soloed_by_others_upstream == 0))) {
                 
-        if (old_sbu == 0 && _soloed_by_others_upstream > 0) {
-                /* upstream made us solo when we weren't before */
-                push_inverse = true;
-        }
-
-        if (push_inverse) {
-                cerr << "\t ... INVERT push\n";
-                for (FedBy::iterator i = _fed_by.begin(); i != _fed_by.end(); ++i) {
-                        boost::shared_ptr<Route> sr = i->r.lock();
-                        if (sr) {
-                                sr->mod_solo_by_others_downstream (-delta);
+                if (delta > 0 || !Config->get_exclusive_solo()) {
+                        DEBUG_TRACE (DEBUG::Solo, "\t ... INVERT push\n");
+                        for (FedBy::iterator i = _fed_by.begin(); i != _fed_by.end(); ++i) {
+                                boost::shared_ptr<Route> sr = i->r.lock();
+                                if (sr) {
+                                        sr->mod_solo_by_others_downstream (-delta);
+                                }
                         }
-                }
+                } 
         }
 
         set_mute_master_solo ();
@@ -670,8 +660,6 @@ Route::mod_solo_by_others_downstream (int32_t delta)
                 return;
         }
 
-        cerr << name() << " SbD delta " << delta << " = ";     
-
         if (delta < 0) {
                if (_soloed_by_others_downstream >= (uint32_t) abs (delta)) {
                        _soloed_by_others_downstream += delta;
@@ -682,7 +670,7 @@ Route::mod_solo_by_others_downstream (int32_t delta)
                _soloed_by_others_downstream += delta;
        }
 
-        cerr << _soloed_by_others_downstream << endl;
+        DEBUG_TRACE (DEBUG::Solo, string_compose ("%1 SbD delta %2 = %3\n", name(), delta, _soloed_by_others_downstream));
 
         set_mute_master_solo ();
         solo_changed (false, this);
@@ -725,22 +713,27 @@ Route::set_solo_isolated (bool yn, void *src)
 
         /* XXX should we back-propagate as well? (April 2010: myself and chris goddard think not) */
 
+        bool changed = false;
+
        if (yn) {
                 if (_solo_isolated == 0) {
                         _mute_master->set_solo_ignore (true);
+                        changed = true;
                 }
                _solo_isolated++;
-                solo_isolated_changed (src);
        } else {
                if (_solo_isolated > 0) {
                        _solo_isolated--;
                         if (_solo_isolated == 0) {
                                 _mute_master->set_solo_ignore (false);
+                                changed = true;
                         }
-                        solo_isolated_changed (src);
                }
        }
 
+        if (changed) {
+                solo_isolated_changed (src);
+        }
 }
 
 bool
@@ -752,8 +745,7 @@ Route::solo_isolated () const
 void
 Route::set_mute_points (MuteMaster::MutePoint mp)
 {
-        _mute_points = mp;
-        _mute_master->set_mute_points (MuteMaster::AllPoints);
+        _mute_master->set_mute_points (mp);
         mute_points_changed (); /* EMIT SIGNAL */
         
         if (_mute_master->muted()) {
@@ -897,6 +889,7 @@ Route::add_processor (boost::shared_ptr<Processor> processor, ProcessorList::ite
        }
 
        processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
+       set_processor_positions ();
 
        return 0;
 }
@@ -1041,6 +1034,7 @@ Route::add_processors (const ProcessorList& others, ProcessorList::iterator iter
        }
 
        processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
+       set_processor_positions ();
 
        return 0;
 }
@@ -1241,6 +1235,7 @@ Route::clear_processors (Placement p)
        processor_max_streams.reset();
        _have_internal_generator = false;
        processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
+       set_processor_positions ();
 
        if (!already_deleting) {
                _session.clear_deletion_in_progress();
@@ -1332,6 +1327,7 @@ Route::remove_processor (boost::shared_ptr<Processor> processor, ProcessorStream
 
        processor->drop_references ();
        processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
+       set_processor_positions ();
 
        return 0;
 }
@@ -1423,6 +1419,7 @@ Route::remove_processors (const ProcessorList& to_be_deleted, ProcessorStreams*
        }
 
        processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
+       set_processor_positions ();
 
        return 0;
 }
@@ -1668,6 +1665,7 @@ Route::reorder_processors (const ProcessorList& new_order, ProcessorStreams* err
 
         if (true) {
                 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
+               set_processor_positions ();
         }
 
        return 0;
@@ -2315,6 +2313,7 @@ Route::set_processor_state (const XMLNode& node)
         }
 
         processors_changed (RouteProcessorChange ());
+       set_processor_positions ();
 }
 
 void
@@ -2588,12 +2587,6 @@ Route::direct_feeds (boost::shared_ptr<Route> other, bool* only_send)
        return false;
 }
 
-void
-Route::check_physical_connections ()
-{
-        _physically_connected = _output->physically_connected ();
-}
-
 void
 Route::handle_transport_stopped (bool /*abort_ignored*/, bool did_locate, bool can_flush_processors)
 {
@@ -3365,8 +3358,22 @@ Route::has_io_processor_named (const string& name)
         return false;
 }
 
+MuteMaster::MutePoint
+Route::mute_points () const
+{
+       return _mute_master->mute_points ();
+}
+
 void
-Route::set_graph_level (int32_t l)
+Route::set_processor_positions ()
 {
-        _graph_level = l;
+       Glib::RWLock::ReaderLock lm (_processor_lock);
+
+       bool had_amp = false;
+       for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
+               (*i)->set_pre_fader (!had_amp);
+               if (boost::dynamic_pointer_cast<Amp> (*i)) {
+                       had_amp = true;
+               }
+       }
 }