[Portaudio] using paFramesPerBufferUnspecified

Ross Bencina rossb-lists at audiomulch.com
Tue Dec 15 01:55:24 EST 2015

Hello Gilles,

On 15/12/2015 5:41 PM, Gilles Barges wrote:
> I’d like to use the paFramesPerBufferUnspecified option to shorten
> latencies.
> In this case, it is said that the number of frames for each callback may
> vary.

Yes, the value may vary. For example, the value might depend on the fill 
level of a native audio buffer at the time of the callback. The callback 
will ask to fill all the empty space in the buffer.

> So it seems that I have to wait for the callback to occur in order to
> know how many frames I have to push on output.


> In my architecture I have a dedicated thread (not the CB thread) to
> prepare in advance the next chunk of audio.

It would be unusual for there to be benefit to such a scheme, but I 
trust you know what you're doing.

> As soon as the callback occurs, I can start to prepare audio.

Do you mean that as soon as one callback is called, you start to prepare 
for the next one?

> But here I don’t know how many frames the next callback will ask !

Neither does PortAudio.

> So, is paFramesPerBufferUnspecified only usable when the audio is
> elaborated directly from inside the callback function ?

You can use it however you want. But you won't know how many samples it 
needs until the callback is called.


More information about the Portaudio mailing list