Skip to content

Fix crashes in handleRouteChange during audio engine reset#36

Open
ptrbrynt wants to merge 5 commits into
biner88:mainfrom
ptrbrynt:main
Open

Fix crashes in handleRouteChange during audio engine reset#36
ptrbrynt wants to merge 5 commits into
biner88:mainfrom
ptrbrynt:main

Conversation

@ptrbrynt

Copy link
Copy Markdown

No description provided.

ptrbrynt and others added 5 commits June 10, 2026 09:24
AVAudioEngine.disconnectNodeOutput throws an NSException if the node
has no output connections. After audioEngine.reset() in handleRouteChange
all connections are already cleared, so the subsequent disconnectNodeOutput
call in reconnectPlayerNode crashes. Guard the call by checking
outputConnectionPoints first.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
outputConnectionPointsForNode throws an NSException if called after
audioEngine.reset(), because reset() puts nodes into an invalid state
for connection queries. Since reset() already clears all connections,
reconnect the player node directly in handleRouteChange rather than
going through reconnectPlayerNode (which defensively queries first).

reconnectPlayerNode retains its guard for the setAudioFile path,
where the engine is stopped but not reset and nodes remain attached.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
audioEngine.reset() only resets DSP node state — it does not clear
connections. Calling connect() or disconnectNodeOutput() on an already-
connected graph after reset() raises an NSException (the root cause of
the crash reported in A5F032EC). Removing reset() and the redundant
reconnect lets stop()/start() handle hardware route reconfiguration
naturally.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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