From 98c314a48511059f0e44800d7f86039dee045801 Mon Sep 17 00:00:00 2001 From: hrz <1710360675@qq.com> Date: Tue, 27 Oct 2026 10:22:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=94=A4=E9=86=92=E8=AF=8D=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E6=97=B6=E6=8A=8A=E9=BA=A6=E5=85=8B=E9=A3=8E?= =?UTF-8?q?=E9=87=87=E9=9B=86=E6=B5=81=E5=85=B3=E6=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 模型文件缺失导致启动中断时,麦克风的采集流会一直占着设备。这里让停止流程不管有没有启动成功都把插件停掉,采集流能正常关闭。 --- .../digital-human/wakeword_runtime/plugins/audio.py | 2 ++ main/digital-human/wakeword_runtime/runtime/app.py | 13 +++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/main/digital-human/wakeword_runtime/plugins/audio.py b/main/digital-human/wakeword_runtime/plugins/audio.py index 484cfc5e9..b0b8e2ea9 100644 --- a/main/digital-human/wakeword_runtime/plugins/audio.py +++ b/main/digital-human/wakeword_runtime/plugins/audio.py @@ -31,6 +31,8 @@ class AudioPlugin(Plugin): self.source.stop() def shutdown(self) -> None: + if self.source is not None: + self.source.stop() if self.app is not None: self.app.audio_source = None self.source = None diff --git a/main/digital-human/wakeword_runtime/runtime/app.py b/main/digital-human/wakeword_runtime/runtime/app.py index f40b2d5eb..5e92fca2c 100644 --- a/main/digital-human/wakeword_runtime/runtime/app.py +++ b/main/digital-human/wakeword_runtime/runtime/app.py @@ -51,13 +51,14 @@ class TestRuntimeApplication: logger.info("test runtime application started") def stop(self) -> None: - if not self._is_running: - return - - self.event_bridge.publish_service_stopping() - self.plugins.stop_all() + was_running = self._is_running 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: self.stop()