diff options
author | Robin Gareus <robin@gareus.org> | 2020-04-23 04:56:45 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2020-04-23 04:56:45 +0200 |
commit | 40eefeddd666ee9a83c07382a28836e5b4aef6cd (patch) | |
tree | bbd390a3bafe667a2c3b04c5a79ce6e1cf6a5444 | |
parent | 6b10987e4bd9961b6603b426eae087ee49e1bca5 (diff) |
Micro optimization: cache output IO latency
IO::latency iterates over the port-set retrieving the
private_latency_range of each port. Since it can only change
when connections and latency changes, we can instead cache the value.
This is also in preparation to allow the auditioner to override it.
-rw-r--r-- | libs/ardour/ardour/route.h | 3 | ||||
-rw-r--r-- | libs/ardour/route.cc | 4 |
2 files changed, 6 insertions, 1 deletions
diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h index 08f9465803..ef102a9b48 100644 --- a/libs/ardour/ardour/route.h +++ b/libs/ardour/ardour/route.h @@ -355,6 +355,8 @@ public: samplecnt_t signal_latency() const { return _signal_latency; } samplecnt_t playback_latency (bool incl_downstream = false) const; + virtual samplecnt_t output_latency () const { return _output_latency; } + PBD::Signal0<void> active_changed; PBD::Signal0<void> denormal_protection_changed; PBD::Signal0<void> comment_changed; @@ -615,6 +617,7 @@ protected: bool _active; samplecnt_t _signal_latency; + samplecnt_t _output_latency; ProcessorList _processors; mutable Glib::Threads::RWLock _processor_lock; diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 3ba9a80f99..c50b4aab25 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -383,7 +383,7 @@ Route::process_output_buffers (BufferSet& bufs, const double speed = (is_auditioner() ? 1.0 : _session.transport_speed ()); - const sampleoffset_t latency_offset = _signal_latency + _output->latency (); + const sampleoffset_t latency_offset = _signal_latency + output_latency (); if (speed < 0) { /* when rolling backwards this can become negative */ start_sample -= latency_offset; @@ -4302,6 +4302,8 @@ Route::update_signal_latency (bool apply_to_delayline) apply_latency_compensation (); } + _output_latency = _output->latency (); + return _signal_latency; } |