summaryrefslogtreecommitdiff
path: root/libs/ardour/session_process.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2020-03-20 19:26:51 -0600
committerPaul Davis <paul@linuxaudiosystems.com>2020-03-22 10:57:54 -0600
commit1f3145f8ff01d483eeb9d10ec1dd685db7fe47f3 (patch)
tree8708ad2e64effe7357371afc4eaebf6a6008b22b /libs/ardour/session_process.cc
parent1e474afbce20e789ccb8e23bb177c1aee410ee4e (diff)
fix up JACK transport to use master strategy design
Diffstat (limited to 'libs/ardour/session_process.cc')
-rw-r--r--libs/ardour/session_process.cc32
1 files changed, 24 insertions, 8 deletions
diff --git a/libs/ardour/session_process.cc b/libs/ardour/session_process.cc
index c367ad858e..b6d7e79bf8 100644
--- a/libs/ardour/session_process.cc
+++ b/libs/ardour/session_process.cc
@@ -1101,29 +1101,37 @@ Session::emit_thread_run ()
}
double
-Session::plan_master_strategy_engine (pframes_t nframes, double master_speed, samplepos_t master_transport_sample, double catch_speed)
+Session::plan_master_strategy_engine (pframes_t nframes, double master_speed, samplepos_t master_transport_sample, double /* catch_speed */)
{
/* JACK Transport. */
TransportMasterManager& tmm (TransportMasterManager::instance());
sampleoffset_t delta = _transport_sample - master_transport_sample;
+ const bool interesting_transport_state_change_underway = (locate_pending() || declick_in_progress());
if (master_speed == 0) {
+ DEBUG_TRACE (DEBUG::Slave, "JACK transport: not moving\n");
+
if (!actively_recording()) {
const samplecnt_t wlp = worst_latency_preroll_buffer_size_ceil ();
if (delta != wlp) {
+ DEBUG_TRACE (DEBUG::Slave, string_compose ("JACK transport: need to locate to reduce delta %1 vs %2\n", delta, wlp));
+
/* if we're not aligned with the current JACK * time, then jump to it */
- if (!locate_pending() && !declick_in_progress() && !tmm.current()->starting()) {
+ if (!interesting_transport_state_change_underway && !tmm.current()->starting()) {
const samplepos_t locate_target = master_transport_sample + wlp;
DEBUG_TRACE (DEBUG::Slave, string_compose ("JACK transport: jump to master position %1 by locating to %2\n", master_transport_sample, locate_target));
/* for JACK transport always stop after the locate (2nd argument == false) */
- TFSM_LOCATE (locate_target, MustStop, true, false, false);
+
+ transport_master_strategy.action = TransportMasterLocate;
+ transport_master_strategy.target = master_transport_sample;
+ transport_master_strategy.roll_disposition = MustStop;
} else {
DEBUG_TRACE (DEBUG::Slave, string_compose ("JACK Transport: locate already in process, sts = %1\n", master_transport_sample));
@@ -1133,11 +1141,16 @@ Session::plan_master_strategy_engine (pframes_t nframes, double master_speed, sa
} else {
+ DEBUG_TRACE (DEBUG::Slave, string_compose ("JACK transport: MOVING at %1\n", master_speed));
+
if (_transport_speed) {
/* master is rolling, and we're rolling ... with JACK we should always be perfectly in sync, so ... WTF? */
if (delta) {
if (remaining_latency_preroll() && worst_latency_preroll()) {
/* our transport position is not moving because we're doing latency alignment. Nothing in particular to do */
+ DEBUG_TRACE (DEBUG::Slave, "JACK transport: waiting for latency alignment\n");
+ transport_master_strategy.action = TransportMasterRelax;
+ return 1.0;
} else {
cerr << "\n\n\n IMPOSSIBLE! OUT OF SYNC WITH JACK TRANSPORT (rlp = " << remaining_latency_preroll() << " wlp " << worst_latency_preroll() << ")\n\n\n";
}
@@ -1145,8 +1158,7 @@ Session::plan_master_strategy_engine (pframes_t nframes, double master_speed, sa
}
}
-
- if (!locate_pending() && !declick_in_progress()) {
+ if (!interesting_transport_state_change_underway) {
if (master_speed != 0.0) {
@@ -1154,19 +1166,23 @@ Session::plan_master_strategy_engine (pframes_t nframes, double master_speed, sa
if (_transport_speed == 0.0f) {
DEBUG_TRACE (DEBUG::Slave, string_compose ("slave starts transport: %1 sample %2 tf %3\n", master_speed, master_transport_sample, _transport_sample));
- TFSM_EVENT (TransportFSM::StartTransport);
+ transport_master_strategy.action = TransportMasterStart;
+ return 1.0;
}
} else if (!tmm.current()->starting()) { /* master stopped, not in "starting" state */
if (_transport_speed != 0.0f) {
DEBUG_TRACE (DEBUG::Slave, string_compose ("slave stops transport: %1 sample %2 tf %3\n", master_speed, master_transport_sample, _transport_sample));
- TFSM_STOP (false, false);
+ transport_master_strategy.action = TransportMasterStop;
+ return 1.0;
}
}
}
- return catch_speed;
+ /* No varispeed with JACK */
+ transport_master_strategy.action = TransportMasterRelax;
+ return 1.0;
}
double