+ get_connections (connections);
+
+ if (!connections.empty()) {
+
+ range.min = ~((pframes_t) 0);
+ range.max = 0;
+
+ DEBUG_TRACE (DEBUG::Latency, string_compose ("%1: %2 connections to check for latency range\n", name(), connections.size()));
+
+ for (vector<string>::const_iterator c = connections.begin();
+ c != connections.end(); ++c) {
+
+ LatencyRange lr;
+
+ if (!AudioEngine::instance()->port_is_mine (*c)) {
+
+ /* port belongs to some other port-system client, use
+ * the port engine to lookup its latency information.
+ */
+
+ PortEngine::PortHandle remote_port = port_engine.get_port_by_name (*c);
+
+ if (remote_port) {
+ lr = port_engine.get_latency_range (remote_port, playback);
+
+ DEBUG_TRACE (DEBUG::Latency, string_compose (
+ "\t%1 <-> %2 : latter has latency range %3 .. %4\n",
+ name(), *c, lr.min, lr.max));
+
+ range.min = min (range.min, lr.min);
+ range.max = max (range.max, lr.max);
+ }
+
+ } else {
+
+ /* port belongs to this instance of ardour,
+ so look up its latency information
+ internally, because our published/public
+ values already contain our plugin
+ latency compensation.
+ */
+
+ boost::shared_ptr<Port> remote_port = AudioEngine::instance()->get_port_by_name (*c);
+ if (remote_port) {
+ lr = remote_port->private_latency_range ((playback ? true : false));
+ DEBUG_TRACE (DEBUG::Latency, string_compose (
+ "\t%1 <-LOCAL-> %2 : latter has latency range %3 .. %4\n",
+ name(), *c, lr.min, lr.max));
+
+ range.min = min (range.min, lr.min);
+ range.max = max (range.max, lr.max);
+ }
+ }
+ }