Skip to content

fix: recover audio engine after route changes - #140

Closed
jatinkrmalik wants to merge 1 commit into
mainfrom
fix/recover-audio-route-changes
Closed

fix: recover audio engine after route changes#140
jatinkrmalik wants to merge 1 commit into
mainfrom
fix/recover-audio-route-changes

Conversation

@jatinkrmalik

Copy link
Copy Markdown
Member

Summary

Fix recovery from macOS audio route/input format churn by making the recording start path report failure and rebuilding the AVAudioEngine when the current instance may hold stale hardware format state.

This is aimed at failures like:

AVAudioEngine exception while starting recording: Input HW format and tap format not matching

which can happen after Bluetooth headset connect/disconnect, default input changes, Zoom/Loom microphone activity, or other AVAudioEngine configuration changes.

Changes

  • Return a success/failure result from AudioRecording.startRecording(...).
  • Reset AppState and hotkey state immediately if AudioEngine fails to start.
  • Recreate the underlying AVAudioEngine after:
    • audio configuration changes
    • failed start attempts
    • force reset
  • Keep AVAudioEngineConfigurationChange scoped to the current engine and re-register the observer when the engine is recreated.
  • Add a regression test for failed audio start resetting recording and hotkey state.

Validation

  • swift test --filter AppStateRecordingGuardTests/testFailedAudioStartResetsRecordingAndHotkeyState
  • swift build
  • swift test — 169 tests passed

Test notes

Please try this build with Bluetooth headphones connect/disconnect and during/after Zoom or Loom microphone usage to verify VocaMac no longer needs an app restart after input route changes.

@jatinkrmalik

Copy link
Copy Markdown
Member Author

Closed as superseded.

Current main already has the safer lazy audio-engine lifecycle, start-failure reset, and fixed input-device support. This PR now conflicts and would regress that model.

@jatinkrmalik
jatinkrmalik deleted the fix/recover-audio-route-changes branch August 22, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant