Detecting AUv3 invalidations in a host app (iOS)

174 Views Asked by At

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

There are 1 best solutions below

4
Ol Sen On

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.