Attention! Translated article might be found on my English blog.

2016年4月14日木曜日

deprecatedなコードを含むAudioUnit取得処理を一新する

更新前:
ComponentDescription desc;
desc.componentType = kAudioUnitType_Effect;
desc.componentSubType = kAudioUnitSubType_MatrixReverb;
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
desc.componentFlagsMask = 0;
desc.componentFlags = 0;

Component comp = NULL;
comp = FindNextComponent(comp,&desc);

AudioUnit unit;
OSStatus err = OpenAComponent(comp, &unit);
NSAssert(err == noErr@"");
err = AudioUnitInitialize(unit);
NSAssert(err == noErr@"");

更新後:
AudioComponentDescription desc;
desc.componentType = kAudioUnitType_Effect;
desc.componentSubType = kAudioUnitSubType_MatrixReverb;
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
desc.componentFlagsMask = 0;
desc.componentFlags = 0;

AudioComponent comp = NULL;
comp = AudioComponentFindNext(comp,&desc);

AudioUnit unit;
OSStatus err = AudioComponentInstanceNew(comp, &unit);
NSAssert(err == noErr, @"");
err = AudioUnitInitialize(unit);
NSAssert(err == noErr, @"");

ComponentDescription -> AudioComponentDescription
Component -> AudioComponent
FindNextComponent() -> AudioComponentFindNext()
OpenAComponent()-> AudioComponentInstanceNew()
ComponentResult -> OSStatus
CloseComponent() -> AudioComponentInstanceDispose()