Skip to content

Fastest and only macOS Dictation app with on-device STT and custom trained AI enhancement model. Windows, iOS testflight! Android, Linux waitlist open! A local Wispr Flow alternative. Follow https://x.com/fluidvoiceapp for more

fix preview capture handoff

altic-dev9e137bdfb0fe
diff --git a/Sources/Fluid/Services/ASRService.swift b/Sources/Fluid/Services/ASRService.swift
index f7027fa8..065b0f0c 100644
--- a/Sources/Fluid/Services/ASRService.swift
+++ b/Sources/Fluid/Services/ASRService.swift
@@ -1654,14 +1654,26 @@ final class ASRService: ObservableObject {
DebugLogger.shared.warning("START() blocked - app is terminating", source: "ASRService")
return .failed
}
- if self.isMicrophonePreviewActive || self.audioCapturePipeline.isLevelMonitoringEnabled {
- await self.stopMicrophonePreview()
- }
self.audioCaptureStartGeneration &+= 1
let startGeneration = self.audioCaptureStartGeneration
self.isStarting = true
defer { self.finishAudioCaptureStart() }
+ // Reserve the start before preview teardown yields. Press-and-hold release
+ // must be able to see and cancel this handoff before capture hardware starts.
+ if self.isMicrophonePreviewActive || self.audioCapturePipeline.isLevelMonitoringEnabled {
+ await self.stopMicrophonePreview()
+ guard startGeneration == self.audioCaptureStartGeneration,
+ self.isTerminating == false
+ else {
+ DebugLogger.shared.debug(
+ "Audio capture start cancelled during microphone preview handoff",
+ source: "ASRService"
+ )
+ return .failed
+ }
+ }
+
// Reset media pause state for this session
self.didPauseMediaForThisSession = false
self.audioEngineStandbyTask?.cancel()