fix: stop camera streams from ducking system audio#140
Merged
nickustinov merged 2 commits intoJul 2, 2026
Conversation
nickustinov
approved these changes
Jul 2, 2026
nickustinov
left a comment
Owner
There was a problem hiding this comment.
Thanks Matt! Reviewed and verified – activation/deactivation is balanced on every path (connect/disconnect, play/stop, mute toggle, fallback chain, deinit), and the build passes on Mac Catalyst. Nice clean fix for #138.
One note for the future: since AVAudioSession.setActive(false) isn't reference-counted, the unconditional deactivation in both clients would need revisiting if we ever add a multi-camera live grid. Fine as-is with the single-stream architecture.
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
Camera streams no longer duck (lower the volume of) other system audio. The stream players now configure their audio session so opening a camera view stops interrupting music, calls, or other playback, and the session is deactivated cleanly when the stream closes.
Why this matters
Issue #138 reports that viewing a camera ducks system audio: starting an HLS or WebRTC camera stream activated an audio session with default options, so iOS lowered other audio even though these streams are typically muted video. Users watching a camera had their music or podcast volume dropped for no reason.
The stream clients now use a non-ducking audio-session configuration and balance activation with deactivation on teardown. Because
LKRTCAudioSession(WebRTC) and the AVAudioSession are reference-counted, activation and deactivation are guarded by a per-clientdidActivateAudioSessionflag so each client activates at most once and deactivates exactly once.deinitroutes through the idempotent teardown, so normaldisconnect(); client = nilflows and stream reopen do not drive the reference count negative or leave the session active.Testing
Verified the activation/deactivation is balanced and idempotent by tracing the disconnect and deinit paths and the mute path (which clears the flag after deactivating). On-device build/run was not exercised in this environment (no iOS simulator available); the change is scoped to audio-session setup and teardown in the two stream clients.
Fixes #138