+ if (possibly_recording == fully_rec_enabled) {
+
+ if (last_possibly_recording == fully_rec_enabled) {
+ return;
+ }
+
+ /* we transitioned to recording. lets see if its transport based or a punch */
+
+ first_recordable_frame = transport_frame + _capture_offset;
+ last_recordable_frame = max_framepos;
+ capture_start_frame = transport_frame;
+
+ if (change & transport_rolling) {
+
+ /* transport-change (started rolling) */
+
+ if (_alignment_style == ExistingMaterial) {
+
+ /* there are two delays happening:
+
+ 1) inbound, represented by _capture_offset
+ 2) outbound, represented by _session.worst_output_latency()
+
+ the first sample to record occurs when the larger of these
+ two has elapsed, since they occur in parallel.
+
+ since we've already added _capture_offset, just add the
+ difference if _session.worst_output_latency() is larger.
+ */
+
+ if (_capture_offset < _session.worst_output_latency()) {
+ first_recordable_frame += (_session.worst_output_latency() - _capture_offset);
+ }
+ } else {
+ first_recordable_frame += _roll_delay;
+ }
+
+ } else {
+
+ /* punch in */
+
+ if (_alignment_style == ExistingMaterial) {
+
+ /* There are two kinds of punch:
+
+ manual punch in happens at the correct transport frame
+ because the user hit a button. but to get alignment correct
+ we have to back up the position of the new region to the
+ appropriate spot given the roll delay.
+
+ autopunch toggles recording at the precise
+ transport frame, and then the DS waits
+ to start recording for a time that depends
+ on the output latency.
+
+ XXX: BUT THIS CODE DOESN'T DIFFERENTIATE !!!
+
+ */
+
+ if (_capture_offset < _session.worst_output_latency()) {
+ /* see comment in ExistingMaterial block above */
+ first_recordable_frame += (_session.worst_output_latency() - _capture_offset);
+ }
+
+ } else {
+ capture_start_frame -= _roll_delay;
+ }
+ }
+
+ 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() */
+
+ } else {
+ /* punch out */
+
+ last_recordable_frame = transport_frame + _capture_offset;
+
+ if (_alignment_style == ExistingMaterial) {
+ if (_session.worst_output_latency() > _capture_offset) {
+ last_recordable_frame += (_session.worst_output_latency() - _capture_offset);
+ }
+ } else {
+ last_recordable_frame += _roll_delay;
+ }
+ }
+ }
+ }
+
+ last_possibly_recording = possibly_recording;