- /* we need to capture the audio that has still not yet been received by the system
- at the time the stop is requested, so we have to roll past that time.
-
- we want to declick before stopping, so schedule the autostop for one
- block before the actual end. we'll declick in the subsequent block,
- and then we'll really be stopped.
- */
-
- DEBUG_TRACE (DEBUG::Transport, string_compose ("stop transport requested @ %1, scheduled for + %2 - %3 = %4, abort = %5\n",
- _transport_frame, _worst_input_latency, current_block_size,
- _transport_frame - _worst_input_latency - current_block_size,
- abort));
-
- SessionEvent *ev = new SessionEvent (SessionEvent::StopOnce, SessionEvent::Replace,
- _transport_frame + _worst_input_latency - current_block_size,
- 0, 0, abort);
-
- merge_event (ev);
- transport_sub_state |= StopPendingCapture;
- pending_abort = abort;
- return;
- }
-
- if ((transport_sub_state & PendingDeclickOut) == 0) {
+ SubState new_bits;
+
+ if (actively_recording() && /* we are recording */
+ worst_input_latency() > current_block_size) { /* input latency exceeds block size, so simple 1 cycle delay before stop is not enough */
+
+ /* we need to capture the audio that is still somewhere in the pipeline between
+ wherever it was generated and the process callback. This means that even though
+ the user (or something else) has asked us to stop, we have to roll
+ past this point and then reset the playhead/transport location to
+ the position at which the stop was requested.
+
+ we still need playback to "stop" now, however, which is why we schedule
+ a declick below.
+ */
+
+ DEBUG_TRACE (DEBUG::Transport, string_compose ("stop transport requested @ %1, scheduled for + %2 = %3, abort = %4\n",
+ _transport_frame, _worst_input_latency,
+ _transport_frame + _worst_input_latency,
+ abort));
+
+ SessionEvent *ev = new SessionEvent (SessionEvent::StopOnce, SessionEvent::Replace,
+ _transport_frame + _worst_input_latency,
+ 0, 0, abort);
+
+ merge_event (ev);