13
0

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
This commit is contained in:
Robin Gareus 2012-10-28 10:48:06 +00:00
parent f750aa3207
commit 52423fa8c3
4 changed files with 32 additions and 16 deletions

View File

@ -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

View File

@ -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;

View File

@ -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 (&LTC_Slave::reset, this));
session.engine().GraphReordered.connect_same_thread (port_connections, boost::bind (&LTC_Slave::reset, this));
session.Xrun.connect_same_thread (port_connections, boost::bind (&LTC_Slave::resync_latency, this));
session.engine().GraphReordered.connect_same_thread (port_connections, boost::bind (&LTC_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<Port> 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<Port> ltcport = session.ltc_input_port();
ltcport->get_connected_latency_range(ltc_slave_latency, false);
}
resync_latency();
}
void

View File

@ -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<Port> 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<Port> ltcport = ltc_output_port();
if (ltcport) {
ltcport->get_connected_latency_range(ltc_out_latency, true);
}
}
ltc_tx_resync_latency();
}
void