Optimize recorder startup by backgrounding media controls
This commit is contained in:
parent
53d1507a53
commit
2a4f48ac0d
@ -76,15 +76,7 @@ class Recorder: NSObject, ObservableObject, AVAudioRecorderDelegate {
|
|||||||
UserDefaults.standard.set(String(currentDeviceID), forKey: "lastUsedMicrophoneDeviceID")
|
UserDefaults.standard.set(String(currentDeviceID), forKey: "lastUsedMicrophoneDeviceID")
|
||||||
|
|
||||||
hasDetectedAudioInCurrentSession = false
|
hasDetectedAudioInCurrentSession = false
|
||||||
|
|
||||||
// Coordinate media control and system audio sequentially for better reliability
|
|
||||||
await playbackController.pauseMedia()
|
|
||||||
|
|
||||||
// Small delay to allow media command to process before muting system audio
|
|
||||||
try? await Task.sleep(nanoseconds: 100_000_000) // 100ms
|
|
||||||
|
|
||||||
_ = await mediaController.muteSystemAudio()
|
|
||||||
|
|
||||||
let deviceID = deviceManager.getCurrentDevice()
|
let deviceID = deviceManager.getCurrentDevice()
|
||||||
if deviceID != 0 {
|
if deviceID != 0 {
|
||||||
do {
|
do {
|
||||||
@ -114,6 +106,12 @@ class Recorder: NSObject, ObservableObject, AVAudioRecorderDelegate {
|
|||||||
throw RecorderError.couldNotStartRecording
|
throw RecorderError.couldNotStartRecording
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Task { [weak self] in
|
||||||
|
guard let self = self else { return }
|
||||||
|
await self.playbackController.pauseMedia()
|
||||||
|
_ = await self.mediaController.muteSystemAudio()
|
||||||
|
}
|
||||||
|
|
||||||
audioLevelCheckTask?.cancel()
|
audioLevelCheckTask?.cancel()
|
||||||
audioMeterUpdateTask?.cancel()
|
audioMeterUpdateTask?.cancel()
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ class DictionaryContextService {
|
|||||||
|
|
||||||
private init() {}
|
private init() {}
|
||||||
|
|
||||||
private let predefinedWords = "VoiceInk, chatGPT, GPT-4o, GPT-5-mini, Kimi-K2, GLM V4.5, Claude, Claude 4 sonnet, Claude opus, ultrathink, Vibe-coding, groq, cerebras, gpt-oss-120B, Wispr flow, deepseek, gemini-2.5, Veo 3, elevenlabs, Kyutai"
|
private let predefinedWords = "VoiceInk, chatGPT, GPT-4o, GPT-5-mini, Kimi-K2, GLM V4.5, Claude, Claude 4 sonnet, Claude opus, ultrathink, Vibe-coding, groq, cerebras, gpt-oss-120B, deepseek, gemini-2.5, Veo 3, elevenlabs, Kyutai"
|
||||||
|
|
||||||
func getDictionaryContext() -> String {
|
func getDictionaryContext() -> String {
|
||||||
var allWords: [String] = []
|
var allWords: [String] = []
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user