mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-23 03:19:41 +00:00
唤醒词启动失败时把麦克风采集流关掉
模型文件缺失导致启动中断时,麦克风的采集流会一直占着设备。这里让停止流程不管有没有启动成功都把插件停掉,采集流能正常关闭。
This commit is contained in:
parent
a377d89dcd
commit
98c314a485
2 changed files with 9 additions and 6 deletions
|
|
@ -31,6 +31,8 @@ class AudioPlugin(Plugin):
|
||||||
self.source.stop()
|
self.source.stop()
|
||||||
|
|
||||||
def shutdown(self) -> None:
|
def shutdown(self) -> None:
|
||||||
|
if self.source is not None:
|
||||||
|
self.source.stop()
|
||||||
if self.app is not None:
|
if self.app is not None:
|
||||||
self.app.audio_source = None
|
self.app.audio_source = None
|
||||||
self.source = None
|
self.source = None
|
||||||
|
|
|
||||||
|
|
@ -51,13 +51,14 @@ class TestRuntimeApplication:
|
||||||
logger.info("test runtime application started")
|
logger.info("test runtime application started")
|
||||||
|
|
||||||
def stop(self) -> None:
|
def stop(self) -> None:
|
||||||
if not self._is_running:
|
was_running = self._is_running
|
||||||
return
|
|
||||||
|
|
||||||
self.event_bridge.publish_service_stopping()
|
|
||||||
self.plugins.stop_all()
|
|
||||||
self._is_running = False
|
self._is_running = False
|
||||||
logger.info("test runtime application stopped")
|
if was_running:
|
||||||
|
self.event_bridge.publish_service_stopping()
|
||||||
|
logger.info("test runtime application stopped")
|
||||||
|
# 启动中途失败时 _is_running 还是 False,但插件可能已经开过采集流,
|
||||||
|
# 这里不提前返回,保证采集流一定被关掉
|
||||||
|
self.plugins.stop_all()
|
||||||
|
|
||||||
def shutdown(self) -> None:
|
def shutdown(self) -> None:
|
||||||
self.stop()
|
self.stop()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue