diff --git a/control/audio.py b/control/audio.py index d11641a..5defe5e 100644 --- a/control/audio.py +++ b/control/audio.py @@ -14,7 +14,8 @@ logger = logging.getLogger(__name__) CHUNK_SIZE = 1024 INTERVAL_QUEUE = 0.1 -INTERVAL_STREAM = 0.0001 +INTERVAL_STREAM_FAST = 0.0001 +INTERVAL_STREAM_SLOW = 0.001 class PlayEntry: @@ -96,11 +97,12 @@ class AudioSystem: raise e def fill_streams(self): - self.scheduler.enter(INTERVAL_STREAM, 1, self.fill_streams) + self.scheduler.enter(INTERVAL_STREAM_FAST if len(self.playing) > 0 else INTERVAL_STREAM_SLOW, + 1, self.fill_streams) finished_streams = [] for stream_id, entry in self.playing.items(): # type: uuid.UUID, PlayEntry try: - if entry.stream.get_write_available() < CHUNK_SIZE: + if entry.stream.get_write_available() < (CHUNK_SIZE * 1.5): continue # not enough space in buffer, wait for next iteration try: data = entry.get_actual_data(CHUNK_SIZE) diff --git a/tickworker.py b/tickworker.py index 1659e10..a96d189 100644 --- a/tickworker.py +++ b/tickworker.py @@ -56,11 +56,11 @@ walle.setup() def walle_tick(): - scheduler.enter(INTERVAL_TICK, 1, walle_tick) + scheduler.enter(INTERVAL_TICK, 3, walle_tick) walle.tick() -scheduler.enter(INTERVAL_TICK, 1, walle_tick) +scheduler.enter(INTERVAL_TICK, 3, walle_tick) audio.queue_sound('walle.boot')