- /* map LTC timecode to session TC setting */
- framepos_t ltc_frame; ///< audio-frame corresponding to LTC frame
- Timecode::timecode_to_sample (timecode, ltc_frame, true, false,
- double(session.frame_rate()),
- session.config.get_subframes_per_frame(),
- timecode_negative_offset, timecode_offset
- );
-
- framepos_t cur_timestamp = frame.off_end + 1;
- DEBUG_TRACE (DEBUG::LTC, string_compose ("LTC F: %1 LF: %2 N: %3 L: %4\n", ltc_frame, last_ltc_frame, cur_timestamp, last_timestamp));
- if (frame.off_end + 1 <= last_timestamp || last_timestamp == 0) {
+ samplepos_t ltc_sample; // audio-sample corresponding to position of LTC frame
+
+ if (_session && Config->get_use_session_timecode_format()) {
+ Timecode::timecode_to_sample (timecode, ltc_sample, true, false, (double)ENGINE->sample_rate(), _session->config.get_subframes_per_frame(), timecode_negative_offset, timecode_offset);
+ } else {
+ Timecode::timecode_to_sample (timecode, ltc_sample, true, false, (double)ENGINE->sample_rate(), 100, timecode_negative_offset, timecode_offset);
+ }
+
+ ltc_sample += ltc_slave_latency.max;
+
+ /* This LTC frame spans sample time between sample.off_start .. sample.off_end
+ *
+ * NOTE: these sample times are NOT the ones that LTC is representing. They are
+ * derived our own audioengine's monotonic audio clock.
+ *
+ * So we expect the next frame to span sample.off_end+1 and ... <don't care for now>.
+ * That isn't the time we will necessarily receive the LTC frame, but the decoder
+ * should tell us that its span begins there.
+ *
+ */
+
+ samplepos_t cur_timestamp = sample.off_end + 1;
+
+ DEBUG_TRACE (DEBUG::LTC, string_compose ("LTC S: %1 LS: %2 N: %3 L: %4\n", ltc_sample, last_ltc_sample, cur_timestamp, last_timestamp));
+
+ if (cur_timestamp <= last_timestamp || last_timestamp == 0) {