+
+ _realtime_export = realtime;
+ _region_export = region_export;
+
+ if (region_export) {
+ _export_preroll = 0;
+ }
+ else if (realtime) {
+ _export_preroll = nominal_frame_rate ();
+ } else {
+ _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 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_latency ();
+
+ boost::shared_ptr<Route> master = master_out ();
+ if (master && comensate_master_latency) {
+ _export_latency += master->signal_latency ();
+ }
+
+ if (region_export) {
+ _export_latency = 0;
+ }