NO-OP: whitespace
[ardour.git] / libs / ardour / automation_control.cc
index 7deeac422185e37c44684c5b680d917431d6aae6..a194e2858af4caf94f5161ae9427f1e8a26b1442 100644 (file)
@@ -100,7 +100,7 @@ double
 AutomationControl::get_value() const
 {
        bool from_list = alist() && alist()->automation_playback();
-       return Control::get_double (from_list, _session.transport_frame());
+       return Control::get_double (from_list, _session.transport_sample());
 }
 
 double
@@ -141,7 +141,7 @@ AutomationControl::set_value (double val, PBD::Controllable::GroupControlDisposi
        }
 
        if (_group && _group->use_me (gcd)) {
-               _group->set_group_value (shared_from_this(), val);
+               _group->set_group_value (boost::dynamic_pointer_cast<AutomationControl>(shared_from_this()), val);
        } else {
                actually_set_value (val, gcd);
        }
@@ -158,7 +158,7 @@ AutomationControl::grouped_controls () const
 }
 
 void
-AutomationControl::automation_run (framepos_t start, pframes_t nframes)
+AutomationControl::automation_run (samplepos_t start, pframes_t nframes)
 {
        if (!automation_playback ()) {
                return;
@@ -186,7 +186,7 @@ void
 AutomationControl::actually_set_value (double value, PBD::Controllable::GroupControlDisposition gcd)
 {
        boost::shared_ptr<AutomationList> al = alist ();
-       const framepos_t pos = _session.transport_frame();
+       const samplepos_t pos = _session.transport_sample();
        bool to_list;
 
        /* We cannot use ::get_value() here since that is virtual, and intended
@@ -252,25 +252,25 @@ AutomationControl::set_automation_state (AutoState as)
                }
 
                if (as == Write) {
-                       AutomationWatch::instance().add_automation_watch (shared_from_this());
-               } else if (as == Touch) {
+                       AutomationWatch::instance().add_automation_watch (boost::dynamic_pointer_cast<AutomationControl>(shared_from_this()));
+               } else if (as & (Touch | Latch)) {
                        if (alist()->empty()) {
-                               Control::set_double (val, _session.current_start_frame (), true);
-                               Control::set_double (val, _session.current_end_frame (), true);
+                               Control::set_double (val, _session.current_start_sample (), true);
+                               Control::set_double (val, _session.current_end_sample (), true);
                                Changed (true, Controllable::NoGroup);
                        }
                        if (!touching()) {
-                               AutomationWatch::instance().remove_automation_watch (shared_from_this());
+                               AutomationWatch::instance().remove_automation_watch (boost::dynamic_pointer_cast<AutomationControl>(shared_from_this()));
                        } else {
                                /* this seems unlikely, but the combination of
                                 * a control surface and the mouse could make
                                 * it possible to put the control into Touch
                                 * mode *while* touching it.
                                 */
-                               AutomationWatch::instance().add_automation_watch (shared_from_this());
+                               AutomationWatch::instance().add_automation_watch (boost::dynamic_pointer_cast<AutomationControl>(shared_from_this()));
                        }
                } else {
-                       AutomationWatch::instance().remove_automation_watch (shared_from_this());
+                       AutomationWatch::instance().remove_automation_watch (boost::dynamic_pointer_cast<AutomationControl>(shared_from_this()));
                        Changed (false, Controllable::NoGroup);
                }
        }
@@ -283,7 +283,7 @@ AutomationControl::start_touch (double when)
                return;
        }
 
-       if (alist()->automation_state() == Touch) {
+       if (alist()->automation_state() & (Touch | Latch)) {
                /* subtle. aligns the user value with the playback and
                 * use take actual value (incl masters).
                 *
@@ -293,7 +293,7 @@ AutomationControl::start_touch (double when)
                AutomationControl::actually_set_value (get_value (), Controllable::NoGroup);
                alist()->start_touch (when);
                if (!_desc.toggled) {
-                       AutomationWatch::instance().add_automation_watch (shared_from_this());
+                       AutomationWatch::instance().add_automation_watch (boost::dynamic_pointer_cast<AutomationControl>(shared_from_this()));
                }
                set_touching (true);
        }
@@ -306,12 +306,16 @@ AutomationControl::stop_touch (double when)
                return;
        }
 
+       if (alist()->automation_state() == Latch && _session.transport_rolling ()) {
+               return;
+       }
+
        set_touching (false);
 
-       if (alist()->automation_state() == Touch) {
+       if (alist()->automation_state() & (Touch | Latch)) {
                alist()->stop_touch (when);
                if (!_desc.toggled) {
-                       AutomationWatch::instance().remove_automation_watch (shared_from_this());
+                       AutomationWatch::instance().remove_automation_watch (boost::dynamic_pointer_cast<AutomationControl>(shared_from_this()));
                }
        }
 }
@@ -374,7 +378,7 @@ AutomationControl::check_rt (double val, Controllable::GroupControlDisposition g
 {
        if (!_session.loading() && (flags() & Controllable::RealTime) && !AudioEngine::instance()->in_process_thread()) {
                /* queue change in RT context */
-               _session.set_control (shared_from_this(), val, gcd);
+               _session.set_control (boost::dynamic_pointer_cast<AutomationControl>(shared_from_this()), val, gcd);
                return true;
        }