From 24ec0b974d84df061cbbe645668dc62fa7120678 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 26 Sep 2017 17:49:24 +0200 Subject: Properly aligned export (Stem + Session) Delay ports being exported by their playback latency. --- libs/ardour/session_export.cc | 42 +++++++++++++----------------------------- 1 file changed, 13 insertions(+), 29 deletions(-) (limited to 'libs/ardour/session_export.cc') diff --git a/libs/ardour/session_export.cc b/libs/ardour/session_export.cc index 33ede3cadc..879f34020a 100644 --- a/libs/ardour/session_export.cc +++ b/libs/ardour/session_export.cc @@ -104,7 +104,7 @@ Session::pre_export () /** Called for each range that is being exported */ int -Session::start_audio_export (samplepos_t position, bool realtime, bool region_export, bool comensate_master_latency) +Session::start_audio_export (samplepos_t position, bool realtime, bool region_export) { if (!_exporting) { pre_export (); @@ -127,31 +127,6 @@ Session::start_audio_export (samplepos_t position, bool realtime, bool region_ex _export_preroll = 1; } - /* "worst_track_latency" is the correct value for stem-exports - * see to Route::add_export_point(), - * - * For master-bus export, we also need to add the master's latency. - * (or actually longest-total-session-latency - worst-track-latency) - * to align the export to 00:00:00:00. - * - * We must not use worst_playback_latency because that - * includes external (hardware) latencies and would overcompensate - * during file-export. - * - * (this is all still very [w]hacky. Individual Bus and Track outputs - * are not aligned but one can select them in the PortExportChannelSelector) - */ - _export_latency = worst_track_out_latency (); - - boost::shared_ptr master = master_out (); - if (master && comensate_master_latency) { - _export_latency += master->signal_latency (); - } - - if (region_export) { - _export_latency = 0; - } - /* We're about to call Track::seek, so the butler must have finished everything up otherwise it could be doing do_refill in its thread while we are doing it here. @@ -181,6 +156,12 @@ Session::start_audio_export (samplepos_t position, bool realtime, bool region_ex */ _transport_sample = position; + + if (!region_export) { + _remaining_latency_preroll = worst_latency_preroll (); + } else { + _remaining_latency_preroll = 0; + } export_status->stop = false; /* get transport ready. note how this is calling butler functions @@ -277,18 +258,21 @@ Session::process_export_fw (pframes_t nframes) return; } - if (_export_latency > 0) { - samplepos_t remain = std::min ((samplepos_t)nframes, _export_latency); + if (_remaining_latency_preroll > 0) { + samplepos_t remain = std::min ((samplepos_t)nframes, _remaining_latency_preroll); if (need_buffers) { _engine.main_thread()->get_buffers (); } + process_without_events (remain); + if (need_buffers) { _engine.main_thread()->drop_buffers (); } - _export_latency -= remain; + _remaining_latency_preroll -= remain; + _transport_sample -= remain; nframes -= remain; if (nframes == 0) { -- cgit v1.2.3