Re: [LAD] alsa sequencer and sysex editing

From: Fons Adriaensen <fons@email-addr-hidden>
Date: Mon Jun 02 2008 - 22:55:30 EEST

On Mon, Jun 02, 2008 at 07:32:16PM +0200, rdxesy@email-addr-hidden wrote:

> thank you for that info. The problem with that thread
> approach is that i cannot call gtk_* stuff from it (which
> is needed, as most answers are values that will be used to
> set sliders, comboboxes and spinbuttons).
> I could use g_idle_add or g_timeout_add for that thread but
> that adds another async layer, and questions like "what
> would be the timeout"?
> Is there a way to call a function in the main loop from a
> thread "now and once" (i mean, without using
> g_idle/timeout_add, something thats just like a call to a
> "normal" function but calls it in the main loop)?

"In the main loop" and "from a(nother) thread" are contradictory
- these *are* different threads and nothing can change that.

I don't know the details of GTK, but this is a classic problem
with high-level GUI toolsets: they don't allow you to wait
for X events (which trigger the loop, behind the scenes) and
anyhting else at the same time in the same thread. They don't
even separate _waiting_ for an X event, and _handling_ it into
two separate user calls (which would allow the user to add the
missing multiple wait functionality). This is one of the
reasons why I wrote my own GUI toolkit.

Now if the messages you receive are for display only, there
is no need to be faster than the display update rate, or a
human reader. If the GTK loop times out every say 50ms,
checks the midi input, and if there is any, displays it,
then things should just work. There's no problem if you
are too late as the midi data is buffered. There's no
problem if you're to early, you will get the message next
time.

Other solutions are:

- Use a separate thread to read the midi data, then send
it as an X event (you can make 'user' event types) to your
main window. Doing this will trigger the GTK loop.

- Use a separate thread, and a mutex used by this thread
and the GTK loop to avoid concurrent access to data and
mixed-up X-calls.

Ciao,

-- 
FA
Laboratorio di Acustica ed Elettroacustica
Parma, Italia
Lascia la spina, cogli la rosa.
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev
Received on Tue Jun 3 00:15:09 2008

This archive was generated by hypermail 2.1.8 : Tue Jun 03 2008 - 00:15:09 EEST