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