• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
getting AU kernels to react to stream format changes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Prev by Date: Re: More Glitches
  • Next by Date: Re: envelope error
  • Previous by thread: Re: Which is the correct SDK location?
  • Next by thread: quick and dirty way to play some data?
  • Index(es):
    • Date
    • Thread