Why did AudioQueueAllocateBuffer fail?

200 views Asked by At

Device: iPhone X

System: OS 15.1

I came across an error when using AudioQueue to play some data. The error is returned by this API and its value is -308.

OSStatus status = AudioQueueAllocateBuffer(_audioQueue, MIN_SIZE_PER_FRAME, &audioQueueBuffers[i]); 

After that, All the AudioQueue APIs will return the error -66671. The official documents define as below.

kAudioQueueErr_QueueInvalidated
In iOS, the audio server has exited, causing the audio queue to become invalid.

However, I have no idea what the audio server means. Could any guy tell me what had happened?

1

There are 1 answers

0
M.Faster On

This problem may be caused by an abnormal shutdown of the media service。The solution is to destroy the audioQueue and recreate it when you got an error。 See https://developer.apple.com/forums/thread/693371。 Refer to the Apple Media Engineer's answers。