summaryrefslogtreecommitdiff
path: root/libs/ardour/session_export.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2016-07-10 03:20:35 +0200
committerRobin Gareus <robin@gareus.org>2016-07-10 03:21:29 +0200
commita4a246b41d68012534fdc315c67e32c18a25ae8e (patch)
tree368838691a0d62c2b5e45973951fed9048299107 /libs/ardour/session_export.cc
parent0a52b325f4e1eaf39be65a24f9a594ffe1f66e79 (diff)
towards export latency compensation
Diffstat (limited to 'libs/ardour/session_export.cc')
-rw-r--r--libs/ardour/session_export.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/libs/ardour/session_export.cc b/libs/ardour/session_export.cc
index efb731463f..1dee1f8d3c 100644
--- a/libs/ardour/session_export.cc
+++ b/libs/ardour/session_export.cc
@@ -111,6 +111,21 @@ Session::start_audio_export (framepos_t position)
}
_export_preroll = Config->get_export_preroll() * nominal_frame_rate ();
+ if (_export_preroll == 0) {
+ // must be > 0 so that transport is started in sync.
+ _export_preroll = 1;
+ }
+
+ /* "worst_track_latency" is the correct value for stem-exports
+ * see to Route::add_export_point(),
+ *
+ * for master-bus export, we'd need to add the master's latency.
+ * or actually longest-total-session-latency.
+ *
+ * We can't use worst_playback_latency because that includes
+ * includes external latencies and would overcompensate.
+ */
+ _export_latency = worst_track_latency ();
/* 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
@@ -212,9 +227,25 @@ Session::process_export_fw (pframes_t nframes)
butler_transport_work ();
g_atomic_int_set (&_butler->should_do_transport_work, 0);
post_transport ();
+
return 0;
}
+ if (_export_latency > 0) {
+ framepos_t remain = std::min ((framepos_t)nframes, _export_latency);
+
+ _engine.main_thread()->get_buffers ();
+ process_without_events (remain);
+ _engine.main_thread()->drop_buffers ();
+
+ _export_latency -= remain;
+ nframes -= remain;
+
+ if (nframes == 0) {
+ return 0;
+ }
+ }
+
_engine.main_thread()->get_buffers ();
process_export (nframes);
_engine.main_thread()->drop_buffers ();