title: How to play NSData(bytes) with Audio Queue's?
body: <p>how to play [NSData bytes] with Audio Queue Services, from speakHere example the bytes are token from the AudioFile, but i'm having sound downloaded from internet i need to play it with Queue Services. Iv've tried to the parameters like this:</p>
  
  <pre><code>      memset(&amp;mDataFormat, 0, sizeof(mDataFormat));
  audioData = [[NSData alloc]initWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"1" ofType:@"mp3"]];
      UInt32 size = sizeof(mDataFormat.mSampleRate);
      XThrowIfError(AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareSampleRate, &amp;size,&amp;mDataFormat.mSampleRate), "couldn't get hardware sample rate");
      size = sizeof(mDataFormat.mChannelsPerFrame);
      XThrowIfError(AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareInputNumberChannels,&amp;size,&amp;mDataFormat.mChannelsPerFrame), "couldn't get input channel count");
      mDataFormat.mFormatID = kAudioFormatLinearPCM;
      if (mDataFormat.mFormatID == kAudioFormatLinearPCM)
      {
          mDataFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked;
          mDataFormat.mBitsPerChannel = 8;
          mDataFormat.mBytesPerPacket = mDataFormat.mBytesPerFrame = (mDataFormat.mBitsPerChannel / 8) * mDataFormat.mChannelsPerFrame;
          mDataFormat.mFramesPerPacket = 1;
      }
  
  
  
  AudioQueueNewOutput(&amp;mDataFormat, AQPlayer::AQBufferCallback, this, CFRunLoopGetCurrent(), kCFRunLoopCommonModes, 0, &amp;mQueue);
  UInt32 maxPacketSize;
  UInt32 _size = sizeof(maxPacketSize);
  AudioFileGetProperty(mAudioFile, kAudioFilePropertyPacketSizeUpperBound, &amp;_size, &amp;maxPacketSize);
  UInt32 bufferByteSize = (UInt32)[audioData length];
  CalculateBytesForTime (mDataFormat, maxPacketSize, kBufferDurationSeconds, &amp;bufferByteSize, &amp;mNumPacketsToRead);
  AudioQueueSetParameter(mQueue, kAudioQueueParam_Volume, 1.0);
  </code></pre>
  
  <p>the callback is working but unfortunately a cannot set the bytes in the buffer: </p>
  
  <pre><code>if (nPackets &gt; 0) 
  {
      inCompleteAQBuffer-&gt;mAudioDataByteSize = numBytes;      
      inCompleteAQBuffer-&gt;mPacketDescriptionCount = nPackets; 
  
    for (int i = 0; i &lt; inCompleteAQBuffer-&gt;mAudioDataByteSize; i++)
     {
          char * cash = (void *)[THIS-&gt;audioData bytes];
  
         // inCompleteAQBuffer-&gt;mUserData[i] = cash[i];
  
     }
  
      //inCompleteAQBuffer-&gt;mUserData = data;
  </code></pre>
  
  <p>where inCompleteAQBuffer is AudioQueueBufferRef type, please help ...</p>