Re: AU HostCallback - musical location
Re: AU HostCallback - musical location
- Subject: Re: AU HostCallback - musical location
- From: Bill Stewart <email@hidden>
- Date: Tue, 01 Oct 2002 12:42:40 -0700
Marc
on 28/9/02 7:10 AM, Marc Poirier wrote:
>
> To add the additional support that has been discussed we're proposing
>
> the following:
>
>
>
> typedef struct HostCallbackInfo {
>
> void * hostUserData;
>
> HostCallback_GetBeatAndTempo beatAndTempoProc;
>
> HostCallback_GetMusicalTimeLocation musicalTimeLocationProc;
>
> } HostCallbackInfo;
>
>
>
> An AudioUnit can determine if its being called for just the first proc
>
> through checking the size of the passed in data proc.
>
>
Oh, this reminds me of a little (possible) bug I found a while ago: In
>
AUBase.cpp, memcpy is used for kAudioUnitProperty_HostCallbacks in
>
DispatchSetProperty, but an assignment is done in DispatchGetProperty.
>
This is fine for now given the struct, but might be an issue in the
>
future, so memcpy probably should be used in both cases, I think...
Yes indeed - in fact this is a bug.
The implementation for DispatchSetProperty currently is:
case kAudioUnitProperty_HostCallbacks:
require(inScope == kAudioUnitScope_Global, InvalidScope);
memcpy (&mHostCallbackInfo, inData, inDataSize);
break;
And this is wrong and will cause problems...
The correction that you should apply (and we will update this ourselves) is:
case kAudioUnitProperty_HostCallbacks:
{
require(inScope == kAudioUnitScope_Global, InvalidScope);
UInt32 availSize = (inDataSize < sizeof (mHostCallbackInfo) ?
inDataSize : sizeof (mHostCallbackInfo));
memset (&mHostCallbackInfo, 0, sizeof (mHostCallbackInfo));
memcpy (&mHostCallbackInfo, inData, availSize);
break;
}
(Having been bitten by this once, I decided to be ultra conservative here -
thus the memset of the mHostCallbackInfo member to make sure that if this
property is being set again with a different size, there aren't any
dangling/stale addresses)
I'm also tweaking the constructor to do the same memset - that way I don't
have to keep changing this as we add additional callbacks:)
Bill
>
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.
--
mailto:email@hidden
tel: +1 408 974 4056
__________________________________________________________________________
"Much human ingenuity has gone into finding the ultimate Before.
The current state of knowledge can be summarized thus:
In the beginning, there was nothing, which exploded" - Terry Pratchett
__________________________________________________________________________
_______________________________________________
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.