How to use AudioComponentRegister()?
How to use AudioComponentRegister()?
- Subject: How to use AudioComponentRegister()?
- From: patrick machielse <email@hidden>
- Date: Wed, 05 Mar 2014 22:57:16 +0100
My application needs to be sandboxed. The application uses 1 bundled AudioUnit.
In accordance with TN 2247 I've added:
<key>sandboxSafe</key>
<true/>
to my bundled audio unit's Info.plist.
https://developer.apple.com/library/mac/technotes/tn2247
Now I need to register it at runtime, so that the audio unit is enumerated when audio units are requested. Previously I used RegisterComponentFileRef(), which is deprecated as of 10.8. I assume that I must use AudioComponentRegister() to provide Sandbox support
The trouble is that I get a linker error when I use code similar to that in TN 2247. What I'm seeing is identical to this question on stackoverflow.com:
http://stackoverflow.com/questions/14705405/audio-units-dynamic-registration
Undefined symbols for architecture:
"_MyExampleAUFactoryFunction", referenced from:
AudioComponentRegister( const AudioComponentDescription * inDesc,
CFStringRef inName,
UInt32 inVersion,
AudioComponentFactoryFunction inFactory)
I've tried:
- linking against my audio unit .component file (which contains my version of '_MyExampleAUFactoryFunction').
- adding __attribute__((weak_import)) to the extern function declaration to atempt some sort of weak linking to the function.
- passing NULL as the last parameter of AudioComponentRegister().
I think I'm mis-understanding AudioComponentRegister().
- since a unit's factory function is listed in its Info.plist (and therefore public knowledge), why must I pass it in?
- must my bundled Audio Units be in a specific location for AudioComponentRegister() to find them? There is no path / url parameter.
- some sort of error value returned by AudioComponentRegister would probably have been helpful to me. Even RegisterComponentFileRef() provided that.
Or perhaps I should roll specific 'factory functions' within my host application:
extern AudioComponentPlugInInterface* PitchShiftUnitFactory(const AudioComponentDescription *inDesc) __attribute__((weak_import));
// for MIKRegisterBundledAudioUnit
AudioComponentPlugInInterface* HostPitchShiftUnitFactory(const AudioComponentDescription *inDesc)
{
NSURL *bundleURL = [[NSBundle mainBundle] URLForResource:@"PitchShiftUnit" withExtension:@"component"];
if ( !bundleURL ) { NSLog(@"PitchShiftUnit.component not found"); return NULL; }
[[NSBundle bundleWithURL:bundleURL] load];
if ( PitchShiftUnitFactory ) {
return PitchShiftUnitFactory(inDesc);
}
NSLog(@"PitchShiftUnitFactory() not found");
return nil;
}
void MIKRegisterBundledAudioUnit()
{
// fill out the version number for the AU
UInt32 version = 0x00010000;
// fill out the AudioComponentDescription
AudioComponentDescription description = { 0 };
description.componentType = kAudioUnitType_FormatConverter;
...
description.componentFlags = kAudioComponentFlag_SandboxSafe;
AudioComponentRegister(&description, CFSTR("My Company: PitchShift Unit"), version, HostPitchShiftUnitFactory);
}
But that still leaves me with the linking problem...
I would be very grateful if an 'Apple Insider' could point me in the right direction.
Thanks,
patrick
--
Patrick Machielse
Hieper Software
http://www.hieper.nl
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden