]> git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/blobdiff - helpers/music_file.py
Use machine for key handling
[perso/Immae/Projets/Python/MusicSampler.git] / helpers / music_file.py
index aeba1b9912fd9d2aa74da3fddd8683fc9e21fb12..a972bc5bc965b9a59634897587e807640d24725b 100644 (file)
@@ -48,7 +48,10 @@ class MusicFile:
         {
             'trigger': 'start_playing',
             'source': 'loaded',
-            'dest': 'loaded_playing'
+            'dest': 'loaded_playing',
+            # if a child has no transitions, then it is bubbled to the parent,
+            # and we don't want that. Not useful in that machine precisely.
+            'conditions': ['is_loaded']
         },
         {
             'trigger': 'pause',
@@ -235,13 +238,14 @@ class MusicFile:
 
     # Let other subscribe for an event when they are ready
     def subscribe_loaded(self, callback):
-        with file_lock:
-            if self.is_loaded(allow_substates=True):
-                callback(True)
-            elif self.is_failed():
-                callback(False)
-            else:
-                self.loaded_callbacks.append(callback)
+        # FIXME: should lock to be sure we have no race, but it makes the
+        # initialization screen not showing until everything is loaded
+        if self.is_loaded(allow_substates=True):
+            callback(True)
+        elif self.is_failed():
+            callback(False)
+        else:
+            self.loaded_callbacks.append(callback)
 
     def poll_loaded(self):
         for callback in self.loaded_callbacks: