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



On Thu, Jun 26, 2008 at 03:24:08PM -0400, Charlotte Curtis wrote:
> Hi all,
> 
> I'm working on a plugin that will build playlists and add songs the
> play queue based on music feature similarities.  I've created a
> feature extraction program in C++ using the Marsyas music analysis
> library, and I've started working on a python plugin to call this
> program from Rhythmbox.  I am, however, a little stuck.
> 
> Right now, I'm looping through the songs in the library as follows:
> library = self.shell.get_property('library-source')
> for row in library.props.query_model:
> 	self.scan_song(self.db, row[0])
> 
> The important bits of the "scan_song" function looks like this:
> pid, stdin, stdout, stderr = gobject.spawn_async(['/path/to/fextract',\
> 	songfile, vecfile], flags=gobject.SPAWN_DO_NOT_REAP_CHILD)
> gobject.child_watch_add(pid, self.process_complete)
> gobject.timeout_add(5, self.timeout, pid, songname)
>
[...]
> 
> Here's the problem: neither "self.process_complete" or "self.timeout"
> ever seem to run (they contain print statements that don't get
> printed, and even syntax errors that are never touched).  There's a
> few songs that, for whatever reason, cause my executable to hang up,
> so I wanted to use the timeout function to skip those songs, but what
> ends up happening is everything (rhythmbox included) just freezes up.

Both the child watch and the timeout will only work when the GLib main
loop is running.  Either your plugin has to return control
from whatever callback or handler is being called, then process the next
file in the child watch or timeout callback, or it can create a
thread to do this.

Query models cannot safely be used from multiple threads, so you'll
probably have to go with the former, and instead of
'for for in model:', I think you'll need to pass around a gtk.TreeIter
between callbacks to keep track of where you're up to.

um.. good luck?



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