+
+ 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>::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) | (record_enabled() << 1) | can_record;
+ change = possibly_recording ^ last_possibly_recording;
+
+ if (possibly_recording == last_possibly_recording) {
+ return;
+ }
+
+ 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 ()
+{
+ _io.reset ();
+}
+
+void
+Diskstream::calculate_record_range (Evoral::OverlapType ot, framepos_t transport_frame, framecnt_t nframes,
+ framecnt_t & rec_nframes, framecnt_t & rec_offset)
+{
+ switch (ot) {
+ case Evoral::OverlapNone:
+ rec_nframes = 0;
+ break;
+
+ case Evoral::OverlapInternal:
+ /* ---------- recrange
+ |---| transrange
+ */
+ rec_nframes = nframes;
+ rec_offset = 0;
+ break;
+
+ case Evoral::OverlapStart:
+ /* |--------| recrange
+ -----| transrange
+ */
+ rec_nframes = transport_frame + nframes - first_recordable_frame;
+ if (rec_nframes) {
+ rec_offset = first_recordable_frame - transport_frame;
+ }
+ break;
+
+ case Evoral::OverlapEnd:
+ /* |--------| recrange
+ |-------- transrange
+ */
+ rec_nframes = last_recordable_frame - transport_frame;
+ rec_offset = 0;
+ break;
+
+ case Evoral::OverlapExternal:
+ /* |--------| recrange
+ -------------- transrange
+ */
+ rec_nframes = last_recordable_frame - first_recordable_frame;
+ rec_offset = first_recordable_frame - transport_frame;
+ break;
+ }
+
+ DEBUG_TRACE (DEBUG::CaptureAlignment, string_compose ("%1 rec? %2 @ %3 (for %4) FRF %5 LRF %6 : rf %7 @ %8\n",
+ _name, enum_2_string (ot), transport_frame, nframes,
+ first_recordable_frame, last_recordable_frame, rec_nframes, rec_offset));
+}
+
+void
+Diskstream::prepare_to_stop (framepos_t pos)
+{
+ last_recordable_frame = pos + _capture_offset;
+}
+
+void
+Diskstream::engage_record_enable ()
+{
+ g_atomic_int_set (&_record_enabled, 1);
+}
+
+void
+Diskstream::disengage_record_enable ()
+{
+ g_atomic_int_set (&_record_enabled, 0);