[LAD] a *simple* ring buffer, comments pls?
Arnold Krille
arnold at arnoldarts.de
Fri Jul 8 20:59:14 UTC 2011
On Friday 08 July 2011 22:41:54 Paul Davis wrote:
> On Fri, Jul 8, 2011 at 3:53 PM, Fons Adriaensen <fons at linuxaudio.org> wrote:
> > - You can use all 2^n elements, there is no ambiguity between
> > full and empty.
>
> so what does it mean when wr_index == rd_index?
Empty for reading. Lots of space for writing.
Its much more interesting to see what happens when the indezes cross the 2^32
or 2^64 mark, then the write-index will be smaller then the read-index untill
the read-index catches up. But as far as I see currently, this wouldn't be a
problem either. The writer only has to stop writing when its at read_ptr - 1.
Maybe I don't understand it all, but with fons approach I think it only works
when the buffer-sizes are 2^n. When you have a buffer of say 5 elements, doing
the modulo at the element-access and not at the read/write-head-movement, this
will jump every now and then, right?
Have fun,
Arnold
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.linuxaudio.org/pipermail/linux-audio-dev/attachments/20110708/3d618d41/attachment.pgp>
More information about the Linux-audio-dev
mailing list