summaryrefslogtreecommitdiff
path: root/libs/ardour/mtc_slave.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2009-12-01 18:32:29 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2009-12-01 18:32:29 +0000
commit9e9cb3bf31a8cbf00ecf43ea0c3acd8b8bb86760 (patch)
tree8a5b6e2decce5b008ac4d93ef2d69ca6846f95e2 /libs/ardour/mtc_slave.cc
parentb825b86862223862f2cd23e08d204b2de657b4b7 (diff)
adjust to use timestamped MTC messages
git-svn-id: svn://localhost/ardour2/branches/3.0@6255 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/mtc_slave.cc')
-rw-r--r--libs/ardour/mtc_slave.cc35
1 files changed, 20 insertions, 15 deletions
diff --git a/libs/ardour/mtc_slave.cc b/libs/ardour/mtc_slave.cc
index b8e2693622..4ca86236b7 100644
--- a/libs/ardour/mtc_slave.cc
+++ b/libs/ardour/mtc_slave.cc
@@ -74,10 +74,8 @@ MTC_Slave::rebind (MIDI::Port& p)
}
void
-MTC_Slave::update_mtc_qtr (Parser& /*p*/, int which_qtr)
+MTC_Slave::update_mtc_qtr (Parser& /*p*/, int which_qtr, nframes_t now)
{
- nframes64_t now = session.engine().frame_time();
-
DEBUG_TRACE (DEBUG::MTC, string_compose ("qtr frame %1 at %2, valid-for-time? %3\n", which_qtr, now, qtr_frame_messages_valid_for_time));
if (qtr_frame_messages_valid_for_time) {
@@ -109,9 +107,12 @@ MTC_Slave::update_mtc_qtr (Parser& /*p*/, int which_qtr)
}
void
-MTC_Slave::update_mtc_time (const byte *msg, bool was_full)
+MTC_Slave::update_mtc_time (const byte *msg, bool was_full, nframes_t now)
{
- nframes64_t now = session.engine().frame_time();
+ /* "now" can be zero if this is called from a context where we do not have or do not want
+ to use a timestamp indicating when this MTC time was received.
+ */
+
Timecode::Time timecode;
TimecodeFormat tc_format;
bool reset_tc = true;
@@ -201,17 +202,21 @@ MTC_Slave::update_mtc_time (const byte *msg, bool was_full)
*/
mtc_frame += (long) (1.75 * session.frames_per_timecode_frame()) + session.worst_output_latency();
-
- double speed = compute_apparent_speed (now);
-
- current.guard1++;
- current.position = mtc_frame;
- current.timestamp = now;
- current.speed = speed;
- current.guard2++;
+
+ if (now) {
+ double speed = compute_apparent_speed (now);
+
+ current.guard1++;
+ current.position = mtc_frame;
+ current.timestamp = now;
+ current.speed = speed;
+ current.guard2++;
+ }
}
- last_inbound_frame = now;
+ if (now) {
+ last_inbound_frame = now;
+ }
}
double
@@ -262,7 +267,7 @@ MTC_Slave::handle_locate (const MIDI::byte* mmc_tc)
mtc[1] = mmc_tc[2];
mtc[0] = mmc_tc[3];
- update_mtc_time (mtc, true);
+ update_mtc_time (mtc, true, 0);
}
void