diff --git a/platypush/backend/http/webapp/src/components/panels/Camera/Index.vue b/platypush/backend/http/webapp/src/components/panels/Camera/Index.vue
index 3c93b9b708..1aec37fde0 100644
--- a/platypush/backend/http/webapp/src/components/panels/Camera/Index.vue
+++ b/platypush/backend/http/webapp/src/components/panels/Camera/Index.vue
@@ -40,8 +40,7 @@
diff --git a/platypush/plugins/sound/_controllers/_recorder.py b/platypush/plugins/sound/_controllers/_recorder.py
index ef6adf26fa..4c13931134 100644
--- a/platypush/plugins/sound/_controllers/_recorder.py
+++ b/platypush/plugins/sound/_controllers/_recorder.py
@@ -1,5 +1,3 @@
-from dataclasses import dataclass
-
from typing import IO
from typing_extensions import override
@@ -16,7 +14,6 @@ from .._model import AudioState
from ._base import AudioThread
-@dataclass
class AudioRecorder(AudioThread):
"""
The ``AudioRecorder`` thread is responsible for recording audio from the
@@ -32,7 +29,7 @@ class AudioRecorder(AudioThread):
# _ = frames
# __ = time
def callback(indata, outdata, _, __, status):
- if self.state == AudioState.PAUSED:
+ if self.state != AudioState.RUNNING:
return
if status:
@@ -41,7 +38,7 @@ class AudioRecorder(AudioThread):
try:
audio_converter.write(indata.tobytes())
except AssertionError as e:
- self.logger.warning('Audio recorder callback error: %s', e)
+ self.logger.warning('Audio converter callback error: %s', e)
self.state = AudioState.STOPPED
return
@@ -63,8 +60,10 @@ class AudioRecorder(AudioThread):
@override
def notify_stop(self):
+ prev_state = self.state
super().notify_stop()
- get_bus().post(SoundRecordingStoppedEvent())
+ if prev_state != AudioState.STOPPED:
+ get_bus().post(SoundRecordingStoppedEvent())
# vim:sw=4:ts=4:et:
diff --git a/platypush/plugins/sound/_converter.py b/platypush/plugins/sound/_converter.py
index 3aa307f2b1..bdab2d03ea 100644
--- a/platypush/plugins/sound/_converter.py
+++ b/platypush/plugins/sound/_converter.py
@@ -1,5 +1,6 @@
import asyncio
from asyncio.subprocess import PIPE
+from logging import getLogger
from queue import Empty
from queue import Queue
@@ -74,6 +75,7 @@ class ConverterProcess(Thread):
self._closed = False
self._out_queue = Queue()
self.ffmpeg = None
+ self.logger = getLogger(__name__)
self._loop = None
self._should_stop = Event()
self._stop_lock = RLock()
@@ -157,21 +159,21 @@ class ConverterProcess(Thread):
def run(self):
super().run()
self._loop = get_or_create_event_loop()
- self._loop.run_until_complete(self._audio_proxy(timeout=1))
+ try:
+ self._loop.run_until_complete(self._audio_proxy(timeout=1))
+ except RuntimeError as e:
+ self.logger.warning(e)
+ finally:
+ self.stop()
def stop(self):
with self._stop_lock:
self._should_stop.set()
if self.ffmpeg:
- try:
- self.ffmpeg.kill()
- except ProcessLookupError:
- pass
+ self.ffmpeg.kill()
self.ffmpeg = None
-
- if self._loop:
- self._loop = None
+ self._loop = None
@property
def should_stop(self) -> bool: