summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2020-03-05 20:47:19 +0100
committerRobin Gareus <robin@gareus.org>2020-03-06 01:44:32 +0100
commit1f6686c2a0c8ecd5bdf7ae74c3f4775811197033 (patch)
tree6b8eff0aa5eeaacb7b6c0be28597688a71a5fd64
parent6fd27f89b3ab0cde19035875725893f58a306709 (diff)
Separate pre-roll cycle calculation
This is also needed when exporting.
-rw-r--r--libs/ardour/ardour/session.h2
-rw-r--r--libs/ardour/session_process.cc38
2 files changed, 25 insertions, 15 deletions
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h
index 1ed5413206..63dd516d72 100644
--- a/libs/ardour/ardour/session.h
+++ b/libs/ardour/ardour/session.h
@@ -1345,6 +1345,8 @@ private:
void process_export (pframes_t);
void process_export_fw (pframes_t);
+ samplecnt_t calc_preroll_subcycle (samplecnt_t) const;
+
void block_processing() { g_atomic_int_set (&processing_prohibited, 1); }
void unblock_processing() { g_atomic_int_set (&processing_prohibited, 0); }
bool processing_blocked() const { return g_atomic_int_get (&processing_prohibited); }
diff --git a/libs/ardour/session_process.cc b/libs/ardour/session_process.cc
index fef23107ca..720f1a7129 100644
--- a/libs/ardour/session_process.cc
+++ b/libs/ardour/session_process.cc
@@ -303,6 +303,27 @@ Session::compute_audible_delta (samplepos_t& pos_and_delta) const
return true;
}
+samplecnt_t
+Session::calc_preroll_subcycle (samplecnt_t ns) const
+{
+ boost::shared_ptr<RouteList> r = routes.reader ();
+ for (RouteList::const_iterator i = r->begin(); i != r->end(); ++i) {
+ samplecnt_t route_offset = (*i)->playback_latency ();
+ if (_remaining_latency_preroll > route_offset + ns) {
+ /* route will no-roll for complete pre-roll cycle */
+ continue;
+ }
+ if (_remaining_latency_preroll > route_offset) {
+ /* route may need partial no-roll and partial roll from
+ * (_transport_sample - _remaining_latency_preroll) .. +ns.
+ * shorten and split the cycle.
+ */
+ ns = std::min (ns, (_remaining_latency_preroll - route_offset));
+ }
+ }
+ return ns;
+}
+
/** Process callback used when the auditioner is not active */
void
Session::process_with_events (pframes_t nframes)
@@ -358,21 +379,8 @@ Session::process_with_events (pframes_t nframes)
ns = std::min ((samplecnt_t)nframes, _count_in_samples);
}
- boost::shared_ptr<RouteList> r = routes.reader ();
- for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
- samplecnt_t route_offset = (*i)->playback_latency ();
- if (_remaining_latency_preroll > route_offset + ns) {
- /* route will no-roll for complete pre-roll cycle */
- continue;
- }
- if (_remaining_latency_preroll > route_offset) {
- /* route may need partial no-roll and partial roll from
- * (_transport_sample - _remaining_latency_preroll) .. +ns.
- * shorten and split the cycle.
- */
- ns = std::min (ns, (_remaining_latency_preroll - route_offset));
- }
- }
+ /* process until next route in-point */
+ ns = calc_preroll_subcycle (ns);
if (_count_in_samples > 0) {
run_click (_transport_sample - _count_in_samples, ns);