Flush processor (re-activate) on route active change
[ardour.git] / libs / ardour / slavable_automation_control.cc
index 9acf7444ad8114f2e0a3bc6fb197848091be59fa..63784dc3a5bd52b947771d18f8941499af41a507 100644 (file)
@@ -95,22 +95,6 @@ SlavableAutomationControl::get_value_locked() const
        return Control::get_double() * get_masters_value_locked ();
 }
 
-void
-SlavableAutomationControl::actually_set_value (double value, PBD::Controllable::GroupControlDisposition gcd)
-{
-       {
-               Glib::Threads::RWLock::WriterLock lm (master_lock);
-
-               if (!_masters.empty()) {
-                       /* need to scale given value by current master's scaling */
-                       value /= get_masters_value_locked();
-               }
-       }
-
-       /* this will call Control::set_double() and emit Changed signals as appropriate */
-       AutomationControl::actually_set_value (value, gcd);
-}
-
 /** Get the current effective `user' value based on automation state */
 double
 SlavableAutomationControl::get_value() const
@@ -125,6 +109,29 @@ SlavableAutomationControl::get_value() const
        }
 }
 
+void
+SlavableAutomationControl::actually_set_value (double value, PBD::Controllable::GroupControlDisposition gcd)
+{
+       if (!_desc.toggled) {
+
+               Glib::Threads::RWLock::WriterLock lm (master_lock);
+
+               if (!_masters.empty()) {
+                       /* need to scale given value by current master's scaling */
+                       const double masters_value = get_masters_value_locked();
+                       if (masters_value == 0.0) {
+                               value = 0.0;
+                       } else {
+                               value /= masters_value;
+                               value = std::max (lower(), std::min(upper(), value));
+                       }
+               }
+       }
+
+       /* this will call Control::set_double() and emit Changed signals as appropriate */
+       AutomationControl::actually_set_value (value, gcd);
+}
+
 void
 SlavableAutomationControl::add_master (boost::shared_ptr<AutomationControl> m, bool loading)
 {
@@ -144,7 +151,7 @@ SlavableAutomationControl::add_master (boost::shared_ptr<AutomationControl> m, b
                                        const double master_value = m->get_value();
 
                                        if (master_value == 0.0) {
-                                               actually_set_value (0.0, Controllable::NoGroup);
+                                               AutomationControl::set_double (0.0, Controllable::NoGroup);
                                        } else {
                                                /* scale control's own value by
                                                   amount that the master will
@@ -263,8 +270,6 @@ SlavableAutomationControl::master_going_away (boost::weak_ptr<AutomationControl>
 void
 SlavableAutomationControl::remove_master (boost::shared_ptr<AutomationControl> m)
 {
-       Masters::size_type erased = 0;
-
        pre_remove_master (m);
 
        {
@@ -298,9 +303,7 @@ SlavableAutomationControl::remove_master (boost::shared_ptr<AutomationControl> m
                return;
        }
 
-       if (erased) {
-               MasterStatusChange (); /* EMIT SIGNAL */
-       }
+       MasterStatusChange (); /* EMIT SIGNAL */
 
        /* no need to update boolean masters records, since the MR will have
         * been removed already.