summaryrefslogtreecommitdiff
path: root/libs/ardour/session_ltc.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2012-10-26 11:39:13 +0000
committerRobin Gareus <robin@gareus.org>2012-10-26 11:39:13 +0000
commit3ddfc762248bbad41645998781584e2e70549b93 (patch)
tree9853177ac40384f22e98efc58bfd15402812ffe5 /libs/ardour/session_ltc.cc
parent0047b87e3dba286906097d5b15ca73b5b529b0eb (diff)
LTC generator - reinit on xrun or graph-reorder
git-svn-id: svn://localhost/ardour2/branches/3.0@13351 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/session_ltc.cc')
-rw-r--r--libs/ardour/session_ltc.cc31
1 files changed, 25 insertions, 6 deletions
diff --git a/libs/ardour/session_ltc.cc b/libs/ardour/session_ltc.cc
index de85ed06d6..ae41444832 100644
--- a/libs/ardour/session_ltc.cc
+++ b/libs/ardour/session_ltc.cc
@@ -58,6 +58,8 @@ Session::ltc_tx_initialize()
ltc_enc_buf = (ltcsnd_sample_t*) calloc((nominal_frame_rate() / 23), sizeof(ltcsnd_sample_t));
ltc_speed = 0;
ltc_tx_reset();
+ Xrun.connect_same_thread (*this, boost::bind (&Session::ltc_tx_reset, this));
+ engine().GraphReordered.connect_same_thread (*this, boost::bind (&Session::ltc_tx_reset, this));
}
void
@@ -78,6 +80,11 @@ Session::ltc_tx_reset()
ltc_buf_off = 0;
ltc_enc_byte = 0;
ltc_enc_cnt = 0;
+
+ boost::shared_ptr<Port> ltcport = ltc_output_port();
+ if (ltcport) {
+ ltcport->get_connected_latency_range(ltc_out_latency, true);
+ }
}
void
@@ -113,7 +120,7 @@ Session::ltc_tx_send_time_code_for_cycle (framepos_t start_frame, framepos_t end
boost::shared_ptr<Port> ltcport = ltc_output_port();
Buffer& buf (ltcport->get_buffer (nframes));
-
+
if (!ltc_encoder || !ltc_enc_buf) {
return;
}
@@ -138,9 +145,17 @@ Session::ltc_tx_send_time_code_for_cycle (framepos_t start_frame, framepos_t end
/* range from libltc (38..218) || - 128.0 -> (-90..90) */
const float ltcvol = Config->get_ltc_output_volume()/(90.0); // pow(10, db/20.0)/(90.0);
- jack_latency_range_t ltc_latency;
- ltcport->get_connected_latency_range(ltc_latency, true);
- DEBUG_TRACE (DEBUG::LTC, string_compose("LTC TX %1 to %2 / %3 | lat: %4\n", start_frame, end_frame, nframes, ltc_latency.max));
+#if 1
+ /* TODO read layency only on demand -> ::ltc_tx_reset()
+ * this is already prepared.
+ *
+ * ..but first fix jack2 issue with re-computing latency
+ * in the correct order. Until then, querying it in the
+ * process-callback is the only way to get the current value
+ */
+ ltcport->get_connected_latency_range(ltc_out_latency, true);
+#endif
+ DEBUG_TRACE (DEBUG::LTC, string_compose("LTC TX %1 to %2 / %3 | lat: %4\n", start_frame, end_frame, nframes, ltc_out_latency.max));
/* all systems go. Now here's the plan:
*
@@ -175,6 +190,10 @@ Session::ltc_tx_send_time_code_for_cycle (framepos_t start_frame, framepos_t end
}
// (2) speed & direction
+
+ /* speed 0 aka transport stopped is interpreted as rolling forward.
+ * keep repeating current frame
+ */
#define SIGNUM(a) ( (a) < 0 ? -1 : 1)
bool speed_changed = false;
@@ -183,7 +202,7 @@ Session::ltc_tx_send_time_code_for_cycle (framepos_t start_frame, framepos_t end
/* The generated timecode is offset by the port-latency,
* therefore the offset depends on the direction of transport.
*/
- framepos_t cycle_start_frame = (current_speed < 0) ? (start_frame + ltc_latency.max) : (start_frame - ltc_latency.max);
+ framepos_t cycle_start_frame = (current_speed < 0) ? (start_frame + ltc_out_latency.max) : (start_frame - ltc_out_latency.max);
#else
/* This comes in handy when testing sync - record output on an A3 track
* see also http://tracker.ardour.org/view.php?id=5073
@@ -510,7 +529,7 @@ Session::ltc_tx_send_time_code_for_cycle (framepos_t start_frame, framepos_t end
DEBUG_TRACE (DEBUG::LTC, string_compose("LTC TX6.4 enc-pos: %1 + %2 [ %4 / %5 ] spd %6\n", ltc_enc_pos, ltc_enc_cnt, ltc_buf_off, ltc_buf_len, ltc_speed));
#endif
}
-
+
dynamic_cast<AudioBuffer*>(&buf)->set_written (true);
return;
}