13
0

Fix ambiguous latency detection (mostly revert eb0498bb2)

This commit is contained in:
Robin Gareus 2021-09-14 21:34:43 +02:00
parent 4998b2711b
commit 2c4a2fc6fa
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -1680,8 +1680,8 @@ PortManager::check_for_ambiguous_latency (bool log) const
boost::shared_ptr<Ports> plist = _ports.reader();
for (Ports::iterator pi = plist->begin(); pi != plist->end(); ++pi) {
boost::shared_ptr<Port> const& p (pi->second);
/* check one to many connections on the receiving side */
if (p->sends_output () || (p->flags () & IsTerminal)) {
/* check one to many connections */
if (!p->sends_output () || (p->flags () & IsTerminal) || !p->connected ()) {
continue;
}
if (boost::dynamic_pointer_cast<AsyncMIDIPort>(p)) {
@ -1689,51 +1689,13 @@ PortManager::check_for_ambiguous_latency (bool log) const
}
assert (port_is_mine (p->name ()));
LatencyRange rangeA;
p->get_connected_latency_range (rangeA, true);
if (rangeA.min == rangeA.max) {
continue;
}
/* check if latency-range of connected ports matches our own */
vector<string> connections;
p->get_connections (connections);
assert (!connections.empty());
for (vector<string>::const_iterator c = connections.begin(); c != connections.end(); ++c) {
LatencyRange rangeB;
if (!AudioEngine::instance()->port_is_mine (*c)) {
PortEngine::PortHandle ph = _backend->get_port_by_name (*c);
if (!ph) {
continue;
}
rangeB = _backend->get_latency_range (ph, true);
} else {
Ports::iterator x = plist->find (make_port_name_relative (*c));
if (x == plist->end()) {
continue;
}
boost::shared_ptr<Port> const& pb (x->second);
if (pb->flags () & (IsTerminal | Hidden | TransportSyncPort)) {
continue;
}
pb->get_connected_latency_range (rangeB, true);
}
if (rangeA == rangeB) {
continue;
}
LatencyRange range;
range.min = ~((pframes_t) 0);
range.max = 0;
p->collect_latency_from_backend (range, true);
if (range.min != range.max) {
if (log) {
warning << string_compose(
_("Ambiguous latency for input '%1' (%2, %3),"
"receiving from port '%4' (%5, %6)"),
p->name(), rangeA.min, rangeA.max,
*c, rangeB.min, rangeB.max)
<< endmsg;
warning << string_compose(_("Ambiguous latency for port '%1' (%2, %3)"), p->name(), range.min, range.max) << endmsg;
rv = true;
} else {
return true;