+
+ l->start_write_pass (now);
+
+ if (rolling && am_touching) {
+ c->start_touch (now);
+ }
+ }
+ }
+}
+
+void
+Automatable::non_realtime_transport_stop (samplepos_t now, bool /*flush_processors*/)
+{
+ for (Controls::iterator li = controls().begin(); li != controls().end(); ++li) {
+ boost::shared_ptr<AutomationControl> c =
+ boost::dynamic_pointer_cast<AutomationControl>(li->second);
+ if (!c) {
+ continue;
+ }
+
+ 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);