Re: AUEffectBase::ChangeStreamFormat changes sOld
Re: AUEffectBase::ChangeStreamFormat changes sOld
- Subject: Re: AUEffectBase::ChangeStreamFormat changes sOld
- From: Shai Shasag <email@hidden>
- Date: Wed, 29 Sep 2004 14:25:23 +0200
On 29/09/2004, at 14:07, kelly jacklin wrote:
On Sep 29, 2004, at 4:58 AM, Shai Shasag wrote:
When the sample rate of the session has changed (ie. under Logic)
ChangeStreamFormat gets called with the parameters:
const CAStreamBasicDescription& sOld, const CAStreamBasicDescription&
sNew
Where sOld.mSampleRate holds the current sample rate and sNew
.mSampleRate hold the new.
My code than calls AUEffectBase::ChangeStreamFormat passing sOld and
sNew.
When AUEffectBase::ChangeStreamFormat returns, sOld.mSampleRate holds
the NEW sample rate!
This happens despite the fact that sOld is defined as const
CAStreamBasicDescription&.
Hi Shai,
The format you are passed is a const reference to the actual (live)
format data structure in the AUBase code (actually in the
AUScopeElement, if memory serves).
It is not const to the owner of the original data structure, only
const to you...
Ideally, the SDK should have made a copy of the old format
CAStreamBasicDescription, and passed you a const reference to that,
but instead, it just passes a const reference to the live data
structure, i.e.:
const CAStreamBasicDescription &curDesc =
GetStreamFormat(inScope, inElement);
// ...
result = ChangeStreamFormat(inScope, inElement, curDesc,
newDesc);
If you require this information to persist across the call to
AUEffectBase::ChangeStreamFormat, make a copy of sOld.
Always be aware, whenever you receive a reference to something, that
it is just a pointer to a structure, and that the original structure
could be changed by any calls you make. Just because your reference
(pointer) is const, does not mean that the underlying data is const
(it usually is not)...
Hope this helps,
Kelly,
Thanks for the (very) fast answer.
I used a copy of sOld and now things work.
However the current design is very confusing.
1st, If sOld refers to the current format, and I can get the current
format by calling GetStreamFormat, why pass it to ChangeStreamFormat at
all?
2nd, if sOld is passed anyway, probably so I can easily compare it to
sNew, why not pass a copy? Clearly I cannot use sOld as it is now.
Are there any other places in the AU SDK with similar problem, that I
should look out for?
Thanks,
Shai Shasag
Senior Software Engineer
Waves Audio Ltd.
Phone: +972-36084007; Fax: +972-36084056;
------------------------------------------------------------------------
------------
"Perfection is achieved, not when there is nothing more to add,
but when there is nothing left to take away." - Antoine de Saint Exupery
_______________________________________________
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