summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2020-05-09 23:42:26 +0200
committerRobin Gareus <robin@gareus.org>2020-05-09 23:43:04 +0200
commit52ae134efb055cfad701b7039df1c7544e47d011 (patch)
tree9cbe94f6e7e73b1713486881151ffe2d60ee4c46 /libs
parent34fd8b5356f79987473d36084325fba9961dbd2d (diff)
Fix initial sync to external time source
TransportMasterStart needs to be set when this cycle's delta can reach _remaining_latency_preroll. This allows to directly catch the master-position and start rolling without initial vari-speed.
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/session_process.cc19
-rw-r--r--libs/ardour/transport_master_manager.cc3
2 files changed, 18 insertions, 4 deletions
diff --git a/libs/ardour/session_process.cc b/libs/ardour/session_process.cc
index a157c4a1d5..efc282a52b 100644
--- a/libs/ardour/session_process.cc
+++ b/libs/ardour/session_process.cc
@@ -1227,6 +1227,16 @@ Session::plan_master_strategy (pframes_t nframes, double master_speed, samplepos
return actual_speed ();
}
+ /* When calling TransportMasterStart, sould aim for
+ * delta >= _remaining_latency_preroll
+ * This way there can be silent pre-roll of exactly the delta time.
+ *
+ * In order to meet this condition, TransportMasterStart needs be set
+ * if the *end* of the current cycle can reach _remaining_latency_preroll.
+ * So current_block_size needs to be added here.
+ */
+ const samplecnt_t wlp = worst_latency_preroll_buffer_size_ceil () + current_block_size;
+
TransportMasterManager& tmm (TransportMasterManager::instance());
const samplecnt_t locate_threshold = 5 * current_block_size;
@@ -1279,7 +1289,6 @@ Session::plan_master_strategy (pframes_t nframes, double master_speed, samplepos
return 1.0;
}
- const samplecnt_t wlp = worst_latency_preroll_buffer_size_ceil ();
bool should_locate;
if (transport_master_strategy.action == TransportMasterNoRoll) {
@@ -1366,6 +1375,12 @@ Session::plan_master_strategy (pframes_t nframes, double master_speed, samplepos
DEBUG_TRACE (DEBUG::Slave, string_compose ("master @ %1 is WITHIN %2 of our position %3 (delta is %4), so start\n", master_transport_sample, wlp, _transport_sample, delta));
+ if (delta > _remaining_latency_preroll) {
+ /* increase pre-roll to match delta. this allows
+ * to directly catch the transport w/o vari-speed */
+ _remaining_latency_preroll = delta;
+ }
+
transport_master_strategy.action = TransportMasterStart;
transport_master_strategy.catch_speed = catch_speed;
return catch_speed;
@@ -1392,7 +1407,7 @@ Session::plan_master_strategy (pframes_t nframes, double master_speed, samplepos
samplepos_t locate_target = master_transport_sample;
- locate_target += lrintf (ntracks() * sample_rate() * 0.05);
+ locate_target += wlp + lrintf (ntracks() * sample_rate() * (1.5 * (current_usecs_per_track / 1000000.0)));
DEBUG_TRACE (DEBUG::Slave, string_compose ("request locate to master position %1\n", locate_target));
diff --git a/libs/ardour/transport_master_manager.cc b/libs/ardour/transport_master_manager.cc
index f3083f7af6..2875021966 100644
--- a/libs/ardour/transport_master_manager.cc
+++ b/libs/ardour/transport_master_manager.cc
@@ -231,10 +231,9 @@ TransportMasterManager::pre_process_transport_masters (pframes_t nframes, sample
if (master_dll_initstate == 0) {
init_transport_master_dll (_master_speed, _master_position);
- _master_invalid_this_cycle = true;
DEBUG_TRACE (DEBUG::Slave, string_compose ("no roll3 - still initializing master DLL, will be %1 next process cycle\n", master_dll_initstate));
- return 1.0;
+ return _master_speed;
}
/* compute delta or "error" between the computed master_position for