diff options
author | Robin Gareus <robin@gareus.org> | 2019-02-16 00:13:30 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2019-02-16 01:10:50 +0100 |
commit | 3cffaeac74163535295513488756c55ba5e2dffa (patch) | |
tree | 3cf90ea9932a8f707f5dc8b04bf0113f2c743e79 /libs/ardour/ardour/latent.h | |
parent | 26f37a47530bac5f1c21d660dcea0b794cc22f09 (diff) |
Prepare to allow to disable latency-compensation
Previously "zero custom/user latency" meant "default plugin latency".
This is now saved in a separate boolean allowing a user to reduce a
processor's latency to zero.
This also prepares for a global switch to use zero latency throughout
the whole session.
Diffstat (limited to 'libs/ardour/ardour/latent.h')
-rw-r--r-- | libs/ardour/ardour/latent.h | 48 |
1 files changed, 41 insertions, 7 deletions
diff --git a/libs/ardour/ardour/latent.h b/libs/ardour/ardour/latent.h index c4464f7ba4..b7d9a3fcd5 100644 --- a/libs/ardour/ardour/latent.h +++ b/libs/ardour/ardour/latent.h @@ -26,27 +26,61 @@ namespace ARDOUR { class LIBARDOUR_API Latent { - public: +public: Latent() : _user_latency (0) {} virtual ~Latent() {} virtual samplecnt_t signal_latency() const = 0; - samplecnt_t user_latency () const { return _user_latency; } + /* effective latency to be used while processing */ samplecnt_t effective_latency() const { - if (_user_latency) { + if (_zero_latency) { + return 0; + } else if (_use_user_latency) { return _user_latency; } else { return signal_latency (); } } - virtual void set_user_latency (samplecnt_t val) { _user_latency = val; } + /* custom user-set latency, if any */ + samplecnt_t user_latency () const { + if (_use_user_latency) { + return _user_latency; + } else { + return 0; + } + } + + void unset_user_latency () { + _use_user_latency = false; + _user_latency = 0; + } + + virtual void set_user_latency (samplecnt_t val) { + _use_user_latency = true; + _user_latency = val; + } + + static void force_zero_latency (bool en) { + _zero_latency = en; + } - protected: - samplecnt_t _user_latency; + static bool zero_latency () { + return _zero_latency; + } + +protected: + int set_state (const XMLNode& node, int version); + void add_state (XMLNode*) const; + +private: + samplecnt_t _use_user_latency; + samplecnt_t _user_latency; + static bool _zero_latency; }; -} +} /* namespace */ + #endif /* __ardour_latent_h__*/ |