[linux-audio-dev] mutex in process callback?

Lukas Degener AFBLukas at gmx.de
Thu Mar 27 09:12:01 UTC 2003


Hi LADs,
here is a problem that maybe very common with many rt audio apps, so 
hopefully there is a "standard" solution for it?

assume jack process callback reads audio data from a buffer, while 
another thread might alter the
contents of this buffer.  In my particular scenario, i will actualy use 
doublebuffering. So the only operation that needs to be "mutexed"
is the actual swapping of front and back buffers (well, pointers, of 
course, not the contents)

Now my problem is: How can i make sure that swapping does not accure 
during process (playback) callback?

I could use a mutex, but this might also block the playback thread. (if 
swapping is in process when the jack callback is invoked)

On the other hand, swapping pointers shouldn't take that long, so maybe 
this would not be a problem?

Or would it make sense to try and "foresee" such a situation and avoid 
it by delaying the swapping?

Any clever suggestions on this?

Regards,
Lukas






More information about the Linux-audio-dev mailing list