title: AudioQueueDispose delay
body: <p>According to documentation here <a href="https://developer.apple.com/library/mac/documentation/MusicAudio/Reference/AudioQueueReference/#//apple_ref/c/func/AudioQueueDispose">https://developer.apple.com/library/mac/documentation/MusicAudio/Reference/AudioQueueReference/#//apple_ref/c/func/AudioQueueDispose</a> </p>
  
  <pre><code>err = AudioQueueDispose(queue, true);
  </code></pre>
  
  <p>I use <code>true</code> so dispose of <code>AudioQueue</code> happens immediately, although it does dispose queue immediately sometimes , other times it has delay 3-4 seconds up to 13 seconds on the device. <code>err = AudioQueueStop(queue, true)</code> has the same problem as well. </p>
  
  <p>My understanding is that both functions try to flush-release buffers already and about to be enqueued...<br>
  so I even help my call-back function to flush the buffers if <code>AudioQueueDispose</code> is going to be called.</p>
  
  <pre><code>static void MyAQOutputCallBack(void *inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inCompleteAQBuffer)
  {
    if (player.shouldDispose) {
          printf("player shouldDispose !!!!!!!!!!!\n\n\n\n\n\n");
          OSStatus dispose = AudioQueueFlush (inAQ);
          return;
      }
  }
  </code></pre>
  
  <p>Since I am going to record something using <code>AudioQueues</code> after playing a track, I need this functions returned without delays. couple hundred milliseconds is okay but 3-4 seconds? that is unacceptable. </p>
  
  <p>Other <code>AudioQueue</code> functions also being called on the same thread and they seem working fine. </p>
  
  <p>I have also tried to call this on main thread to make sure if it is going to change anything or not</p>
  
  <p><code>[self performSelectorOnMainThread:@selector(tryOnMain) withObject:nil waitUntilDone:NO];</code> </p>
  
  <p>or </p>
  
  <p><code>dispatch_sync(dispatch_get_main_queue(),^{</code> didnt do any difference</p>
  
  <p>Any idea what might be happening? </p>