title: Accessing raw audio data with Audio Queue using AudioFileReadPackets
body: <p>I'm attempting to access the raw audio data sent to the Audio Queue callback, but I after calling AudioFileReadPackets, the number of bytes (numBytes) is 0.  </p>
  
  <pre><code>void AQRecorder::MyInputBufferHandler(void *inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer, const AudioTimeStamp * inStartTime, UInt32 inNumPackets, const AudioStreamPacketDescription* inPacketDesc) {
  
  AQRecorder *aqr = (AQRecorder *)inUserData;
  
  try {
      if (inNumPackets &gt; 0) {
  
          //read packets
          UInt32 numBytes;
  
          OSStatus result = AudioFileReadPackets(aqr-&gt;mRecordFile,      // The audio file from which packets of audio data are to be read.
                                                 FALSE,                   // Set to true to cache the data. Otherwise, set to false.
                                                 &amp;numBytes,               // On output, a pointer to the number of bytes actually returned.
                                                 (__bridge AudioStreamPacketDescription*)inPacketDesc,    // A pointer to an array of packet descriptions that have been allocated.
                                                 aqr-&gt;mRecordPacket,  // The packet index of the first packet you want to be returned.
                                                 &amp;inNumPackets,               // On input, a pointer to the number of packets to read. On output, the number of packets actually read.                                           
                                                 inBuffer-&gt;mAudioData); // A pointer to user-allocated memory.
  
          inBuffer-&gt;mAudioDataByteSize = numBytes;       
          SInt16 *testBuffer = (SInt16*)inBuffer-&gt;mAudioData;
  
          for (int i=0; i &lt; numBytes; i++)
          {
              UInt16 currentData = testBuffer[i];
              printf("Current data in testbuffer is %d", currentData);
          }
  
      // if we're not stopping, re-enqueue the buffe so that it gets filled again
      if (aqr-&gt;IsRunning())
          XThrowIfError(AudioQueueEnqueueBuffer(inAQ, inBuffer, 0, NULL), "AudioQueueEnqueueBuffer failed");
  } catch (CAXException e) {
      char buf[256];
      fprintf(stderr, "Error: %s (%s)\n", e.mOperation, e.FormatError(buf));
  }
  }
  </code></pre>
  
  <p>I am able to get values between 0 and 4294967296 when I print out just the first index of testBuffer, so it does not seem to be empty.  Any ideas why numBytes is 0 after AudioFileReadPackets executes?</p>