Thank you all for the responses!
On Mon, Feb 29, 2016 at 9:05 PM, Harry van Haaren <harryhaaren@gmail.com> wrote:
> On Mon, Feb 29, 2016 at 7:52 PM, Spencer Jackson <ssjackson71@gmail.com>
> wrote:
>> > The generic solution for cases like this is a lock-free ringbuffer.
>> I've also used the jack ringbuffer for this and it was easy enough.
>
> Simple tutorial on using JACK ringbuffer and C++ event class here:
> https://github.com/harryhaaren/realtimeAudioThreading
I've looked into JACK's ringbuffer implementation. It doesn't look too
complicated. Thank you all for suggesting it! But I'm a little bit
concerned about ISO standard compliance. According to the
multi-threading-aware update to the C11 and C++11 memory models, the
access to the ringbuffer's data (*buf) is technically a data race and
therefore invokes undefined behaviour. Only read_ptr/write_ptr are
somewhat protected (volatile). From what I understand, given the
C11/C++11 memory model, one is supposed to use "atomics" for all
read/write accesses in such situations (including *buf). But so far, I
havn't gathered much experience in this kind of lock-free programming.