Q:

OSX: AudioUnit callback not being called enough

I've got a simple app that records audio, and processes the bytes that are coming in.  I've found that I am missing quite a lot of the data that should be coming in, something like 2/3 of it.  
This routine:
static OSStatus AudioCallBack (void* userData, AudioUnitRenderActionFlags* ioActionFlags, const AudioTimeStamp* inTimeStamp, UInt32 inBusNumber, UInt32 nFrames, AudioBufferList* ioData)

is not being called enough.  What can typically cause this?   

A:

If you try to do any significant amount of processing inside an Audio Unit callback (or anything else that does Objective C messaging, synchronization, locks, or memory management, etc.),  your callback function or block might take too long, and thus your app might miss some callbacks, and thus miss some audio data.   You can check for this by removing all processing inside the callback, and just total the number of audio samples received to make sure the right amount is coming in per second. 
If this is happening, then, to prevent your callback from blocking too long, you should rearrange your processing to do all or most of it in another thread, and just quickly copy the data out of the Audio Unit callback into an array, queue, or fifo to pass to that other processing task or thread.   Since you know the rate of Audio Callbacks, you can determine the correct rate to poll for the needed processing.