mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-09 08:14:58 +01:00
Update LTC reader port latency on connection change
This mechanism adds infrastructure that can later also be used for MTC and MIDIClock. PS. The LTC Generator port's latency is queried after the port is created, and later kept in sync via LatencyUpdated signal.
This commit is contained in:
parent
a46091b86a
commit
3ca33c07dc
4 changed files with 20 additions and 12 deletions
|
|
@ -443,9 +443,9 @@ protected:
|
||||||
|
|
||||||
XMLNode port_node;
|
XMLNode port_node;
|
||||||
|
|
||||||
PBD::ScopedConnection port_connection;
|
virtual void connection_handler (boost::weak_ptr<ARDOUR::Port>, std::string name1, boost::weak_ptr<ARDOUR::Port>, std::string name2, bool yn);
|
||||||
bool connection_handler (boost::weak_ptr<ARDOUR::Port>, std::string name1, boost::weak_ptr<ARDOUR::Port>, std::string name2, bool yn);
|
|
||||||
|
|
||||||
|
PBD::ScopedConnection port_connection;
|
||||||
PBD::ScopedConnection backend_connection;
|
PBD::ScopedConnection backend_connection;
|
||||||
|
|
||||||
virtual void register_properties ();
|
virtual void register_properties ();
|
||||||
|
|
@ -613,6 +613,7 @@ private:
|
||||||
void resync_latency (bool);
|
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);
|
||||||
|
void connection_handler (boost::weak_ptr<ARDOUR::Port>, std::string, boost::weak_ptr<ARDOUR::Port>, std::string, bool);
|
||||||
|
|
||||||
bool did_reset_tc_format;
|
bool did_reset_tc_format;
|
||||||
Timecode::TimecodeFormat saved_tc_format;
|
Timecode::TimecodeFormat saved_tc_format;
|
||||||
|
|
|
||||||
|
|
@ -66,9 +66,8 @@ LTC_TransportMaster::LTC_TransportMaster (std::string const & name)
|
||||||
{
|
{
|
||||||
memset (&prev_frame, 0, sizeof(LTCFrameExt));
|
memset (&prev_frame, 0, sizeof(LTCFrameExt));
|
||||||
|
|
||||||
resync_latency (false);
|
|
||||||
|
|
||||||
AudioEngine::instance()->Xrun.connect_same_thread (port_connection, boost::bind (<C_TransportMaster::resync_xrun, this));
|
AudioEngine::instance()->Xrun.connect_same_thread (port_connection, boost::bind (<C_TransportMaster::resync_xrun, this));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -125,6 +124,18 @@ LTC_TransportMaster::~LTC_TransportMaster()
|
||||||
ltc_decoder_free(decoder);
|
ltc_decoder_free(decoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
LTC_TransportMaster::connection_handler (boost::weak_ptr<ARDOUR::Port> w0, std::string n0, boost::weak_ptr<ARDOUR::Port> w1, std::string n1, bool con)
|
||||||
|
{
|
||||||
|
TransportMaster::connection_handler(w0, n0, w1, n1, con);
|
||||||
|
|
||||||
|
boost::shared_ptr<Port> p0 = w0.lock ();
|
||||||
|
boost::shared_ptr<Port> p1 = w1.lock ();
|
||||||
|
if (p0 == _port || p1 == _port) {
|
||||||
|
resync_latency (false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
LTC_TransportMaster::parse_timecode_offset()
|
LTC_TransportMaster::parse_timecode_offset()
|
||||||
{
|
{
|
||||||
|
|
@ -190,11 +201,11 @@ LTC_TransportMaster::resync_latency (bool playback)
|
||||||
if (playback) {
|
if (playback) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DEBUG_TRACE (DEBUG::LTC, "LTC resync_latency()\n");
|
|
||||||
|
|
||||||
uint32_t old = ltc_slave_latency.max;
|
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);
|
||||||
|
DEBUG_TRACE (DEBUG::LTC, string_compose ("LTC resync_latency: %1\n", ltc_slave_latency.max));
|
||||||
}
|
}
|
||||||
if (old != ltc_slave_latency.max) {
|
if (old != ltc_slave_latency.max) {
|
||||||
sync_lock_broken = false;
|
sync_lock_broken = false;
|
||||||
|
|
|
||||||
|
|
@ -107,10 +107,10 @@ Session::ltc_tx_resync_latency (bool playback)
|
||||||
if (deletion_in_progress() || !playback) {
|
if (deletion_in_progress() || !playback) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DEBUG_TRACE (DEBUG::TXLTC, "resync latency\n");
|
|
||||||
boost::shared_ptr<Port> ltcport = ltc_output_port();
|
boost::shared_ptr<Port> ltcport = ltc_output_port();
|
||||||
if (ltcport) {
|
if (ltcport) {
|
||||||
ltcport->get_connected_latency_range(ltc_out_latency, true);
|
ltcport->get_connected_latency_range(ltc_out_latency, true);
|
||||||
|
DEBUG_TRACE (DEBUG::TXLTC, string_compose ("resync latency: %1\n", ltc_out_latency.max));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -163,11 +163,11 @@ TransportMaster::set_name (std::string const & str)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
void
|
||||||
TransportMaster::connection_handler (boost::weak_ptr<ARDOUR::Port>, std::string name1, boost::weak_ptr<ARDOUR::Port>, std::string name2, bool yn)
|
TransportMaster::connection_handler (boost::weak_ptr<ARDOUR::Port>, std::string name1, boost::weak_ptr<ARDOUR::Port>, std::string name2, bool yn)
|
||||||
{
|
{
|
||||||
if (!_port) {
|
if (!_port) {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string fqn = ARDOUR::AudioEngine::instance()->make_port_name_non_relative (_port->name());
|
const std::string fqn = ARDOUR::AudioEngine::instance()->make_port_name_non_relative (_port->name());
|
||||||
|
|
@ -188,11 +188,7 @@ TransportMaster::connection_handler (boost::weak_ptr<ARDOUR::Port>, std::string
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyChanged (Properties::connected);
|
PropertyChanged (Properties::connected);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue