doc code a bit
This commit is contained in:
parent
d13474b239
commit
08b18e02bd
2 changed files with 16 additions and 4 deletions
|
@ -16,7 +16,7 @@ logging.getLogger('mpd').setLevel(logging.WARNING)
|
|||
|
||||
class Monitor(ParentedLet):
|
||||
'''
|
||||
Manages timegenerators and audiogenerators.
|
||||
Manages timegenerators and audiogenerators for DB events
|
||||
|
||||
The mechanism is partially based on ticks, partially on scheduled actions.
|
||||
Ticks are emitted periodically; at every tick, :func:`on_tick
|
||||
|
|
|
@ -21,7 +21,10 @@ def get_mpd_client(conf):
|
|||
return client
|
||||
|
||||
|
||||
class MpcWatcher(ParentedLet):
|
||||
class MPDWatcher(ParentedLet):
|
||||
'''
|
||||
MPDWatcher notifies parent about any mpd event
|
||||
'''
|
||||
def __init__(self, queue, conf, client=None):
|
||||
ParentedLet.__init__(self, queue)
|
||||
self.log = logging.getLogger(self.__class__.__name__)
|
||||
|
@ -55,6 +58,13 @@ class MpcWatcher(ParentedLet):
|
|||
|
||||
|
||||
class Player:
|
||||
'''
|
||||
The player contains different mpd-related methods
|
||||
|
||||
check_playlist determines whether the playlist is long enough and run audiogenerator accordingly
|
||||
|
||||
enqueue receive audios that have been generated by Monitor and (if filters allow it) enqueue it to MPD playlist
|
||||
'''
|
||||
def __init__(self, conf):
|
||||
self.conf = conf
|
||||
self.log = logging.getLogger(self.__class__.__name__)
|
||||
|
@ -98,7 +108,7 @@ class Player:
|
|||
songs = mpd_client.playlist()
|
||||
current = mpd_client.currentsong()
|
||||
pos = int(current.get('pos', 0)) + 1
|
||||
if(len(songs) - pos >= self.min_playlist_length):
|
||||
if (len(songs) - pos) >= self.min_playlist_length:
|
||||
return
|
||||
self.log.info('need to add new songs')
|
||||
picker = gevent.Greenlet(audiogenerate,
|
||||
|
@ -196,7 +206,7 @@ class Controller(gevent.Greenlet):
|
|||
def _run(self):
|
||||
if self.monitor is not None:
|
||||
self.monitor.start()
|
||||
mw = MpcWatcher(self.q, self.conf, client=None)
|
||||
mw = MPDWatcher(self.q, self.conf, client=None)
|
||||
mw.parent_greenlet = self
|
||||
mw.start()
|
||||
t = Timer(int(self.conf['CHECK_SECS']) * 1000, self.q)
|
||||
|
@ -221,6 +231,8 @@ class Controller(gevent.Greenlet):
|
|||
elif kind == 'mpc':
|
||||
pass
|
||||
elif kind == 'uris_enqueue':
|
||||
# TODO: uris_enqueue messages should be delivered directly to Player.enqueue
|
||||
# probably we need a MPDEnqueuer that receives every uri we want to add
|
||||
try:
|
||||
self.player.enqueue(args[0])
|
||||
except AssertionError:
|
||||
|
|
Loading…
Reference in a new issue