summaryrefslogtreecommitdiff
path: root/libs/ardour/transport_master.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2018-09-25 17:46:59 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2018-09-27 11:31:13 -0400
commitc4fcd0c268bffef82a9426e4763717772656f19f (patch)
treec0967e7ac0883cb30e48fb3912fe27a487355b92 /libs/ardour/transport_master.cc
parent147d456dbda658f15bd302fe89ec5b4f8780b148 (diff)
consolidate all transport masters on a SafeTime object that is a member of the TransportMaster base class.
This seems to have broken some aspects of chasing/locking
Diffstat (limited to 'libs/ardour/transport_master.cc')
-rw-r--r--libs/ardour/transport_master.cc54
1 files changed, 54 insertions, 0 deletions
diff --git a/libs/ardour/transport_master.cc b/libs/ardour/transport_master.cc
index 4dec88272a..135e022dbf 100644
--- a/libs/ardour/transport_master.cc
+++ b/libs/ardour/transport_master.cc
@@ -22,6 +22,7 @@
#include "pbd/debug.h"
#include "ardour/audioengine.h"
+#include "ardour/debug.h"
#include "ardour/midi_port.h"
#include "ardour/session.h"
#include "ardour/transport_master.h"
@@ -84,6 +85,59 @@ TransportMaster::~TransportMaster()
delete _session;
}
+bool
+TransportMaster::speed_and_position (double& speed, samplepos_t& pos, samplepos_t& lp, samplepos_t& when, samplepos_t now)
+{
+ if (!_collect) {
+ return false;
+ }
+
+ SafeTime last;
+ current.safe_read (last);
+
+ if (last.timestamp == 0) {
+ return false;
+ }
+
+ if (last.timestamp && now > last.timestamp && now - last.timestamp > labs (seekahead_distance())) {
+ /* no timecode for two cycles - conclude that it's stopped */
+
+ if (!Config->get_transport_masters_just_roll_when_sync_lost()) {
+ speed = 0;
+ pos = last.position;
+ lp = last.position;
+ when = last.timestamp;
+ _current_delta = 0;
+ // queue_reset (false);
+ DEBUG_TRACE (DEBUG::Slave, string_compose ("%1 not seen for 2 samples - reset pending, pos = %2\n", name(), pos));
+ return false;
+ }
+ }
+
+ lp = last.position;
+ when = last.timestamp;
+ speed = last.speed;
+ pos = last.position + (now - last.timestamp) * last.speed;
+
+ DEBUG_TRACE (DEBUG::Slave, string_compose ("%1: speed_and_position tme: %2 pos: %3 spd: %4\n", name(), last.timestamp, last.position, last.speed));
+
+ lp = last.position;
+ when = last.timestamp;
+ speed = last.speed;
+
+ /* provide a .1% deadzone to lock the speed */
+ if (fabs (speed - 1.0) <= 0.001) {
+ speed = 1.0;
+ }
+
+ pos = last.position + (now - last.timestamp) * speed;
+
+ DEBUG_TRACE (DEBUG::Slave, string_compose ("%1 sync spd: %2 pos: %3 | last-pos: %4 | elapsed: %5\n",
+ name(), speed, pos, last.position, (now - last.timestamp)));
+
+ return true;
+}
+
void
TransportMaster::register_properties ()
{