创建第3版AudioUnit的示例代码演示了实现如何返回用于渲染处理的功能块。该块将通过pullInputBlock
从链中的前一个 AxudioUnit中获取样本,并向输出缓冲区提供处理后的样本。如果单位下游的单位没有,它也必须提供一些输出缓冲区。下面是代码的AudioUnit子类的摘录:版本3 AudioUnits:internalRenderBlock中的最小frameCount
- (AUInternalRenderBlock)internalRenderBlock {
/*
Capture in locals to avoid ObjC member lookups.
*/
// Specify captured objects are mutable.
__block FilterDSPKernel *state = &_kernel;
__block BufferedInputBus *input = &_inputBus;
return Block_copy(^AUAudioUnitStatus(
AudioUnitRenderActionFlags *actionFlags,
const AudioTimeStamp *timestamp,
AVAudioFrameCount frameCount,
NSInteger outputBusNumber,
AudioBufferList *outputData,
const AURenderEvent *realtimeEventListHead,
AURenderPullInputBlock pullInputBlock) {
...
});
这是好的,如果处理不要求调用该块之前知道frameCount
,但许多应用程序都需要为了这个块之前知道frameCount
分配内存,准备处理参数等。
解决此问题的一种方法是累积以前的输出缓冲区,每个调用块只输出frameCount
样本,但只有在知道最小值frameCount
时才能使用。为了工作,处理必须被初始化为大于该帧数的大小。有没有办法指定或获得frameCount
的最小值或强制它成为特定值?
感谢您指出我正确的方向,但我也对OSX感兴趣(我不知道这些API对于不同的操作系统来说是如此不同)。任何想法为OSX上运行的应用程序设置此位置? – mondaugen
只需将它放在这里,我就可以了:看起来AUDeferredRenderer可以帮助我。 – mondaugen