X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Faudio_diskstream.cc;h=c8cc1c9ebf2f0dbb53b08a3b7822a780bbd22fe8;hb=d9cebc2edf8accded23c6f2a1caab73eb47a50fd;hp=d832a39e280bb1ca3dd18ce850c262d4eeb59f58;hpb=e3dd8cc3ee481924997a1650e3a130b2579be209;p=ardour.git diff --git a/libs/ardour/audio_diskstream.cc b/libs/ardour/audio_diskstream.cc index d832a39e28..c8cc1c9ebf 100644 --- a/libs/ardour/audio_diskstream.cc +++ b/libs/ardour/audio_diskstream.cc @@ -79,10 +79,7 @@ AudioDiskstream::AudioDiskstream (Session &sess, const string &name, Diskstream: /* prevent any write sources from being created */ in_set_state = true; - - init(flag); use_new_playlist (); - in_set_state = false; } @@ -92,7 +89,7 @@ AudioDiskstream::AudioDiskstream (Session& sess, const XMLNode& node) , channels (new ChannelList) { in_set_state = true; - init (Recordable); + init (); if (set_state (node, Stateful::loading_state_version)) { in_set_state = false; @@ -107,10 +104,8 @@ AudioDiskstream::AudioDiskstream (Session& sess, const XMLNode& node) } void -AudioDiskstream::init (Diskstream::Flag f) +AudioDiskstream::init () { - Diskstream::init(f); - /* there are no channels at this point, so these two calls just get speed_buffer_size and wrap_buffer size setup without duplicating their code. @@ -433,8 +428,6 @@ AudioDiskstream::process (nframes_t transport_frame, nframes_t nframes, bool can int ret = -1; nframes_t rec_offset = 0; nframes_t rec_nframes = 0; - bool nominally_recording; - bool re = record_enabled (); bool collect_playback = false; playback_distance = 0; @@ -445,8 +438,6 @@ AudioDiskstream::process (nframes_t transport_frame, nframes_t nframes, bool can check_record_status (transport_frame, nframes, can_record); - nominally_recording = (can_record && re); - if (nframes == 0) { return 0; } @@ -464,27 +455,35 @@ AudioDiskstream::process (nframes_t transport_frame, nframes_t nframes, bool can (*chan)->current_playback_buffer = 0; } - if (nominally_recording || (_session.get_record_enabled() && _session.config.get_punch_in())) { - // Safeguard against situations where process() goes haywire when autopunching and last_recordable_frame < first_recordable_frame - if (last_recordable_frame < first_recordable_frame) { - last_recordable_frame = max_frames; - } + /* two conditions to test for here: + + A: this track is rec-enabled, and the session has confirmed that we can record + B: this track is rec-enabled, has been recording, and we are set up for auto-punch-in - OverlapType ot = coverage (first_recordable_frame, last_recordable_frame, transport_frame, transport_frame + nframes); + The second test is necessary to capture the extra material that arrives AFTER the transport + frame has left the punch range (which will cause the "can_record" argument to be false). + */ - calculate_record_range(ot, transport_frame, nframes, rec_nframes, rec_offset); - if (rec_nframes && !was_recording) { - capture_captured = 0; - was_recording = true; - } - } + // Safeguard against situations where process() goes haywire when autopunching and last_recordable_frame < first_recordable_frame + if (last_recordable_frame < first_recordable_frame) { + last_recordable_frame = max_frames; + } + + OverlapType ot = coverage (first_recordable_frame, last_recordable_frame, transport_frame, transport_frame + nframes); + + calculate_record_range (ot, transport_frame, nframes, rec_nframes, rec_offset); + + if (rec_nframes && !was_recording) { + capture_captured = 0; + was_recording = true; + } if (can_record && !_last_capture_regions.empty()) { _last_capture_regions.clear (); } - if (nominally_recording || rec_nframes) { + if (rec_nframes) { uint32_t limit = _io->n_ports ().n_audio(); @@ -512,7 +511,7 @@ AudioDiskstream::process (nframes_t transport_frame, nframes_t nframes, bool can AudioPort* const ap = _io->audio (n); assert(ap); assert(rec_nframes <= ap->get_audio_buffer(nframes).capacity()); - memcpy (chaninfo->current_capture_buffer, ap->get_audio_buffer (rec_nframes).data(rec_offset), sizeof (Sample) * rec_nframes); + memcpy (chaninfo->current_capture_buffer, ap->get_audio_buffer (nframes).data(rec_offset), sizeof (Sample) * rec_nframes); } else { @@ -572,7 +571,7 @@ AudioDiskstream::process (nframes_t transport_frame, nframes_t nframes, bool can adjust_capture_position = rec_nframes; - } else if (nominally_recording) { + } else if (can_record && record_enabled()) { /* can't do actual capture yet - waiting for latency effects to finish before we start*/ @@ -1579,6 +1578,8 @@ void AudioDiskstream::finish_capture (bool /*rec_monitors_input*/, boost::shared_ptr c) { was_recording = false; + first_recordable_frame = max_frames; + last_recordable_frame = max_frames; if (capture_captured == 0) { return;