static const UInt32 kNumberBuffers = 3;
static const double kBufferDurationSeconds = 0.1;
static const UInt32 kMaxBufferSize = 0x10000; // limit size to 64K
static const UInt32 kMinBufferSize = 0x4000; // limit size to 16K
…………
void YKK_AudioQueueBufferCallback(void * inUserData,
AudioQueueRef inAQ,
AudioQueueBufferRef inCompleteAQBuffer) {
YKK_AudioQueueFilePlayer *player = (YKK_AudioQueueFilePlayer*)inUserData;
if (player->_done) return;
UInt32 numBytes;
UInt32 nPackets = player->_numPacketsToRead;
// Read nPackets worth of data into buffer
OSStatus result = AudioFileReadPackets(player->_audioFile, false, &numBytes, player->_packetDescs, player->_currentPacket, &nPackets, inCompleteAQBuffer->mAudioData);
for (int k=0; k<kNumberBuffers; k++) {
printf("buf data %d:%f\n", k, ((float*)(inCompleteAQBuffer->mAudioData))[k]);
}
…………