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:
parent
97902d0730
commit
6773d9837e
|
@ -26,7 +26,8 @@ import library
|
||||||
import callbacks
|
import callbacks
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
callbacks.on_get_art("images/ocarina.png", 0)
|
import body
|
||||||
|
body.footer.set_art("images/ocarina.png")
|
||||||
libsaria.startup()
|
libsaria.startup()
|
||||||
print "Startup took:", uptime()
|
print "Startup took:", uptime()
|
||||||
gtk.threads_enter()
|
gtk.threads_enter()
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
# Bryan Schumaker (4 / 20 / 2011)
|
# Bryan Schumaker (4 / 20 / 2011)
|
||||||
|
|
||||||
|
import gtk
|
||||||
|
import gobject
|
||||||
|
|
||||||
import libsaria
|
import libsaria
|
||||||
import queue
|
import queue
|
||||||
from ocarina import body
|
from ocarina import body
|
||||||
|
@ -26,11 +29,23 @@ def on_like(like):
|
||||||
footer.on_like(like)
|
footer.on_like(like)
|
||||||
callbacks.on_like = on_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):
|
def on_get_art(path, id):
|
||||||
cur_id = libsaria.sources.get_cur_id()
|
on_get_art_obj.emit("get_art", id, path)
|
||||||
if [id] != cur_id:
|
|
||||||
path = "images/ocarina.png"
|
|
||||||
footer.set_art(path)
|
|
||||||
callbacks.on_get_art = on_get_art
|
callbacks.on_get_art = on_get_art
|
||||||
|
|
||||||
def on_load_playlist():
|
def on_load_playlist():
|
||||||
|
|
Loading…
Reference in New Issue