I am constructing audio graph, which has: AudioFilePlayer (Generator unit) -> GenericOutput (Output unit)
The basic idea:
AudioFilePlayer is producing audio frames to it's output. Generic output takes data from AudioFilePlayer's output as input. Than I can take that data and save it to other buffer.
My question is how to pull data from generic output to get data for offline rendering.
I did some research on it, and find out that I have to use AudioUnitRender on GenericOutput unit to pull audio data from it.
Uint32 frames = 512;
timestamp.mSampleTime = 0;
... While Loop ...
timestamp.mFlags = kAudioTimeStampSampleTimeValid;
bufferList.mNumberBuffers = 1;
bufferList.mBuffers[0].mNumberChannels = param->inputFormat.mChannelsPerFrame;
bufferList.mBuffers[0].mDataByteSize = frames * param->inputFormat.mChannelsPerFrame * sizeof(float);
bufferList.mBuffers[0].mData = NULL;
AudioUnitRenderActionFlags flags = 0;
OSStatus error = noErr;
if ((error = AudioUnitRender(param->genericOutput, &flags, ×tamp, 0, frames, &bufferList)) != noErr)
{
printf("Cannot AudioUnitRender: %d\n", error);
}
timestamp.mSampleTime += frames;
But i get error with number -50.
Am I setting input parameters wrong? Do I need to register any render callback functions to GenericOutput unit?