Goz
Goz

Reputation: 62323

AudioQueue capture and returning different buffer sizes

I have an AudioQueue based application working almost perfectly. I'm suffering an issue, however. When I call AudioQueueAllocateBuffer I specifically request a buffer size of 512 (as I'm performing an FFT on the data). However when the callback fires I find that from time to time I get buffer sizes that are less than 512.

This is infuriating. Is my only solution to set up some sort of internal buffering of the incoming data to smooth out these issues? Why do I specify a value to the allocate buffer and then the iPhone return me a different number of samples?

Any help would be much appreciated, as I'm about to go mad.

Cheers!

Oscar

Upvotes: 3

Views: 444

Answers (1)

hotpaw2
hotpaw2

Reputation: 70673

Your solution is to set up your own internal buffering of the incoming audio data until you have buffered the amount of data required.

The buffer size you allocate indicates the maximum amount of data that can fill that buffer, not the minimum. The Audio Queue API is based on top of other iOS audio APIs, and may change its behavior depending on a number of things (what that underlying API is doing, audio session or sample rate as requested by other apps, background state(s), OS version, different underlying hardware on different device models, etc.) Even the lowest level public audio API (RemoteIO) will change it's returned buffer size, depending.

Upvotes: 2

Related Questions