Skip to content

Audio Session Interruptions#1020

Open
pblazej wants to merge 3 commits into
blaze/audio-session-defaultsfrom
blaze/audio-session-interruptions
Open

Audio Session Interruptions#1020
pblazej wants to merge 3 commits into
blaze/audio-session-defaultsfrom
blaze/audio-session-interruptions

Conversation

@pblazej
Copy link
Copy Markdown
Contributor

@pblazej pblazej commented May 27, 2026

Adds interruption and route-change recovery for the iOS audio session. Closes #886 (audio not resuming after a system interruption — cellular calls, alarms, Siri, FaceTime).

  • New LKRTCAudioSessionDelegate adapter re-applies the active category, mode, and options on:
    • audioSessionDidEndInterruption with shouldResumeSession=true — iOS re-activates the session after an interruption but does not restore the configuration we set.
    • audioSessionDidChangeRoute with .categoryChange / .routeConfigurationChange — externally-driven configuration mutations (CallKit activation, system audio takeover).
  • overrideOutputAudioPort reasserted on resume for .playAndRecord — Apple's documented workaround for a VPIO low-volume regression where audio comes back inaudibly quiet after interruption-end.
  • No-op when isAutomaticConfigurationEnabled = false (CallKit apps that drive AVAudioSession themselves via CXProviderDelegate), so this does not interfere with the documented CallKit integration pattern.
  • Selection logic reused — the re-apply path calls selectConfiguration(state:) from Audio Session Defaults #1019, so resume picks the same category as initial activation (sticky bit, permission gate, etc.).

Depends on #1019; merge base switches to main once that lands.

pblazej and others added 3 commits May 27, 2026 09:36
Closes #1011 — audio loss after a system interruption (cellular call,
alarm, Siri, FaceTime, etc.).

Adds an LKRTCAudioSessionDelegate adapter that listens for
interruption-end and externally-driven route-change events
(.categoryChange, .routeConfigurationChange). On each, re-applies the
current category/mode/options via the existing selectConfiguration
helper. WebRTC re-activates the session on these events but does not
re-apply our configuration; iOS can leave the session in a state
different from what we configured.

Also calls overrideOutputAudioPort as a workaround for a VPIO
low-volume regression where audio comes back inaudibly quiet after
resume; toggling the output port forces a fresh route selection that
picks up the correct gain.

No-op when isAutomaticConfigurationEnabled = false (e.g., CallKit
apps that manage the session themselves), so this does not interfere
with the documented CallKit integration pattern.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Reflects the behavior shipped in this branch — re-apply of category,
mode, and options on interruption-end and externally-driven
category-change events. Notes that the re-apply is skipped when
isAutomaticConfigurationEnabled is false (CallKit pattern).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@pblazej pblazej marked this pull request as ready for review May 29, 2026 07:44
@pblazej
Copy link
Copy Markdown
Contributor Author

pblazej commented May 29, 2026

Tested basic cases like phone calls, AirPods, route changes, etc.

Let's try to break it ⚒️

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