getting AU kernels to react to stream format changes
getting AU kernels to react to stream format changes
- Subject: getting AU kernels to react to stream format changes
- From: Marc Poirier <email@hidden>
- Date: Tue, 15 Feb 2005 17:39:27 -0500
Something that I've noticed before, but hasn't actually affected me
until something I'm working on now, is that there's no easy way using
AUEffectBase and AUKernelBase to have your kernels react to a change in
sample rate or max frames per slice. Right now I'm working on an AU
that uses kernels and each one allocates a buffer that is dependent on
the sample rate. So I had to add my own technique for letting each
kernel know about this, but it seems to me that it would make a lot of
sense to have something like this in AUEffectBase as I'm sure that it
must come up for others, too.
I was thinking that maybe there could be a SampleRateChanged() method
and a MaxFramesPerSliceChanged() method added to AUKernelBase, and then
AUEffectBase could call these when appropriate. I was thinking that
the checking and notifying could occur in
AUEffectBase::MaintainKernels(), perhaps. Here's a possible
implementation:
void AUEffectBase::MaintainKernels()
{
UInt32 nChannels = GetNumberOfChannels();
UInt32 prevNumChannels = mKernelList.size();
if (mKernelList.size() < nChannels) {
mKernelList.reserve(nChannels);
for (UInt32 i = mKernelList.size(); i < nChannels; ++i)
mKernelList.push_back(NewKernel());
} else
while (mKernelList.size() > nChannels) {
AUKernelBase *kernel = mKernelList.back();
delete kernel;
mKernelList.pop_back();
}
for(unsigned int i = 0; i < nChannels; i++ )
{
if(mKernelList[i]) {
mKernelList[i]->SetLastKernel(i == nChannels-1 );
mKernelList[i]->SetChannelNum (i);
if (i < prevNumChannels)
{
if (GetSampleRate() != mPrevSampleRate)
mKernelList[i]->SampleRateChanged(GetSampleRate());
if (GetMaxFramesPerSlice() != mPrevMaxFramesPerSlice)
mKernelList[i]->MaxFramesPerSliceChanged(GetMaxFramesPerSlice());
}
}
}
mPrevSampleRate = GetSampleRate();
mPrevMaxFramesPerSlice = GetMaxFramesPerSlice();
}
In that example, mPrevSampleRate and mPrevMaxFramesPerSlice would also
have to be added as members of AUEffectBase (and initialized to
something in the constructor).
What do others think?
thanks,
Marc
_______________________________________________
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