ocarina: Set album art in the main thread

I use a gobject signal to force setting album art in the main loop.
In theory, this should cut down on the number of crashes I see when
album art is fetched.
This commit is contained in:
Bryan Schumaker 2011-06-18 09:23:50 -04:00
parent 97902d0730
commit 6773d9837e
2 changed files with 21 additions and 5 deletions

View File

@ -26,7 +26,8 @@ import library
import callbacks
def run():
callbacks.on_get_art("images/ocarina.png", 0)
import body
body.footer.set_art("images/ocarina.png")
libsaria.startup()
print "Startup took:", uptime()
gtk.threads_enter()

View File

@ -1,5 +1,8 @@
# Bryan Schumaker (4 / 20 / 2011)
import gtk
import gobject
import libsaria
import queue
from ocarina import body
@ -26,11 +29,23 @@ def on_like(like):
footer.on_like(like)
callbacks.on_like = on_like
# A bit of a hack to force setting album art in the main thread
# Basically, I create a new signal and trigger it when new album
# art arrives
gobject.signal_new("get_art", gobject.GObject, gobject.SIGNAL_RUN_LAST,
gobject.TYPE_NONE,
(gobject.TYPE_INT, gobject.TYPE_STRING))
def on_get_art_helper(obj, id, path):
if id == libsaria.sources.get_cur_id():
footer.set_art(path)
on_get_art_obj = gobject.GObject()
on_get_art_obj.connect("get_art", on_get_art_helper)
def on_get_art(path, id):
cur_id = libsaria.sources.get_cur_id()
if [id] != cur_id:
path = "images/ocarina.png"
footer.set_art(path)
on_get_art_obj.emit("get_art", id, path)
callbacks.on_get_art = on_get_art
def on_load_playlist():