From 3b785b9d357b9c929ba061b306eacf2247737091 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 31 Oct 2017 03:51:08 +0100 Subject: Small steps towards rolling backwards.. --- libs/ardour/route.cc | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'libs/ardour/route.cc') diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 59106beaac..29225404d9 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -360,14 +360,18 @@ Route::process_output_buffers (BufferSet& bufs, * By the Time T=0 is reached (dt=15 later) that sample is audible. */ - 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 ()); + const sampleoffset_t latency_offset = _signal_latency + _output->latency (); + if (speed < 0) { + /* when rolling backwards this can become negative */ + start_sample -= latency_offset; + end_sample -= latency_offset; + } else { + start_sample += latency_offset; + end_sample += latency_offset; + } + /* 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 (). @@ -386,7 +390,7 @@ Route::process_output_buffers (BufferSet& bufs, * given that */ bool run_disk_writer = false; - if (_disk_writer && speed != 0) { + 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 ()) { @@ -514,7 +518,11 @@ Route::process_output_buffers (BufferSet& bufs, pspeed = 0; } - (*i)->run (bufs, start_sample - latency, end_sample - latency, pspeed, nframes, *i != _processors.back()); + if (speed < 0) { + (*i)->run (bufs, start_sample + latency, end_sample + latency, pspeed, nframes, *i != _processors.back()); + } else { + (*i)->run (bufs, start_sample - latency, end_sample - latency, pspeed, nframes, *i != _processors.back()); + } bufs.set_count ((*i)->output_streams()); -- cgit v1.2.3