summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/ardour/ardour/session.h1
-rw-r--r--libs/ardour/butler.cc1
-rw-r--r--libs/ardour/session.cc1
-rw-r--r--libs/ardour/session_process.cc10
-rw-r--r--libs/ardour/session_transport.cc12
5 files changed, 22 insertions, 3 deletions
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h
index c9b8c84798..7f18857bff 100644
--- a/libs/ardour/ardour/session.h
+++ b/libs/ardour/ardour/session.h
@@ -1740,6 +1740,7 @@ private:
};
volatile guint _punch_or_loop; // enum PunchLoopLock
+ gint current_usecs_per_track;
bool punch_active () const;
void unset_punch ();
diff --git a/libs/ardour/butler.cc b/libs/ardour/butler.cc
index b4bf5a83be..935dccc361 100644
--- a/libs/ardour/butler.cc
+++ b/libs/ardour/butler.cc
@@ -508,4 +508,3 @@ Butler::drop_references ()
} // namespace ARDOUR
-
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index 767f3a424d..860ff846aa 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -272,6 +272,7 @@ Session::Session (AudioEngine &eng,
, ltc_timecode_negative_offset (false)
, midi_control_ui (0)
, _punch_or_loop (NoConstraint)
+ , current_usecs_per_track (1000)
, _tempo_map (0)
, _all_route_group (new RouteGroup (*this, "all"))
, routes (new RouteList)
diff --git a/libs/ardour/session_process.cc b/libs/ardour/session_process.cc
index 13f2a428ad..37a93468bf 100644
--- a/libs/ardour/session_process.cc
+++ b/libs/ardour/session_process.cc
@@ -1325,7 +1325,15 @@ Session::plan_master_strategy (pframes_t nframes, double master_speed, samplepos
samplepos_t locate_target = master_transport_sample;
- locate_target += wlp + lrintf (ntracks() * sample_rate() * 0.05);
+ /* locate to a position "worst_latency_preroll" head of
+ * the master, but also add in a generous estimate to
+ * cover the time it will take to locate to that
+ * position, based on our worst-case estimate for this
+ * session (so far).
+ */
+
+ cerr << "chase/locate using " << current_usecs_per_track << " usecs/track\n";
+ locate_target += wlp + lrintf (ntracks() * sample_rate() * (1.5 * (current_usecs_per_track / 1000000.0)));
DEBUG_TRACE (DEBUG::Slave, string_compose ("After locate-to-catch-master, still too far off (%1). Locate again to %2\n", delta, locate_target));
diff --git a/libs/ardour/session_transport.cc b/libs/ardour/session_transport.cc
index 31392b9c89..caa88b4f3b 100644
--- a/libs/ardour/session_transport.cc
+++ b/libs/ardour/session_transport.cc
@@ -1268,6 +1268,9 @@ Session::non_realtime_locate ()
/* no more looping .. should have been noticed elsewhere */
}
+ microseconds_t start;
+ uint32_t nt = 0;
+ int hundreths_of_second_per_track = 0;
samplepos_t tf;
@@ -1277,14 +1280,21 @@ Session::non_realtime_locate ()
restart:
gint sc = g_atomic_int_get (&_seek_counter);
tf = _transport_sample;
+ start = get_microseconds ();
- for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
+ for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i, ++nt) {
(*i)->non_realtime_locate (tf);
if (sc != g_atomic_int_get (&_seek_counter)) {
std::cerr << "\n\nLOCATE INTERRUPTED BY LOCATE!!!\n\n";
goto restart;
}
}
+
+ microseconds_t end = get_microseconds ();
+ int usecs_per_track = lrintf ((end - start) / (double) nt);
+ if (usecs_per_track > g_atomic_int_get (&current_usecs_per_track)) {
+ g_atomic_int_set (&current_usecs_per_track, usecs_per_track);
+ }
}
{