[Portaudio] Lock free queue for callback thread

ChordWizard Software corporate at chordwizard.com
Wed Apr 11 17:12:29 EDT 2012


Hi Ross,

> Just use pa_ringbuffer.c/.h That's the srsw queue we use internally in 
> PortAudio. It's in src/common

Thanks, that's perfect.  I had noticed this module when first exploring, but its significance escaped me at the time.


>> Therefore I should make the size as small as
>> possible and tweakable to the user?
>
>I'm not sure what your logic is behind this.
>I usually dimension the queue to accomodate the maiximum data rate 
>expected through it (you'd need to wait if the queue was full).

I'm thinking that if the queue needs to make sure that it has a full buffer ready for the callback thread each time without glitching, then we can no longer generate audio on demand, but instead need to prepare at least one callback buffer worth of samples ahead of time.  

This would increase the latency between synthesis in response to an audio event "now" and the time when it appears at the output, wouldn't it?

Speaking of buffer sizes, I'm getting the impression that using paFramesPerBufferUnspecified gives the device greatest flexbility to open a lowest latency stream.  In that case, how do we interrogate the stream to find out the actual buffer size chosen so that we setup the lock free queue to accommodate it?

The only place I can see where the actual buffer size is provided is in the callback itself.  But by then we already need the queue to be up and running.  Does this mean the callback buffer size can change?  I seem to remember that ASIO has this possibility. How are we supposed to handle that?

Regards,

Stephen Clarke
Managing Director
ChordWizard Software Pty Ltd
corporate at chordwizard.com
http://www.chordwizard.com
ph: (+61) 2 4960 9520
fax: (+61) 2 4960 9580



More information about the Portaudio mailing list