LTC Slave: subscribe to LatencyUpdated signal

This uses a recently introduce Signal instead of the generic
GraphReordered, which was used in the past since it usually
happened after the latency was changed.
This commit is contained in:
Robin Gareus 2020-05-08 23:42:30 +02:00
parent a2094d97ad
commit ecd55f9fec
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04
2 changed files with 18 additions and 12 deletions

View file

@ -610,7 +610,7 @@ private:
bool detect_ltc_fps (int, bool); bool detect_ltc_fps (int, bool);
bool equal_ltc_sample_time (LTCFrame* a, LTCFrame* b); bool equal_ltc_sample_time (LTCFrame* a, LTCFrame* b);
void resync_xrun (); void resync_xrun ();
void resync_latency (); void resync_latency (bool);
void parse_timecode_offset (); void parse_timecode_offset ();
void parameter_changed (std::string const& p); void parameter_changed (std::string const& p);
@ -635,8 +635,8 @@ private:
Timecode::TimecodeFormat a3e_timecode; Timecode::TimecodeFormat a3e_timecode;
double samples_per_timecode_frame; double samples_per_timecode_frame;
PBD::ScopedConnectionList port_connections; PBD::ScopedConnection port_connection;
PBD::ScopedConnection config_connection; PBD::ScopedConnectionList session_connections;
LatencyRange ltc_slave_latency; LatencyRange ltc_slave_latency;
}; };

View file

@ -66,10 +66,9 @@ LTC_TransportMaster::LTC_TransportMaster (std::string const & name)
{ {
memset (&prev_frame, 0, sizeof(LTCFrameExt)); memset (&prev_frame, 0, sizeof(LTCFrameExt));
resync_latency(); resync_latency (false);
AudioEngine::instance()->Xrun.connect_same_thread (port_connections, boost::bind (&LTC_TransportMaster::resync_xrun, this)); AudioEngine::instance()->Xrun.connect_same_thread (port_connection, boost::bind (&LTC_TransportMaster::resync_xrun, this));
AudioEngine::instance()->GraphReordered.connect_same_thread (port_connections, boost::bind (&LTC_TransportMaster::resync_latency, this));
} }
void void
@ -89,7 +88,7 @@ LTC_TransportMaster::create_port ()
void void
LTC_TransportMaster::set_session (Session *s) LTC_TransportMaster::set_session (Session *s)
{ {
config_connection.disconnect (); session_connections.drop_connections();
_session = s; _session = s;
if (_session) { if (_session) {
@ -109,14 +108,15 @@ LTC_TransportMaster::set_session (Session *s)
parse_timecode_offset(); parse_timecode_offset();
reset (true); reset (true);
_session->config.ParameterChanged.connect_same_thread (config_connection, boost::bind (&LTC_TransportMaster::parameter_changed, this, _1)); _session->config.ParameterChanged.connect_same_thread (session_connections, boost::bind (&LTC_TransportMaster::parameter_changed, this, _1));
_session->LatencyUpdated.connect_same_thread (session_connections, boost::bind (&LTC_TransportMaster::resync_latency, this, _1));
} }
} }
LTC_TransportMaster::~LTC_TransportMaster() LTC_TransportMaster::~LTC_TransportMaster()
{ {
port_connections.drop_connections(); port_connection.disconnect();
config_connection.disconnect(); session_connections.drop_connections();
if (did_reset_tc_format) { if (did_reset_tc_format) {
_session->config.set_timecode_format (saved_tc_format); _session->config.set_timecode_format (saved_tc_format);
@ -185,14 +185,20 @@ LTC_TransportMaster::resync_xrun()
} }
void void
LTC_TransportMaster::resync_latency() LTC_TransportMaster::resync_latency (bool playback)
{ {
if (playback) {
return;
}
DEBUG_TRACE (DEBUG::LTC, "LTC resync_latency()\n"); DEBUG_TRACE (DEBUG::LTC, "LTC resync_latency()\n");
sync_lock_broken = false;
uint32_t old = ltc_slave_latency.max;
if (_port) { if (_port) {
_port->get_connected_latency_range (ltc_slave_latency, false); _port->get_connected_latency_range (ltc_slave_latency, false);
} }
if (old != ltc_slave_latency.max) {
sync_lock_broken = false;
}
} }
void void