Fix recording stuck with BT headphones + auto-retry on timeout#4
Merged
idanyekutiel merged 2 commits intomainfrom Mar 27, 2026
Merged
Fix recording stuck with BT headphones + auto-retry on timeout#4idanyekutiel merged 2 commits intomainfrom
idanyekutiel merged 2 commits intomainfrom
Conversation
When AirPods Max (or other BT devices) are connected, starting the audio engine triggers a Bluetooth profile renegotiation that fires an AVAudioEngineConfigurationChange notification, stopping the engine. Two bugs caused the recording to get stuck permanently: 1. handleConfigChange() guarded on isRecording, which is set async on the main queue AFTER engine.start(). Config changes during startup were silently ignored, leaving the engine stopped with no recovery. 2. The tap callback guarded on isRecording, dropping all initial buffers before the main-queue flag was set. onRecordingReady never fired, so the overlay stayed on the spinner indefinitely. Fix: replace the isRecording guard in handleConfigChange with an audioEngine != nil check, adding a lightweight restart path for startup config changes that re-asserts the target device and restarts the engine. Remove the redundant isRecording guard from the tap callback since the tap's lifetime already matches the recording lifecycle.
Whisper API calls occasionally time out on first attempt but succeed on retry. Add a single automatic retry with a status message instead of immediately failing and requiring manual retry from settings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
isRecordingrace condition.Test plan