libsaria: Began implementing better callback system
The event system was evil, hard to use, and hard to follow. This patch is the beginning of a new, more straightforward system.
This commit is contained in:
parent
6855fb6b2d
commit
b562fff0ed
|
@ -1,8 +1,10 @@
|
|||
# Bryan Schumake (8/7/2010)
|
||||
|
||||
import gst
|
||||
import datetime
|
||||
import threading
|
||||
import pipeline
|
||||
from libsaria import callbacks
|
||||
|
||||
timedelta = datetime.timedelta
|
||||
audio_lock = threading.Lock()
|
||||
|
@ -24,15 +26,15 @@ def get_state():
|
|||
def is_playing():
|
||||
return get_state() == gst.STATE_PLAYING
|
||||
|
||||
#def do_notify_playing():
|
||||
# if get_state() == gst.STATE_PLAYING:
|
||||
# callback.play()
|
||||
def do_notify_playing():
|
||||
if get_state() == gst.STATE_PLAYING:
|
||||
callbacks.play()
|
||||
|
||||
def play():
|
||||
lock_audio()
|
||||
pipeline.play()
|
||||
unlock_audio()
|
||||
#do_notify_playing()
|
||||
do_notify_playing()
|
||||
|
||||
#def do_notify_paused():
|
||||
# if get_state() == gst.STATE_PAUSED:
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
# Bryan Schumaker (4 / 30 / 2011)
|
||||
|
||||
def null_cb(*args):
|
||||
pass
|
||||
|
||||
on_play = null_cb
|
||||
def play():
|
||||
on_play()
|
|
@ -62,7 +62,7 @@ def next():
|
|||
return call("NEXT", pick_next)
|
||||
|
||||
def play():
|
||||
return call("PLAY", audio.play)
|
||||
audio.play()
|
||||
|
||||
def pause():
|
||||
return call("PAUSE", audio.pause)
|
||||
|
|
|
@ -15,7 +15,9 @@ class BG_Thread(Thread):
|
|||
self.func = func
|
||||
self.args = args
|
||||
def run(self):
|
||||
print "running func %s with args %s" % (self.func, self.args)
|
||||
self.func(*self.args)
|
||||
print "exiting func %s" % self.func
|
||||
|
||||
|
||||
def background(func, *args):
|
||||
|
|
|
@ -6,11 +6,11 @@ __start__ = now()
|
|||
|
||||
import gtk
|
||||
import gobject
|
||||
import libsaria
|
||||
|
||||
__vers__ = "Ocarina %s" % libsaria.__vstr__
|
||||
gobject.threads_init()
|
||||
|
||||
import libsaria
|
||||
__vers__ = "Ocarina %s" % libsaria.__vstr__
|
||||
|
||||
def uptime():
|
||||
return now() - __start__
|
||||
|
||||
|
@ -18,6 +18,8 @@ def quit(window, event):
|
|||
gtk.main_quit()
|
||||
libsaria.shutdown()
|
||||
print "Ocarina ran for:", uptime()
|
||||
import threading
|
||||
print "active threads?", threading.active_count()
|
||||
|
||||
import window
|
||||
import playlist
|
||||
|
|
|
@ -4,6 +4,7 @@ import libsaria
|
|||
import queue
|
||||
from ocarina import body
|
||||
from ocarina.body import footer
|
||||
from libsaria import callbacks
|
||||
import playlist
|
||||
import library
|
||||
|
||||
|
@ -11,7 +12,7 @@ invite = libsaria.event.invite
|
|||
|
||||
def on_play(*args):
|
||||
footer.on_play()
|
||||
invite("POSTPLAY", on_play)
|
||||
callbacks.on_play = on_play
|
||||
|
||||
def on_pause(*args):
|
||||
footer.on_pause()
|
||||
|
|
Loading…
Reference in New Issue