+Diskstream::playlist_ranges_moved (list< Evoral::RangeMove<framepos_t> > const & movements_frames, bool from_undo)
+{
+ /* If we're coming from an undo, it will have handled
+ automation undo (it must, since automation-follows-regions
+ can lose automation data). Hence we can do nothing here.
+ */
+
+ if (from_undo) {
+ return;
+ }
+
+ if (!_track || Config->get_automation_follows_regions () == false) {
+ return;
+ }
+
+ list< Evoral::RangeMove<double> > movements;
+
+ for (list< Evoral::RangeMove<framepos_t> >::const_iterator i = movements_frames.begin();
+ i != movements_frames.end();
+ ++i) {
+
+ movements.push_back(Evoral::RangeMove<double>(i->from, i->length, i->to));
+ }
+
+ /* move panner automation */
+ boost::shared_ptr<Pannable> pannable = _track->pannable();
+ Evoral::ControlSet::Controls& c (pannable->controls());
+
+ for (Evoral::ControlSet::Controls::iterator ci = c.begin(); ci != c.end(); ++ci) {
+ boost::shared_ptr<AutomationControl> ac = boost::dynamic_pointer_cast<AutomationControl>(ci->second);
+ if (!ac) {
+ continue;
+ }
+ boost::shared_ptr<AutomationList> alist = ac->alist();
+
+ XMLNode & before = alist->get_state ();
+ bool const things_moved = alist->move_ranges (movements);
+ if (things_moved) {
+ _session.add_command (new MementoCommand<AutomationList> (
+ *alist.get(), &before, &alist->get_state ()));
+ }
+ }
+
+ /* move processor automation */
+ _track->foreach_processor (boost::bind (&Diskstream::move_processor_automation, this, _1, movements_frames));
+}
+
+void
+Diskstream::move_processor_automation (boost::weak_ptr<Processor> p, list< Evoral::RangeMove<framepos_t> > const & movements_frames)
+{
+ boost::shared_ptr<Processor> processor (p.lock ());
+ if (!processor) {
+ return;
+ }
+
+ list< Evoral::RangeMove<double> > movements;
+ for (list< Evoral::RangeMove<framepos_t> >::const_iterator i = movements_frames.begin(); i != movements_frames.end(); ++i) {
+ movements.push_back(Evoral::RangeMove<double>(i->from, i->length, i->to));
+ }
+
+ set<Evoral::Parameter> const a = processor->what_can_be_automated ();
+
+ for (set<Evoral::Parameter>::const_iterator i = a.begin (); i != a.end (); ++i) {
+ boost::shared_ptr<AutomationList> al = processor->automation_control(*i)->alist();
+ XMLNode & before = al->get_state ();
+ bool const things_moved = al->move_ranges (movements);
+ if (things_moved) {
+ _session.add_command (
+ new MementoCommand<AutomationList> (
+ *al.get(), &before, &al->get_state ()
+ )
+ );
+ }
+ }
+}
+
+void
+Diskstream::check_record_status (framepos_t transport_frame, bool can_record)
+{
+ int possibly_recording;
+ int rolling;
+ int change;
+ const int transport_rolling = 0x4;
+ const int track_rec_enabled = 0x2;
+ const int global_rec_enabled = 0x1;
+ const int fully_rec_enabled = (transport_rolling|track_rec_enabled|global_rec_enabled);
+
+ /* merge together the 3 factors that affect record status, and compute
+ * what has changed.
+ */
+
+ rolling = _session.transport_speed() != 0.0f;
+ possibly_recording = (rolling << 2) | ((int)record_enabled() << 1) | (int)can_record;
+ change = possibly_recording ^ last_possibly_recording;
+
+ if (possibly_recording == last_possibly_recording) {
+ return;
+ }
+
+ const framecnt_t existing_material_offset = _session.worst_playback_latency();
+
+ if (possibly_recording == fully_rec_enabled) {
+
+ if (last_possibly_recording == fully_rec_enabled) {
+ return;
+ }
+
+ capture_start_frame = _session.transport_frame();
+ first_recordable_frame = capture_start_frame + _capture_offset;
+ last_recordable_frame = max_framepos;
+
+ DEBUG_TRACE (DEBUG::CaptureAlignment, string_compose ("%1: @ %7 (%9) FRF = %2 CSF = %4 CO = %5, EMO = %6 RD = %8 WOL %10 WTL %11\n",
+ name(), first_recordable_frame, last_recordable_frame, capture_start_frame,
+ _capture_offset,
+ existing_material_offset,
+ transport_frame,
+ _roll_delay,
+ _session.transport_frame(),
+ _session.worst_output_latency(),
+ _session.worst_track_latency()));
+
+
+ if (_alignment_style == ExistingMaterial) {
+ first_recordable_frame += existing_material_offset;
+ DEBUG_TRACE (DEBUG::CaptureAlignment, string_compose ("\tshift FRF by EMO %1\n",
+ first_recordable_frame));
+ }
+
+ prepare_record_status (capture_start_frame);
+
+ } else {
+
+ if (last_possibly_recording == fully_rec_enabled) {
+
+ /* we were recording last time */
+
+ if (change & transport_rolling) {
+
+ /* transport-change (stopped rolling): last_recordable_frame was set in ::prepare_to_stop(). We
+ * had to set it there because we likely rolled past the stopping point to declick out,
+ * and then backed up.
+ */
+
+ } else {
+ /* punch out */
+
+ last_recordable_frame = _session.transport_frame() + _capture_offset;
+
+ if (_alignment_style == ExistingMaterial) {
+ last_recordable_frame += existing_material_offset;
+ }
+ }
+ }
+ }
+
+ last_possibly_recording = possibly_recording;
+}
+
+void
+Diskstream::route_going_away ()