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.
This commit is contained in:
Robin Gareus 2020-04-23 04:56:45 +02:00
parent 6b10987e4b
commit 40eefeddd6
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 6 additions and 1 deletions

View File

@ -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;

View File

@ -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;
}