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()
|
self._stream.stop_stream()
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
|
self._stream.stop_stream()
|
||||||
self._stream.close()
|
self._stream.close()
|
||||||
|
|
||||||
def _read_callback(self, in_data, frame_count, time_info, status):
|
def _read_callback(self, in_data, frame_count, time_info, status):
|
||||||
|
|
|
@ -12,6 +12,7 @@ class AudioAlert(PluginBase):
|
||||||
self.timeout_min = timeout_min
|
self.timeout_min = timeout_min
|
||||||
self.clips = {}
|
self.clips = {}
|
||||||
self.streams = {}
|
self.streams = {}
|
||||||
|
self.tasks = set()
|
||||||
self.buffer_length = int(buffer_length)
|
self.buffer_length = int(buffer_length)
|
||||||
self.output_index = Stream.find_output_index(output)
|
self.output_index = Stream.find_output_index(output)
|
||||||
if sample_rate is None:
|
if sample_rate is None:
|
||||||
|
@ -51,10 +52,20 @@ class AudioAlert(PluginBase):
|
||||||
|
|
||||||
|
|
||||||
if immediate:
|
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:
|
else:
|
||||||
stream.play()
|
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):
|
async def _cleanup(self):
|
||||||
while True:
|
while True:
|
||||||
await asyncio.sleep(60)
|
await asyncio.sleep(60)
|
||||||
|
|
|
@ -111,6 +111,12 @@ class CuePlugin(PluginBase):
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
self.logger.error(f'Cannot schedule cue {name} at {at}: {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):
|
async def _cleanup(self):
|
||||||
while True:
|
while True:
|
||||||
await asyncio.sleep(60)
|
await asyncio.sleep(60)
|
||||||
|
|
Loading…
Add table
Reference in a new issue