static void HandleInputBuffer (
void *aqData,
AudioQueueRef inAQ,
AudioQueueBufferRef inBuffer,
const AudioTimeStamp *inStartTime,
UInt32 inNumPackets,
const AudioStreamPacketDescription *inPacketDesc
) {
RecordState *pAqData = (RecordState *) aqData;
if (inNumPackets == 0 &&
pAqData->dataFormat.mBytesPerPacket != 0)
inNumPackets =
inBuffer->mAudioDataByteSize / pAqData->dataFormat.mBytesPerPacket;
SInt16 *buf = (SInt16 *)inBuffer->mAudioData;
for(int i=0; i< inBuffer->mAudioDataByteSize / 2; i=i+2) {
printf("\n%d\n%d ", buf[i], buf[i+1]);
}
if (AudioFileWritePackets (
pAqData->audioFile,
NO,
inBuffer->mAudioDataByteSize,
inPacketDesc,
pAqData->currentPacket,
&inNumPackets,
inBuffer->mAudioData
) == noErr) {
pAqData->currentPacket += inNumPackets;
if (pAqData->recording == 0)
return;
AudioQueueEnqueueBuffer (
pAqData->queue,
inBuffer,
0,
NULL
);
}
}
Many Thanks!