Fixes re: zognia's testing #2
3 changed files with 19 additions and 1 deletions
|
@ -100,6 +100,7 @@ class Stream:
|
|||
self._stream.stop_stream()
|
||||
|
||||
def close(self):
|
||||
self._stream.stop_stream()
|
||||
self._stream.close()
|
||||
|
||||
def _read_callback(self, in_data, frame_count, time_info, status):
|
||||
|
|
|
@ -12,6 +12,7 @@ class AudioAlert(PluginBase):
|
|||
self.timeout_min = timeout_min
|
||||
self.clips = {}
|
||||
self.streams = {}
|
||||
self.tasks = set()
|
||||
self.buffer_length = int(buffer_length)
|
||||
self.output_index = Stream.find_output_index(output)
|
||||
if sample_rate is None:
|
||||
|
@ -51,10 +52,20 @@ class AudioAlert(PluginBase):
|
|||
|
||||
|
||||
if immediate:
|
||||
asyncio.create_task(stream.aplay())
|
||||
task = asyncio.create_task(stream.aplay())
|
||||
task.add_done_callback(self.tasks.remove)
|
||||
self.tasks.add(task)
|
||||
else:
|
||||
stream.play()
|
||||
|
||||
def close(self):
|
||||
self._cleanup_task.cancel()
|
||||
for task in self.tasks:
|
||||
task.cancel()
|
||||
for stream_dq in self.streams.values():
|
||||
for stream in stream_dq:
|
||||
stream.close()
|
||||
|
||||
async def _cleanup(self):
|
||||
while True:
|
||||
await asyncio.sleep(60)
|
||||
|
|
|
@ -111,6 +111,12 @@ class CuePlugin(PluginBase):
|
|||
except ValueError as e:
|
||||
self.logger.error(f'Cannot schedule cue {name} at {at}: {e}')
|
||||
|
||||
def close(self):
|
||||
self._cleanup_task.cancel()
|
||||
for task in self.tasks.values():
|
||||
self.scheduler.cancel(task)
|
||||
self.scheduler._task.cancel()
|
||||
|
||||
async def _cleanup(self):
|
||||
while True:
|
||||
await asyncio.sleep(60)
|
||||
|
|
Loading…
Add table
Reference in a new issue