From 56fdc348f8120c058cd389cd9966da25f9a1cf4e Mon Sep 17 00:00:00 2001 From: himeditator Date: Sat, 30 Aug 2025 20:57:26 +0800 Subject: [PATCH] =?UTF-8?q?fix(engine):=20=E8=A7=A3=E5=86=B3=E5=9C=A8?= =?UTF-8?q?=E5=BC=95=E6=93=8E=E7=8A=B6=E6=80=81=E4=B8=8D=E4=B8=BA=20runnin?= =?UTF-8?q?g=20=E6=97=B6=E5=BC=BA=E5=88=B6=E5=85=B3=E9=97=AD=E5=AD=97?= =?UTF-8?q?=E5=B9=95=E5=BC=95=E6=93=8E=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 合并了 CaptionEngine 类中的 kill 和 forceKill 方法,删除了状态警告中的提前 return - 更新了 README 文件中的macOS兼容性说明,添加了配置链接 --- README.md | 2 +- README_en.md | 2 +- README_ja.md | 2 +- electron-builder.yml | 5 ++++- src/main/ControlWindow.ts | 2 +- src/main/utils/CaptionEngine.ts | 30 +++++------------------------- 6 files changed, 13 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index ad32ef9..a9fd4ae 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ | 操作系统版本 | 处理器架构 | 获取系统音频输入 | 获取系统音频输出 | | ------------------ | ---------- | ---------------- | ---------------- | | Windows 11 24H2 | x64 | ✅ | ✅ | -| macOS Sequoia 15.5 | arm64 | ✅需要额外配置 | ✅ | +| macOS Sequoia 15.5 | arm64 | ✅ [需要额外配置](./docs/user-manual/zh.md#macos-获取系统音频输出) | ✅ | | Ubuntu 24.04.2 | x64 | ✅ | ✅ | | Kali Linux 2022.3 | x64 | ✅ | ✅ | | Kylin Server V10 SP3 | x64 | ✅ | ✅ | diff --git a/README_en.md b/README_en.md index c819057..0353bc8 100644 --- a/README_en.md +++ b/README_en.md @@ -49,7 +49,7 @@ The software has been adapted for Windows, macOS, and Linux platforms. The teste | OS Version | Architecture | System Audio Input | System Audio Output | | ------------------ | ------------ | ------------------ | ------------------- | | Windows 11 24H2 | x64 | ✅ | ✅ | -| macOS Sequoia 15.5 | arm64 | ✅ Additional config required | ✅ | +| macOS Sequoia 15.5 | arm64 | ✅ [Additional config required](./docs/user-manual/en.md#capturing-system-audio-output-on-macos) | ✅ | | Ubuntu 24.04.2 | x64 | ✅ | ✅ | | Kali Linux 2022.3 | x64 | ✅ | ✅ | | Kylin Server V10 SP3 | x64 | ✅ | ✅ | diff --git a/README_ja.md b/README_ja.md index 5c838e0..2c0de12 100644 --- a/README_ja.md +++ b/README_ja.md @@ -49,7 +49,7 @@ | OS バージョン | アーキテクチャ | システムオーディオ入力 | システムオーディオ出力 | | ------------------ | ------------ | ------------------ | ------------------- | | Windows 11 24H2 | x64 | ✅ | ✅ | -| macOS Sequoia 15.5 | arm64 | ✅ 追加設定が必要 | ✅ | +| macOS Sequoia 15.5 | arm64 | ✅ [追加設定が必要](./docs/user-manual/ja.md#macos-でのシステムオーディオ出力の取得方法) | ✅ | | Ubuntu 24.04.2 | x64 | ✅ | ✅ | | Kali Linux 2022.3 | x64 | ✅ | ✅ | | Kylin Server V10 SP3 | x64 | ✅ | ✅ | diff --git a/electron-builder.yml b/electron-builder.yml index 4cfad9d..12bd784 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -1,5 +1,5 @@ appId: com.himeditator.autocaption -productName: auto-caption +productName: Auto Caption directories: buildResources: build files: @@ -13,6 +13,9 @@ files: - '!engine/*' - '!docs/*' - '!assets/*' + - '!.repomap/*' + - '!.virtualme/*' + extraResources: # For Windows - from: ./engine/dist/main.exe diff --git a/src/main/ControlWindow.ts b/src/main/ControlWindow.ts index f40ff64..2918785 100644 --- a/src/main/ControlWindow.ts +++ b/src/main/ControlWindow.ts @@ -160,7 +160,7 @@ class ControlWindow { }) ipcMain.on('control.engine.forceKill', () => { - captionEngine.forceKill() + captionEngine.kill() }) ipcMain.on('control.captionLog.clear', () => { diff --git a/src/main/utils/CaptionEngine.ts b/src/main/utils/CaptionEngine.ts index aaf5c42..9733789 100644 --- a/src/main/utils/CaptionEngine.ts +++ b/src/main/utils/CaptionEngine.ts @@ -97,7 +97,6 @@ export class CaptionEngine { public connect() { if(this.client) { Log.warn('Client already exists, ignoring...') } - // 清除启动超时计时器 if (this.startTimeoutID) { clearTimeout(this.startTimeoutID) this.startTimeoutID = undefined @@ -137,14 +136,13 @@ export class CaptionEngine { this.status = 'starting' Log.info('Caption Engine Starting, PID:', this.process.pid) - // 设置启动超时机制 const timeoutMs = allConfig.controls.startTimeoutSeconds * 1000 this.startTimeoutID = setTimeout(() => { if (this.status === 'starting') { Log.warn(`Engine start timeout after ${allConfig.controls.startTimeoutSeconds} seconds, forcing kill...`) this.status = 'starting-timeout' controlWindow.sendErrorMessage(i18n('engine.start.timeout')) - this.forceKill() + this.kill() } }, timeoutMs) @@ -182,7 +180,6 @@ export class CaptionEngine { } this.status = 'stopped' clearInterval(this.timerID) - // 清理启动超时计时器 if (this.startTimeoutID) { clearTimeout(this.startTimeoutID) this.startTimeoutID = undefined @@ -194,7 +191,6 @@ export class CaptionEngine { public stop() { if(this.status !== 'running'){ Log.warn('Trying to stop engine which is not running, current status:', this.status) - return } this.sendCommand('stop') if(this.client){ @@ -210,27 +206,12 @@ export class CaptionEngine { } public kill(){ + if(!this.process || !this.process.pid) return if(this.status !== 'running'){ Log.warn('Trying to kill engine which is not running, current status:', this.status) - return } - this.sendCommand('stop') - if(this.client){ - this.client.destroy() - this.client = undefined - } - this.status = 'stopping' - this.timerID = setTimeout(() => { - if(this.status !== 'stopping') return - Log.warn('Engine process still not stopped, trying to kill...') - this.forceKill() - }, 4000); - } + Log.warn('Killing engine process, PID:', this.process.pid) - public forceKill(){ - if(!this.process || !this.process.pid) return - Log.warn('Force killing engine process, PID:', this.process.pid) - // 清理启动超时计时器 if (this.startTimeoutID) { clearTimeout(this.startTimeoutID) this.startTimeoutID = undefined @@ -246,13 +227,12 @@ export class CaptionEngine { } exec(cmd, (error) => { if (error) { - Log.error('Failed to force kill process:', error) + Log.error('Failed to kill process:', error) } else { - Log.info('Process force killed successfully') + Log.info('Process killed successfully') } }) } - this.status = 'stopping' } }