Re: Walking parameter lists safely
Re: Walking parameter lists safely
- Subject: Re: Walking parameter lists safely
- From: Marc Poirier <email@hidden>
- Date: Wed, 12 Nov 2003 16:19:25 -0600 (CST)
Well my first thought is: are you making sure to GetPropertyInfo to
figure out the size of the parameter list? And are you making sure to
divide that by the size of each array member to get the array count (that
could explain crashing and bogus IDs if you are not)? Here's a function
that I once wrote for getting the number of parameters in a scope:
UInt32 GetNumParameters(AudioUnit inComponentInstance, AudioUnitScope inScope)
{
UInt32 datasize = 0;
Boolean writable;
ComponentResult result = AudioUnitGetPropertyInfo(inComponentInstance, kAudioUnitProperty_ParameterList, inScope, (AudioUnitElement)0, &datasize, &writable);
if (result == noErr)
return datasize / sizeof(AudioUnitParameterID);
else
return 0;
}
And here's another one that I wrote allocates a parameter IDs array with
malloc, fetches the list into the array, and returns that:
AudioUnitParameterID * CreateParameterList(AudioUnit inComponentInstance, AudioUnitScope inScope, UInt32 * outNumParameters)
{
UInt32 numParameters = GetNumParameters(inComponentInstance, inScope);
if (numParameters == 0)
return NULL;
UInt32 datasize = numParameters * sizeof(AudioUnitParameterID);
AudioUnitParameterID * parameterList = (AudioUnitParameterID*) malloc(datasize);
if (parameterList == NULL)
return NULL;
ComponentResult result = AudioUnitGetProperty(inComponentInstance, kAudioUnitProperty_ParameterList, inScope, (AudioUnitElement)0, parameterList, &datasize);
if (result == noErr)
{
*outNumParameters = numParameters;
return parameterList;
}
else
{
free(parameterList);
return NULL;
}
}
Anyway, I don't know if that example code is useful at all, maybe it's
exactly what you already are doing, but if it is then I guess it would
seem that you are dealing with some rather buggy AUs. I mean, if any AU
actually crashes from a SetParameter, even if with an invalid parameter
ID, that seems a little ridiculous to me (it can just return
kAudioUnitErr_InvalidParameter). And if the IDs in the list really are
bogus, then again, it doesn't seem like there's anything special that you
should have to do to work with that, it's just broken.
Marc
On Wed, 12 Nov 2003, Robert Grant wrote:
>
Here's a basic one...
>
>
What's the safe and useful way to walk the list parameters returned by
>
kAudioUnitProperty_ParameterList? I'm finding that some AU instruments
>
are returning bogus param IDs which when info is requested crash the
>
app. Other AUs are returning duplicate names and others are leaving big
>
gaps.
>
>
I'm requesting the params that are in global scope.
>
>
Thanks,
>
>
Robert.
_______________________________________________
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.