Re: AU2 - questions about presets and ClassInfo
Re: AU2 - questions about presets and ClassInfo
- Subject: Re: AU2 - questions about presets and ClassInfo
- From: Marc Poirier <email@hidden>
- Date: Thu, 3 Oct 2002 14:29:05 +0200 (CEST)
>
> I would also think that, in the case of choosing a factory preset as the
>
> CurrentPreset, it also shouldn't matter if a name is supplied. But in
>
> DispatchSetProperty, a name is required:
>
>
>
> case kAudioUnitProperty_CurrentPreset:
>
> <snip>
>
> if (newPreset.presetName) {
>
> if (newPreset.presetNumber < 0 || NewFactoryPresetSet(newPreset) == noErr) {
>
> <snip>
>
> } else
>
> result = kAudioUnitErr_InvalidPropertyValue;
>
> } else
>
> result = kAudioUnitErr_InvalidPropertyValue;
>
>
>
> Shouldn't that be something more like:
>
>
>
> if ( newPreset.presetName && (newPreset.presetNumber < 0) )
>
> // ...store the new name and set the preset number...
>
> else if ( (newPreset.presetNumber >= 0) && (NewFactoryPresetSet(newPreset)
>
> == noErr) )
>
> // ...only set the preset number...
>
> else
>
> result = kAudioUnitErr_InvalidPropertyValue;
>
>
>
> Maybe I'm wrong about this, though...
>
>
>
No - you're right - with a slight tweak:
>
>
if (newPreset.presetName && newPreset.presetNumber < 0)
>
{
>
CFRelease (mCurrentPreset.presetName);
>
mCurrentPreset = newPreset;
>
CFRetain (mCurrentPreset.presetName);
>
}
>
else if (newPreset.presetNumber >= 0 && NewFactoryPresetSet(newPreset) ==
>
noErr)
>
{
>
// NewFactoryPreset SHOULD call SetAFactoryPreset if the preset is valid
>
// from its own list of preset number->name
>
}
>
else
>
result = kAudioUnitErr_InvalidPropertyValue;
Okay, I changed my AUBase.cpp to be like this in DispatchSetProperty and
am leaving it up to my plugin's implementation of NewFactoryPresetSet to
decide whether or not the preset ID is valid:
case kAudioUnitProperty_CurrentPreset:
{
require(inScope == kAudioUnitScope_Global, InvalidScope);
AUPreset & newPreset = *(AUPreset *)inData;
if (newPreset.presetNumber >= 0)
result = NewFactoryPresetSet(newPreset);
else if (newPreset.presetName) {
CFRelease (mCurrentPreset.presetName);
mCurrentPreset = newPreset;
CFRetain (mCurrentPreset.presetName);
} else
result = kAudioUnitErr_InvalidPropertyValue;
}
break;
Does that seem like a good fix to apply to AUBase.cpp, or is it incorrect
in any way?
Thanks,
Marc
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.