Re: [Rhythmbox-devel] Calling an executable for each song in rb library

On Thu, Jun 26, 2008 at 3:52 PM, giopas <linux giopas eu> wrote:
> Hi Charlotte,
> at first sight, your plugin idea seams similar to lastfm-queue plugin
> made by Alexandre Rosenfeld.
> Have a look here if you are interested in it:
> enjoy, ;)
> giopas

Hi giopas,

You're right, they are pretty similar, the main difference being that
mine uses information from the song itself instead of or
metadata.  I have actually looked at bits of Alexandre's code (as well
as a few other plugins) to get an idea of how they should work, but I
haven't found one that calls an external executable asynchronously.

I think I've found the cause of my problem, as well as a workaround
that seems to behave.  The gobject callback functions seem to need a
gtk.main or gobject.MainLoop, otherwise they're ignored.  My
workaround is to create a main loop in my plugin activation function
(self.mainloop = gobject.MainLoop()), and then change the scan_song
function to look like this:

pid, stdin, stdout, stderr = gobject.spawn_async(['/path/to/fextract',\
       songfile, vecfile], flags=gobject.SPAWN_DO_NOT_REAP_CHILD)		
procdone = gobject.child_watch_add(pid, self.process_complete)
proctimeout = gobject.timeout_add(5000, self.timeout, pid, songname)

and the self.process_complete function contains self.mainloop.quit().
Obviously there are problems with this code (such as hard coding a
"this is taking too long, it must be broken" time, but otherwise it
seems to work - only one "fextract" process is spawned at a time, and
Rhythmbox is not frozen while this is happening.

Are there any significant problems with this method?  It feels like a
dirty hack, but I can't figure out another way to do it.

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