fix: retire AVAudioEngine after configuration changes - #216
Merged
Conversation
Bluetooth HFP settle posts AVAudioEngineConfigurationChange, and releaseEngine() in that handler deallocates AVAudioIOUnit while Core Audio is still in IOUnitPropertyListener (EXC_BAD_ACCESS on macOS 26). Detach the invalidated engine immediately so the next recording gets a fresh instance, keep the old object alive until AVFAudio callbacks drain, and restart the graph in place when a recording is still active. Hide CADefaultDeviceAggregate from the mic picker and treat it as a healthy transient route during profile switches. Fixes #196
|
Tried the nightly but now it doesn't work at all. So my guess is that you have a fundamental issue here that prevents the app from working when audio devices change on macOS. I plug in my audio interface or connect my BT headset -> weird things happen. |
Member
Author
|
@cbauer42 Did you try this build because I just built it with this commit? https://github.com/VocaHQ/vocamac/releases/tag/nightly ? |
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
Fixes the rest of #196. The HFP settle wait in #197 got Soundcore recordings to start, but later reports from @cbauer42 show the same path still crashing and interrupting recordings.
Crash
handleAudioConfigurationChangecalledreleaseEngine(), which dropped the last reference toAVAudioEnginewhile AVFAudio was still inAVAudioIOUnit::IOUnitPropertyListener. That is theEXC_BAD_ACCESSon macOS 26.6 and 26.6.1. Apple documents this notification as: do not deallocate the engine from the client's handler.Erratic recordings
Bluetooth A2DP/HFP switches keep posting configuration changes after start. We treated those as a lost microphone, force-stopped, and destroyed the engine. That matches the menu bar audio icon appearing and disappearing, Music.app launching on its own, and
CADefaultDeviceAggregateshowing up in the dropdown.Fix
AVAudioEnginealive foridleEngineReleaseDelayso AVFAudio can finish its callbacks.CADefaultDeviceAggregatefrom the mic picker and treat it as a healthy transient route while HFP is settling.Tests
Unit coverage for aggregate detection, picker filtering, route health, and the startup ignore window.
Hardware check
Please try a Bluetooth headset (Soundcore Liberty 5 / AirPods):
CADefaultDeviceAggregateshould not appear in the mic dropdown.