mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-23 07:06:23 +01:00
Add API to query IO latencies
IO::connected_latency() is relevant once Ardour publishes individual per Port latency. IO::public_latency() is only for debug purposes.
This commit is contained in:
parent
491523d6b7
commit
8ff3b5ecf6
2 changed files with 60 additions and 4 deletions
|
|
@ -116,7 +116,10 @@ class LIBARDOUR_API IO : public SessionObject, public Latent
|
||||||
bool physically_connected () const;
|
bool physically_connected () const;
|
||||||
|
|
||||||
samplecnt_t signal_latency () const { return 0; }
|
samplecnt_t signal_latency () const { return 0; }
|
||||||
|
|
||||||
samplecnt_t latency () const;
|
samplecnt_t latency () const;
|
||||||
|
samplecnt_t public_latency () const;
|
||||||
|
samplecnt_t connected_latency (bool for_playback) const;
|
||||||
|
|
||||||
PortSet& ports() { return _ports; }
|
PortSet& ports() { return _ports; }
|
||||||
const PortSet& ports() const { return _ports; }
|
const PortSet& ports() const { return _ports; }
|
||||||
|
|
|
||||||
|
|
@ -1219,14 +1219,12 @@ IO::apply_pretty_name ()
|
||||||
samplecnt_t
|
samplecnt_t
|
||||||
IO::latency () const
|
IO::latency () const
|
||||||
{
|
{
|
||||||
samplecnt_t max_latency;
|
samplecnt_t max_latency = 0;
|
||||||
samplecnt_t latency;
|
|
||||||
|
|
||||||
max_latency = 0;
|
|
||||||
|
|
||||||
/* io lock not taken - must be protected by other means */
|
/* io lock not taken - must be protected by other means */
|
||||||
|
|
||||||
for (PortSet::const_iterator i = _ports.begin(); i != _ports.end(); ++i) {
|
for (PortSet::const_iterator i = _ports.begin(); i != _ports.end(); ++i) {
|
||||||
|
samplecnt_t latency;
|
||||||
if ((latency = i->private_latency_range (_direction == Output).max) > max_latency) {
|
if ((latency = i->private_latency_range (_direction == Output).max) > max_latency) {
|
||||||
DEBUG_TRACE (DEBUG::Latency, string_compose ("port %1 has %2 latency of %3 - use\n",
|
DEBUG_TRACE (DEBUG::Latency, string_compose ("port %1 has %2 latency of %3 - use\n",
|
||||||
name(),
|
name(),
|
||||||
|
|
@ -1242,6 +1240,61 @@ IO::latency () const
|
||||||
return max_latency;
|
return max_latency;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
samplecnt_t
|
||||||
|
IO::public_latency () const
|
||||||
|
{
|
||||||
|
samplecnt_t max_latency = 0;
|
||||||
|
|
||||||
|
/* io lock not taken - must be protected by other means */
|
||||||
|
|
||||||
|
for (PortSet::const_iterator i = _ports.begin(); i != _ports.end(); ++i) {
|
||||||
|
samplecnt_t latency;
|
||||||
|
if ((latency = i->public_latency_range (_direction == Output).max) > max_latency) {
|
||||||
|
DEBUG_TRACE (DEBUG::Latency, string_compose ("port %1 has %2 latency of %3 - use\n",
|
||||||
|
name(),
|
||||||
|
((_direction == Output) ? "PLAYBACK" : "CAPTURE"),
|
||||||
|
latency));
|
||||||
|
max_latency = latency;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUG_TRACE (DEBUG::Latency, string_compose ("%1: max %4 public latency from %2 ports = %3\n",
|
||||||
|
name(), _ports.num_ports(), max_latency,
|
||||||
|
((_direction == Output) ? "PLAYBACK" : "CAPTURE")));
|
||||||
|
return max_latency;
|
||||||
|
}
|
||||||
|
|
||||||
|
samplecnt_t
|
||||||
|
IO::connected_latency (bool for_playback) const
|
||||||
|
{
|
||||||
|
/* io lock not taken - must be protected by other means */
|
||||||
|
samplecnt_t max_latency = 0;
|
||||||
|
bool connected = false;
|
||||||
|
|
||||||
|
/* if output is not connected to anything, use private latency */
|
||||||
|
for (PortSet::const_iterator i = _ports.begin(); i != _ports.end(); ++i) {
|
||||||
|
if (i->connected()) {
|
||||||
|
connected = true;
|
||||||
|
max_latency = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
samplecnt_t latency;
|
||||||
|
if ((latency = i->private_latency_range (for_playback).max) > max_latency) {
|
||||||
|
max_latency = latency;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (connected) {
|
||||||
|
for (PortSet::const_iterator i = _ports.begin(); i != _ports.end(); ++i) {
|
||||||
|
LatencyRange lr;
|
||||||
|
i->get_connected_latency_range (lr, for_playback);
|
||||||
|
if (lr.max > max_latency) {
|
||||||
|
max_latency = lr.max;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return max_latency;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
IO::connect_ports_to_bundle (boost::shared_ptr<Bundle> c, bool exclusive, void* src) {
|
IO::connect_ports_to_bundle (boost::shared_ptr<Bundle> c, bool exclusive, void* src) {
|
||||||
return connect_ports_to_bundle(c, exclusive, false, src);
|
return connect_ports_to_bundle(c, exclusive, false, src);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue