aboutsummaryrefslogtreecommitdiff
path: root/helpers/music_file.py
diff options
context:
space:
mode:
Diffstat (limited to 'helpers/music_file.py')
-rw-r--r--helpers/music_file.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/helpers/music_file.py b/helpers/music_file.py
index b40de1a..e6a340d 100644
--- a/helpers/music_file.py
+++ b/helpers/music_file.py
@@ -40,8 +40,8 @@ class MusicFile(Machine):
40 self.audio_segment = None 40 self.audio_segment = None
41 self.gain = gain 41 self.gain = gain
42 self.music_lock = Lock("music__" + filename) 42 self.music_lock = Lock("music__" + filename)
43 self.wait_event = threading.Event()
43 44
44 self.flag_paused = False
45 threading.Thread(name = "MSMusicLoad", target = self.load).start() 45 threading.Thread(name = "MSMusicLoad", target = self.load).start()
46 46
47 def on_enter_loading(self): 47 def on_enter_loading(self):
@@ -109,6 +109,9 @@ class MusicFile(Machine):
109 if self.is_loaded_stopping(): 109 if self.is_loaded_stopping():
110 self.stopped() 110 self.stopped()
111 111
112 def on_enter_loaded_stopped(self):
113 self.wait_event.set()
114
112 def play_callback(self, out_data, frame_count, time_info, status_flags): 115 def play_callback(self, out_data, frame_count, time_info, status_flags):
113 with self.music_lock: 116 with self.music_lock:
114 audio_segment = self.current_audio_segment.get_sample_slice_data( 117 audio_segment = self.current_audio_segment.get_sample_slice_data(
@@ -147,8 +150,8 @@ class MusicFile(Machine):
147 return 20 * math.log10(max(volume, 0.0001) / 100) 150 return 20 * math.log10(max(volume, 0.0001) / 100)
148 151
149 def wait_end(self): 152 def wait_end(self):
150 # FIXME: todo 153 self.wait_event.clear()
151 pass 154 self.wait_event.wait()
152 155
153# Add some more functions to AudioSegments 156# Add some more functions to AudioSegments
154def get_sample_slice_data(self, start_sample=0, end_sample=float('inf')): 157def get_sample_slice_data(self, start_sample=0, end_sample=float('inf')):