From 23e66530c05a370796259a33d3fd9e3f70278933 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Wed, 22 Oct 2025 15:28:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=89=AB=E6=8F=8F=E8=B6=85?= =?UTF-8?q?=E6=97=B6=E6=A3=80=E6=9F=A5=E5=92=8C=E5=BE=AE=E8=BD=AF=E5=90=88?= =?UTF-8?q?=E6=88=90=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/modules/pairing/controllers/pairing_controller.dart | 8 +++++++- .../Sources/azure_speech/AzureTtsHelper.swift | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/modules/pairing/controllers/pairing_controller.dart b/lib/modules/pairing/controllers/pairing_controller.dart index 3347794bd..7304fadc8 100644 --- a/lib/modules/pairing/controllers/pairing_controller.dart +++ b/lib/modules/pairing/controllers/pairing_controller.dart @@ -732,7 +732,13 @@ class PairingController extends GetxController with WidgetsBindingObserver { try { // 设置超时定时器 _bleTimeoutTimer?.cancel(); - _bleTimeoutTimer = Timer(const Duration(seconds: 20), () { + _bleTimeoutTimer = Timer(const Duration(seconds: 10), () async { + final currentBleState = await _bleManager.getConnectionState(); + if (currentBleState == 2) { + _bleTimeoutTimer?.cancel(); + _transition(PairingState.completed); + return; + } if (_currentState.value == PairingState.waitingBle) { _setError(ErrorType.bleTimeout, 'bleConnectionTimeoutRetry'.tr); //BLE连接超时,请重启耳机后再试 diff --git a/local_plugins/azure_speech/ios/azure_speech/Sources/azure_speech/AzureTtsHelper.swift b/local_plugins/azure_speech/ios/azure_speech/Sources/azure_speech/AzureTtsHelper.swift index 9afe14776..9a0b5f639 100644 --- a/local_plugins/azure_speech/ios/azure_speech/Sources/azure_speech/AzureTtsHelper.swift +++ b/local_plugins/azure_speech/ios/azure_speech/Sources/azure_speech/AzureTtsHelper.swift @@ -266,8 +266,11 @@ public class AzureTtsHelper: NSObject, ITtsService { lastSpokenText = "" // 重置计数器 pendingTextCount = 0 + + // 清空所有待处理任务并重置处理状态 taskLock.lock() pendingTasks.removeAll() + isProcessing = false // 重置处理状态 taskLock.unlock() do { @@ -474,6 +477,9 @@ public class AzureTtsHelper: NSObject, ITtsService { */ private func recreateSynthesizer() { do { + // 强制释放旧的合成器 + synthesizer = nil + // 创建音频配置 let audioConfig: SPXAudioConfiguration? if !useInternalPlayer || customAudioOutputStream != nil {