0

I'm working on a AUv3 host app, and I want the users to be notified when a loaded audio unit crashes (gets invalidated) for some reason. I looked at Apple's documentations about AUAudioUnit, but couldn't find any information about how to detect an invalidation of an audio unit (AUv3) from the host app.

Does anyone know how to do this?

Thanks

1 Answers1

0

when setting up your AudioEngine you can observe kAudioComponentInstanceInvalidationNotification to figure out if its audio component instance was invalidated later on.

[[NSNotificationCenter defaultCenter] addObserverForName:kAudioComponentInstanceInvalidationNotification object:nil queue:nil usingBlock:^(NSNotification *note) {

    AUAudioUnit *auUnit = (AUAudioUnit *)note.object;

    NSValue *val = note.userInfo[@"audioUnit"];
    AudioUnit auAddress = (AudioUnit)val.pointerValue;

    NSLog(@"AudioComponent Invalidation of Unit:%@ with Address:%p", auUnit, auAddress);

}];

keep in mind that you may have got the notification but the component ended up in a deadlock. So when trying to recover from that you may have to turn down the whole host app.

Ol Sen
  • 3,163
  • 2
  • 21
  • 30
  • Thanks again @OI. So actually this leads me to the following question. Isn't there a way to reload an AUAudioUnit, or should I simply remove the invalidated one from the audio engine, and instanciate a fresh new one? – Ali Gokturk Nov 18 '20 at 13:20
  • i would say: reload is per definition invalidate & remove + instance fresh. :) – Ol Sen Nov 18 '20 at 18:38