[linux-audio-dev] Lock-free gtk/jack interaction

Olivier Guilyardi ml at xung.org
Sun Mar 13 21:12:01 UTC 2005


This may be a general IPC question, but I feel lost so I thought you may help me
as you did in the past for some other issue.

In Jackbeat (written in C), I have the gui running in one thread (the gtk main
loop) and jack in its thread. Currently, when tracks get updated, the main loop
sends a message to the jack thread, and then waits for an acknowledgement. I
currently use syscalls (message queues) for these messages, but that's not my
point (I'll turn that later into syscall-free fifos).

Waiting for an ack from the jack thread has a consequence : it locks the gui for
a brief moment, which seems to drive my spin buttons mad : when clicked they
will sometimes step the value by 1, sometimes 2, etc...

Additionally, I think the gui should never lock, for confort. So I though about
a "shadow" data structure. It would act as a intermediary area between my two

The jack thread runs into what I call a "sequence". When processing sound it
relies on a structure called sequence_t. I'm about to add a new member to this
structure, called shadow, which would actually be of the sequence_t type itself.

This nested shadow structure would never be accessed by the jack thread. The
public sequence functions could safely update this shadow, so that the gui can
read from it anytime without any latency.

Message queues would still be used to let the jack thread update itself the
"real" sequence. This is where would reside some latency : waiting for the jack
thread to get in sync. But the gui would never lock.

I'm not sure this is a very clear description, but do you have any advice about 
this kind of issue ? Is my idea a good one ?



More information about the Linux-audio-dev mailing list