Re: [Rhythmbox-devel] plugins and threads
- From: Christian Buennig <masala web de>
- To: rhythmbox-devel gnome org
- Subject: Re: [Rhythmbox-devel] plugins and threads
- Date: Wed, 03 Oct 2007 00:50:14 +0200
Michael Gratton wrote:
> On Tue, 2007-10-02 at 10:59 +0200, Christian Buennig wrote:
>> this would be a better solution, but I have to test if it really works
>> for me. The point is that the actual socket handling is done in a C
>> library which I use from the Rhythmbox plugin via a Python - C - Wrapper
>> for that library.
> Are you writing the C lib yourself? If so, then you could just design it
> to expose the socket via Python, you could then pass it to io_add_watch.
> If not, I know there are python bindings for the bluetooth stack, maybe
> you could use them instead and again get access to the socket.
Yep, I'm writing the lib myself. But I do not want to hand to out the
socket to something outside the library .. one task of the lib is to do
the ugly, low level socket jobs. Also I want to keep the socket code in
C since the lib also gets used by C applications (e.g plugins for other
music players .. b.t.w. the library implements bluetooth remote control
However, see below ..
>> So I wonder if I can do an io_add_watch within the C library (using
>> g_io_add_watch from glib) .. or more abstract if I can add watches to
>> the _same_ main loop from within python using gobject and within C using
>> glib. ... btw: can one process have more than one main loop?
> Maaaybe. It sounds like a lot of work. I doubt you can have two main
> loops, but then again I don't really know too much about this stuff, so
> by means go ahead and try.
>> I'll just test it and will report the results..
I still not fully understand the main loop concept (e.g. is there one
main loop per thread or per process?). Anyway, adding an event source to
the main loop via g_io_add_watch() works in my case, i.e.:
- the main loop has been started somewhere in Rhythmbox
- Rhythmbox calls a method of my Python plugin
- my Python plugin calls a function of a C library
- the C function adds an event source to the main loop (using glib and
without starting a main loop itself)
- the related callback function (in the C library) gets called as
So it looks like this finally solves my issue.
Thanks for the help!
] [Thread Prev