- int possibly_recording;
- int rolling;
- int change;
- const int transport_rolling = 0x4;
- const int track_rec_enabled = 0x2;
- const int global_rec_enabled = 0x1;
-
- /* 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;
- }
-
- /* change state */
-
- /* if per-track or global rec-enable turned on while the other was already on, we've started recording */
-
- if ((change & track_rec_enabled) && record_enabled() && (!(change & global_rec_enabled) && can_record) ||
- ((change & global_rec_enabled) && can_record && (!(change & track_rec_enabled) && record_enabled()))) {
-
- /* starting to record: compute first+last frames */
-
- first_recordable_frame = transport_frame + _capture_offset;
- last_recordable_frame = max_frames;
- capture_start_frame = transport_frame;
-
- if (!(last_possibly_recording & transport_rolling) && (possibly_recording & transport_rolling)) {
-
- /* was stopped, now rolling (and recording) */
-
- if (_alignment_style == ExistingMaterial) {
- first_recordable_frame += _session.worst_output_latency();
- } else {
- first_recordable_frame += _roll_delay;
- }
-
- } else {
-
- /* was rolling, but record state changed */
-
- if (_alignment_style == ExistingMaterial) {
-
- if (!Config->get_punch_in()) {
-
- /* 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.
- */
-
- capture_start_frame -= _roll_delay;
-
- /* XXX paul notes (august 2005): i don't know why
- this is needed.
- */
-
- first_recordable_frame += _capture_offset;
-
- } else {
-
- /* 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.
- */
-
- first_recordable_frame += _session.worst_output_latency();
- }