aboutsummaryrefslogtreecommitdiff
path: root/helpers/music_file.py
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2016-07-25 23:50:51 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2016-07-26 02:05:53 +0200
commite55b29bb38b845c7b9e65a1fbca0198882658e14 (patch)
treea6430f289c909ab355b4f0b51eae9904c0a12c6a /helpers/music_file.py
parentb7ca3fc2b6b05d3aafd44dd0b8e40a4707213ff5 (diff)
downloadMusicSampler-e55b29bb38b845c7b9e65a1fbca0198882658e14.tar.gz
MusicSampler-e55b29bb38b845c7b9e65a1fbca0198882658e14.tar.zst
MusicSampler-e55b29bb38b845c7b9e65a1fbca0198882658e14.zip
Use machine for key handling
Diffstat (limited to 'helpers/music_file.py')
-rw-r--r--helpers/music_file.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/helpers/music_file.py b/helpers/music_file.py
index aeba1b9..a972bc5 100644
--- a/helpers/music_file.py
+++ b/helpers/music_file.py
@@ -48,7 +48,10 @@ class MusicFile:
48 { 48 {
49 'trigger': 'start_playing', 49 'trigger': 'start_playing',
50 'source': 'loaded', 50 'source': 'loaded',
51 'dest': 'loaded_playing' 51 'dest': 'loaded_playing',
52 # if a child has no transitions, then it is bubbled to the parent,
53 # and we don't want that. Not useful in that machine precisely.
54 'conditions': ['is_loaded']
52 }, 55 },
53 { 56 {
54 'trigger': 'pause', 57 'trigger': 'pause',
@@ -235,13 +238,14 @@ class MusicFile:
235 238
236 # Let other subscribe for an event when they are ready 239 # Let other subscribe for an event when they are ready
237 def subscribe_loaded(self, callback): 240 def subscribe_loaded(self, callback):
238 with file_lock: 241 # FIXME: should lock to be sure we have no race, but it makes the
239 if self.is_loaded(allow_substates=True): 242 # initialization screen not showing until everything is loaded
240 callback(True) 243 if self.is_loaded(allow_substates=True):
241 elif self.is_failed(): 244 callback(True)
242 callback(False) 245 elif self.is_failed():
243 else: 246 callback(False)
244 self.loaded_callbacks.append(callback) 247 else:
248 self.loaded_callbacks.append(callback)
245 249
246 def poll_loaded(self): 250 def poll_loaded(self):
247 for callback in self.loaded_callbacks: 251 for callback in self.loaded_callbacks: