- boost::shared_ptr<AutomationControl> c
- = boost::dynamic_pointer_cast<AutomationControl>(li->second);
- if (c) {
- boost::shared_ptr<AutomationList> l
- = boost::dynamic_pointer_cast<AutomationList>(c->list());
+ boost::shared_ptr<AutomationList> l =
+ boost::dynamic_pointer_cast<AutomationList>(c->list());
+ if (!l) {
+ continue;
+ }
+
+ /* Stop any active touch gesture just before we mark the write pass
+ as finished. If we don't do this, the transport can end up stopped with
+ an AutomationList thinking that a touch is still in progress and,
+ when the transport is re-started, a touch will magically
+ be happening without it ever have being started in the usual way.
+ */
+ const bool list_did_write = !l->in_new_write_pass ();
+
+ c->stop_touch (now);
+ l->stop_touch (now);
+
+ c->commit_transaction (list_did_write);
+
+ l->write_pass_finished (now, Config->get_automation_thinning_factor ());
+
+ if (l->automation_state () == Write) {
+ l->set_automation_state (Touch);
+ }
+
+ if (l->automation_playback ()) {
+ c->set_value_unchecked (c->list ()->eval (now));
+ }
+ }
+}
+
+void
+Automatable::automation_run (samplepos_t start, pframes_t nframes, bool only_active)
+{
+ if (only_active) {
+ boost::shared_ptr<ControlList> cl = _automated_controls.reader ();
+ for (ControlList::const_iterator ci = cl->begin(); ci != cl->end(); ++ci) {
+ (*ci)->automation_run (start, nframes);
+ }
+ return;
+ }