Kjetil S. Matheussen wrote:
Olivier Guilyardi:
For inter-thread communication there's Portaudio's ring buffer:
http://portaudio.com/trac/browser/portaudio/trunk/src/common/pa_ringbuffer.h
It can easily be used out of Portaudio (I'm currently doing that), and it
features memory barriers [1] which AFAIK Jack's ringbuffer doesn't.
One problem with everything Portaudio is this heavy naming scheme. For a simpler
API, you might like my little wrapper:
http://jackbeat.samalyse.org/browser/jackbeat/trunk/src/core/ringbuffer.h
Nice. It's probably quicker to copy the jack_ringbuffer.c file out of jack
though.
This isn't the same as Jack's ring buffer. It's a little wrapper around
Portaudio's ring buffer, which as said above, features memory barriers. Jack's
ring buffer has no memory barrier AFAIK.
Using it in one's project is just a matter of copying 4 files.
More about memory barriers and lock-free ring buffers:
http://www.audiomulch.com/~rossb/code/lockfree/
This problem is also mentioned on the PulseAudio website:
http://www.pulseaudio.org/wiki/ThreadingModel (search for "barrier")
Cheers,
--
Olivier Guilyardi / Samalyse