libsaria: Added queue_changed callback

This callback is used when ids are either added or removed from the
queue.
This commit is contained in:
Bryan Schumaker 2011-05-07 18:52:24 -04:00
parent 93f2f6b918
commit 5d336d4815
2 changed files with 8 additions and 0 deletions

View File

@ -36,3 +36,7 @@ def load_playlist():
on_new_source = null_cb
def new_source():
on_new_source()
on_queue_changed = null_cb
def queue_changed():
on_queue_changed()

View File

@ -1,6 +1,7 @@
# Bryan Schumaker (5 / 7 / 2011)
import threading
from libsaria import callbacks
queue_lock = threading.Lock()
lock_queue = queue_lock.acquire
unlock_queue = queue_lock.release
@ -12,6 +13,7 @@ def add_ids(id_list):
lock_queue()
queue_list.extend(id_list)
unlock_queue()
callbacks.queue_changed()
def rm_ids(id_list):
lock_queue()
@ -19,6 +21,7 @@ def rm_ids(id_list):
if id in queue_list:
queue_list.remove(id)
unlock_queue()
callbacks.queue_changed()
def pop():
lock_queue()
@ -26,6 +29,7 @@ def pop():
if len(queue_list) > 0:
id = queue_list.pop(0)
unlock_queue()
callbacks.queue_changed()
return id
def reset():