Re: Threads






On Sat, Oct 19, 2013 at 7:46 AM, Craig Bakalian <craigbakalian verizon net> wrote:
On 10/19/2013 07:11 AM, Paul Davis wrote:
There are dozens if not hundreds of "examples" of this - any JACK client with a GUI.

But to get an idea of the basic idea, take a look in the JACK example clients and/or tools. jack_capture would be a good place to start, since it faces the problem of handing over incoming (audio) data to another thread.

And no, you are not writing "the data" to a pipe from the JACK callback. The key ideas are (a) to move the data to another thread you need to use a lock-free data structure (b) if you need to wake the other thread (i.e. because it doesn't simply wake up periodically and use whatever new data you've delivered), you need to use the *most* RT-safe method you can. There are no absolutely RT-safe methods. A semaphore (on Linux anyway) is the best, writing a byte to a pipe is the 2nd best.

You cannot make calls from the JACK callback that may block - you cannot write to disk, read from disk, take locks, etc, etc.

This really should not be going to the gtk-list anymore. It has roughly nothing to do with gtk and more or less everything to do with JACK.


Hi Paul,

If it has nothing to do with JACK, then why on earth was it working before the latest release of gtk in ubuntu 13.10?  Why could I write data out from the JACK callback with no issues before??  It has nothing to do with the JACK callback and everything to do with the overly secure removal of

gdk_threads_enter();
gdk_thread_leave();

You are not *allowed* to call these functions from a JACK callback, whether they exist or not.
 

My application was working perfectly until the removal of these functions.  Furthermore, once I remove the insert to the gtktextbuffer from the callback, all is well.  And, the error that pops up is that the gtktextbuffer layout can't get a line number. This has nothing to do with JACK and everything to do with threads in gtk.

You are not allowed to interact with the GUI toolkit from the callback.

If you use JACK you are doing realtime programming. I suggest a careful read of this to get you started: http://www.rossbencina.com/code/real-time-audio-programming-101-time-waits-for-nothing

The fact that you are handling MIDI and not audio doesn't change the applicability of Ross' advice.
 

What on earth should I expect anything more than "get this off this list" from I guy whose first response on a HELP list is "Your design is wrong".  It is obvious to me you don't know what my JACK callback is doing.

Maybe you don't understand that I wrote JACK. I run the JACK mailing list. That is where your questions belong. I'm just trying to be nice to the poor souls who wonder what this all has to do with GTK. And btw, moving to Qt won't address any of your fundamental issues.

--p




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]