Skip to content

Commit

Permalink
Improve validation code in AudioUnitLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
sgretscher committed Feb 11, 2024
1 parent e0487be commit 753b5e0
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions ExamplesCommon/PlugInHosting/AudioUnitLoader.m
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,31 @@ AudioUnitComponent AudioUnitPrepareComponentWithIDs(OSType type, OSType subtype,
AVAudioUnitComponent * avComponent = [[[AVAudioUnitComponentManager sharedAudioUnitComponentManager] componentsMatchingDescription:compDesc] firstObject];
if (avComponent)
{
// ensure we pass auval
ARA_VALIDATE_API_CONDITION([avComponent passesAUVal]);

result->component = [avComponent audioComponent];

// validate we provide a proper icon
if (@available(macOS 11.0, *))
{
NSImage * icon = AudioComponentCopyIcon(result->component);
ARA_INTERNAL_ASSERT(icon != nil);
[(NSObject *)icon release]; // cast is necessary because NSImage is only forward-declared here
}

if (([avComponent audioComponentDescription].componentFlags & kAudioComponentFlag_IsV3AudioUnit) != 0)
{
// when migrating to Audio Unit v3, plug-ins should also adopt App Sandbox safety
ARA_VALIDATE_API_CONDITION([avComponent isSandboxSafe]);
}
else
{
#if ARA_CPU_ARM
// when migrating to ARM machines, we suggest to also add App Sandbox safety
// ARA_VALIDATE_API_CONDITION([avComponent isSandboxSafe]);
if (![avComponent isSandboxSafe])
ARA_WARN("This Audio Unit is not sandbox-safe, and thus might not work in future macOS releases.");

// when migrating to ARM machines, we suggest to also move to Audio Unit v3 (AUv2 is deprecated)
// ARA_VALIDATE_API_CONDITION(([avComponent audioComponentDescription].componentFlags & kAudioComponentFlag_IsV3AudioUnit) != 0);
// if (([avComponent audioComponentDescription].componentFlags & kAudioComponentFlag_IsV3AudioUnit) == 0)
// ARA_WARN("This Audio Unit has not yet been updated to version 3 of the Audio Unit API, and thus might not work in future macOS releases.");
// on ARM machines, adopting Audio Unit v3 is required for proper ARA support due to out-of-process operation
ARA_WARN("This Audio Unit has not yet been updated to version 3 of the Audio Unit API, and therefore cannot use ARA when loaded out-of-process.");
#endif
}
}
}
}
Expand Down

0 comments on commit 753b5e0

Please sign in to comment.