We have an audio unit that read the buffers, and i have memory growth in the callback function. it works great but i am spending much time to solve this leak.
after eliminating the problem i found that the the basic configuration code, that is written by apple , is causing the memory growth(100k a second )
this is my callback, after taking all other stuff, with the problem :
AudioComponentInstance audioUnit;
static OSStatus recordingCallback(void *inRefCon,
AudioUnitRenderActionFlags *ioActionFlags,
const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber,
UInt32 inNumberFrames,
AudioBufferList *ioData)
{
AudioBuffer buffer;
buffer.mNumberChannels = 1;
buffer.mDataByteSize = inNumberFrames * 2;
buffer.mData = malloc( inNumberFrames * 2 );
// Put buffer in a AudioBufferList
AudioBufferList bufferList;
bufferList.mNumberBuffers = 1;
bufferList.mBuffers[0] = buffer;
OSStatus status;
// problematic block ******
status = AudioUnitRender(audioUnit,
ioActionFlags,
inTimeStamp,
inBusNumber,
inNumberFrames,
&bufferList);
//end of problem block ******
free(buffer.mData);
}
removing that block solve the problem.
does the audioUnit needs a property ? what could be my basic problem here ? thanks.