summaryrefslogtreecommitdiff
path: root/libs/ardour/audio_unit.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2016-07-16 05:05:52 +0200
committerRobin Gareus <robin@gareus.org>2016-07-16 05:05:52 +0200
commit25a4cae8ad30dc090f2313600456d759ab7e81a5 (patch)
tree7f87d892b7cc50cd22b40848370b4cd168693ef6 /libs/ardour/audio_unit.cc
parent8219fdee073ae20bf05bdb435bc1a7fb7cf0f089 (diff)
AU: install latency listener
Don't query after every cycle, some plugins inject license checks when a host queries latency (!)
Diffstat (limited to 'libs/ardour/audio_unit.cc')
-rw-r--r--libs/ardour/audio_unit.cc29
1 files changed, 26 insertions, 3 deletions
diff --git a/libs/ardour/audio_unit.cc b/libs/ardour/audio_unit.cc
index 74b7ce6566..3e6bdfb691 100644
--- a/libs/ardour/audio_unit.cc
+++ b/libs/ardour/audio_unit.cc
@@ -955,7 +955,10 @@ AUPlugin::default_value (uint32_t port)
framecnt_t
AUPlugin::signal_latency () const
{
- return unit->Latency() * _session.frame_rate();
+ if (_current_latency < 0) {
+ _current_latency = unit->Latency() * _session.frame_rate();
+ }
+ return _current_latency;
}
void
@@ -1082,8 +1085,6 @@ AUPlugin::set_block_size (pframes_t nframes)
activate ();
}
- _current_block_size = nframes;
-
return 0;
}
@@ -3362,6 +3363,19 @@ AUPlugin::create_parameter_listener (AUEventListenerProc cb, void* arg, float in
_parameter_listener_arg = arg;
+ // listen for latency changes
+ AudioUnitEvent event;
+ event.mEventType = kAudioUnitEvent_PropertyChange;
+ event.mArgument.mProperty.mAudioUnit = unit->AU();
+ event.mArgument.mProperty.mPropertyID = kAudioUnitProperty_Latency;
+ event.mArgument.mProperty.mScope = kAudioUnitScope_Global;
+ event.mArgument.mProperty.mElement = 0;
+
+ if (AUEventListenerAddEventType (_parameter_listener, _parameter_listener_arg, &event) != noErr) {
+ PBD::error << "Failed to create latency event listener\n";
+ // TODO don't cache _current_latency
+ }
+
return 0;
}
@@ -3458,6 +3472,15 @@ AUPlugin::_parameter_change_listener (void* arg, void* src, const AudioUnitEvent
void
AUPlugin::parameter_change_listener (void* /*arg*/, void* src, const AudioUnitEvent* event, UInt64 /*host_time*/, Float32 new_value)
{
+ if (event->mEventType == kAudioUnitEvent_PropertyChange) {
+ if (event->mArgument.mProperty.mPropertyID == kAudioUnitProperty_Latency) {
+ DEBUG_TRACE (DEBUG::AudioUnits, string_compose("AU Latency Change Event %1 <> %1\n", new_value, unit->Latency()));
+ // TODO atomically set //_current_latency = -1;
+ _current_latency = unit->Latency() * _session.frame_rate(); // TODO: check: new_value
+ }
+ return;
+ }
+
ParameterMap::iterator i;
if ((i = parameter_map.find (event->mArgument.mParameter.mParameterID)) == parameter_map.end()) {