[LAU] Simple, easy multithreaded circular buffer library for Linux?

Fons Adriaensen fons at kokkinizita.net
Sat Oct 18 17:30:06 EDT 2008


On Sat, Oct 18, 2008 at 10:56:31PM +0200, Paul Davis wrote:

> if read_ptr > size then the math should result in the write space being
> *under* estimated. if thats not happening then my worst nightmares come
> true, which has happened before. is there a signed/unsigned issue going
> on here?

The only way to know is to verify all the possible cases in
jack_ringbuffer_write_space() and jack_ringbuffer_read_space(),
taking into account that the masking operation may not have
been applied at the time these are called, and that 'the other'
*_ptr could be >= size.

Note that this is *much* simpler in the C++ class that
I poster earlier - there are no conditions at all in
write_avail() or read_avail(). The essential difference
is that I don't mask the stored values of _nrd and _nwr
(the equivalents of read_ptr and write_ptr). This also
removes the ambiguity between an empty and full buffer.
The downside is that it depends on the user code acting
in the correct way (which seems reasonable).

Ciao,

-- 
FA

Laboratorio di Acustica ed Elettroacustica
Parma, Italia

Lascia la spina, cogli la rosa.




More information about the Linux-audio-user mailing list