From 52423fa8c3a460c5057b560121a84758f108a17c Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sun, 28 Oct 2012 10:48:06 +0000 Subject: [PATCH] LTC (slave&gen): no reset on graph-change fixes issues with transport stop/start when making connections with jack1 while slaved to LTC git-svn-id: svn://localhost/ardour2/branches/3.0@13356 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/session.h | 1 + libs/ardour/ardour/slave.h | 1 + libs/ardour/ltc_slave.cc | 22 +++++++++++++++------- libs/ardour/session_ltc.cc | 24 +++++++++++++++--------- 4 files changed, 32 insertions(+), 16 deletions(-) diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 5ef7d21bda..f359411846 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -1207,6 +1207,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi void ltc_tx_initialize(); void ltc_tx_cleanup(); void ltc_tx_reset(); + void ltc_tx_resync_latency(); void ltc_tx_recalculate_position(); void ltc_tx_send_time_code_for_cycle (framepos_t, framepos_t, double, double, pframes_t nframes); #endif diff --git a/libs/ardour/ardour/slave.h b/libs/ardour/ardour/slave.h index 0ff1da7884..f864bee636 100644 --- a/libs/ardour/ardour/slave.h +++ b/libs/ardour/ardour/slave.h @@ -356,6 +356,7 @@ public: bool detect_ltc_fps(int, bool); bool equal_ltc_frame_time(LTCFrame *a, LTCFrame *b); void reset(); + void resync_latency(); Session& session; bool did_reset_tc_format; diff --git a/libs/ardour/ltc_slave.cc b/libs/ardour/ltc_slave.cc index 12386eeb18..4f6f77ce1f 100644 --- a/libs/ardour/ltc_slave.cc +++ b/libs/ardour/ltc_slave.cc @@ -61,8 +61,8 @@ LTC_Slave::LTC_Slave (Session& s) decoder = ltc_decoder_create((int) frames_per_ltc_frame, 128 /*queue size*/); reset(); - session.Xrun.connect_same_thread (port_connections, boost::bind (<C_Slave::reset, this)); - session.engine().GraphReordered.connect_same_thread (port_connections, boost::bind (<C_Slave::reset, this)); + session.Xrun.connect_same_thread (port_connections, boost::bind (<C_Slave::resync_latency, this)); + session.engine().GraphReordered.connect_same_thread (port_connections, boost::bind (<C_Slave::resync_latency, this)); } LTC_Slave::~LTC_Slave() @@ -94,6 +94,18 @@ LTC_Slave::ok() const return true; } +void +LTC_Slave::resync_latency() +{ + DEBUG_TRACE (DEBUG::LTC, "LTC resync()\n"); + engine_dll_initstate = 0; + + if (session.ltc_output_io()) { /* check if Port exits */ + boost::shared_ptr ltcport = session.ltc_input_port(); + ltcport->get_connected_latency_range(ltc_slave_latency, false); + } +} + void LTC_Slave::reset() { @@ -103,11 +115,7 @@ LTC_Slave::reset() transport_direction = 0; ltc_speed = 0; engine_dll_initstate = 0; - - if (session.ltc_output_io()) { /* check if Port exits */ - boost::shared_ptr ltcport = session.ltc_input_port(); - ltcport->get_connected_latency_range(ltc_slave_latency, false); - } + resync_latency(); } void diff --git a/libs/ardour/session_ltc.cc b/libs/ardour/session_ltc.cc index dd2ddb5692..b7044d28a4 100644 --- a/libs/ardour/session_ltc.cc +++ b/libs/ardour/session_ltc.cc @@ -58,8 +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)); + Xrun.connect_same_thread (*this, boost::bind (&Session::ltc_tx_resync_latency, this)); + engine().GraphReordered.connect_same_thread (*this, boost::bind (&Session::ltc_tx_resync_latency, this)); } void @@ -71,6 +71,18 @@ Session::ltc_tx_cleanup() ltc_encoder = NULL; } +void +Session::ltc_tx_resync_latency() +{ + DEBUG_TRACE (DEBUG::LTC, "LTC TX resync latency\n"); + if (!deletion_in_progress()) { + boost::shared_ptr ltcport = ltc_output_port(); + if (ltcport) { + ltcport->get_connected_latency_range(ltc_out_latency, true); + } + } +} + void Session::ltc_tx_reset() { @@ -80,13 +92,7 @@ Session::ltc_tx_reset() ltc_buf_off = 0; ltc_enc_byte = 0; ltc_enc_cnt = 0; - - if (!deletion_in_progress()) { - boost::shared_ptr ltcport = ltc_output_port(); - if (ltcport) { - ltcport->get_connected_latency_range(ltc_out_latency, true); - } - } + ltc_tx_resync_latency(); } void