Re: [LAD] Jack ring buffer (again)
On Sat, 14 May 2016, Will Godfrey wrote: While I understand that generally you can't be certain of writing or reading all bytes in a block of data in one call, what about the specific case where you *always* read and write the same number of bytes and the buffer is an exact multiple of this size. e.g data block is 5 bytes & buffer size is 75 bytes. I don't think it matters... That is, I think the buffer could be 16bytes and you only use 3 bytes at a time (ie. MIDI) In general you can know how many bytes are available on the read end, and choose not to read untill there are at least three bytes. Then only read three bytes at a time... checking for at least three each time. (or whatever other size read you wish, audio is two bytes for 16bit, 3 for 24bit and 4 for 32bit Float, if you really want to do non-RT audio) Checking for wrap around is the libs chore. I have not had any missing info in my projects and never worried about buffer size (besides too small) or size of read/data chunk in relation to size. -- Len Ovens www.ovenwerks.net ___ Linux-audio-dev mailing list Linux-audio-dev@lists.linuxaudio.org http://lists.linuxaudio.org/listinfo/linux-audio-dev
Re: [LAD] Jack ring buffer (again)
On 14.05.2016 09:18, Will Godfrey wrote: I'm not sure if this has been covered before... Similar questions seem to come up every couple of months. While I understand that generally you can't be certain of writing or reading all bytes in a block of data in one call, what about the specific case where you *always* read and write the same number of bytes and the buffer is an exact multiple of this size. e.g data block is 5 bytes & buffer size is 75 bytes. > No I'm not intending to use such an example, I just want to cover worst case :) If that doesn't work, what about the case when you are always working in powers of 2? e.g data block is 16 bytes & buffer size is 1024 bytes. libjack *always* allocates a buffer of size (2^x). *but* 1 byte is reserved to discriminate between *empty* and *full* state of the buffer, the usable size of ringbuffer thus is actually (2^x - 1). https://github.com/jackaudio/jack1/blob/master/libjack/ringbuffer.c#L32 ___ Linux-audio-dev mailing list Linux-audio-dev@lists.linuxaudio.org http://lists.linuxaudio.org/listinfo/linux-audio-dev
[LAD] Jack ring buffer (again)
I'm not sure if this has been covered before... While I understand that generally you can't be certain of writing or reading all bytes in a block of data in one call, what about the specific case where you *always* read and write the same number of bytes and the buffer is an exact multiple of this size. e.g data block is 5 bytes & buffer size is 75 bytes. No I'm not intending to use such an example, I just want to cover worst case :) If that doesn't work, what about the case when you are always working in powers of 2? e.g data block is 16 bytes & buffer size is 1024 bytes. -- Will J Godfrey http://www.musically.me.uk Say you have a poem and I have a tune. Exchange them and we can both have a poem, a tune, and a song. ___ Linux-audio-dev mailing list Linux-audio-dev@lists.linuxaudio.org http://lists.linuxaudio.org/listinfo/linux-audio-dev