+ start_sample += _signal_latency;
+ end_sample += _signal_latency;
+
+ start_sample += _output->latency ();
+ end_sample += _output->latency ();
+
+ const double speed = (is_auditioner() ? 1.0 : _session.transport_speed ());
+
+ /* Note: during intial pre-roll 'start_sample' as passed as argument can be negative.
+ * Functions calling process_output_buffers() will set "run_disk_reader"
+ * to false if the pre-roll count-down is larger than playback_latency ().
+ *
+ * playback_latency() is guarnteed to be <= _signal_latency + _output->latency ()
+ */
+ assert (!_disk_reader || !run_disk_reader || start_sample >= 0);
+
+ /* however the disk-writer may need to pick up output from other tracks
+ * during pre-roll (in particular if this route has latent effects after the disk).
+ *
+ * e.g. track 1 play -> latency A --port--> track2 capture -> latency B ---> out
+ * total pre-roll = A + B.
+ *
+ * Note the disk-writer has built-in overlap detection (it's safe to run it early)
+ * given that
+ */
+ bool run_disk_writer = false;
+ if (_disk_writer && speed != 0) {
+ samplecnt_t latency_preroll = _session.remaining_latency_preroll ();
+ run_disk_writer = latency_preroll < nframes + (_signal_latency + _output->latency ());
+ if (end_sample - _disk_writer->input_latency () < _session.transport_sample ()) {
+ run_disk_writer = true;
+ }
+ }
+
+ /* Tell main outs what to do about monitoring. We do this so that
+ * on a transition between monitoring states we get a de-clicking gain
+ * change in the _main_outs delivery, if config.get_use_monitor_fades()
+ * is true.
+ *
+ * We override this in the case where we have an internal generator.
+ *
+ * FIXME: when punching in/out this also depends on latency compensated time
+ * for this route. monitoring_state() does not currently handle that correctly,.
+ *
+ * Also during remaining_latency_preroll, transport_rolling () is false, but
+ * we may need to monitor disk instead.
+ */
+ MonitorState ms = monitoring_state ();
+ bool silence = _have_internal_generator ? false : (ms == MonitoringSilence);