[gnome-music] albumart: make a queue of albums being resolved



commit de554a4bca89d41c287151a424b7c0a7f4b8a56f
Author: Vadim Rutkovsky <vrutkovs redhat com>
Date:   Wed Apr 30 14:23:50 2014 +0200

    albumart: make a queue of albums being resolved

 gnomemusic/albumArtCache.py |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/gnomemusic/albumArtCache.py b/gnomemusic/albumArtCache.py
index 5e5cf4e..bc0266c 100644
--- a/gnomemusic/albumArtCache.py
+++ b/gnomemusic/albumArtCache.py
@@ -34,6 +34,7 @@ import cairo
 from math import pi
 import os
 from _thread import start_new_thread
+from time import sleep
 from gnomemusic import log
 from gnomemusic.grilo import grilo
 import logging
@@ -78,6 +79,7 @@ def _make_icon_frame(pixbuf, path=None):
 class AlbumArtCache:
     instance = None
     blacklist = {}
+    queue = []
 
     @classmethod
     def get_default(self):
@@ -149,6 +151,10 @@ class AlbumArtCache:
     def lookup_worker(self, item, width, height, callback, itr, artist, album):
         try:
             path = MediaArt.get_path(artist, album, "album", None)[0]
+            while path in self.queue:
+                sleep(0.5)
+            self.queue.append(path)
+
             if artist in self.blacklist and album in self.blacklist[artist]:
                 self.finish(item, None, None, callback, itr)
                 return
@@ -167,6 +173,7 @@ class AlbumArtCache:
         try:
             if path:
                 item.set_thumbnail(GLib.filename_to_uri(path, None))
+                self.queue.remove(path)
             GLib.idle_add(callback, pixbuf, path, itr)
         except Exception as e:
             logger.warn("Error: %s" % e)


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