Repository navigation
feat(audio): allow host-managed renderer session activation - #872
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Route-change handling can still overwrite host-managed channel preferences when renderer activation is disabled.
1 open issue
What changed in this PR
This PR adds host control over renderer audio-session activation and moves category validation into the process-wide transition queue.
Changes:
- Add a default-enabled activation flag for renderer loads and interruption recovery.
- Coalesce concurrent category setup and revalidate settings on later loads.
- Add ownership tests and document activation, configuration, and deactivation responsibilities.
| File | Description |
|---|---|
| Tests/AetherEngineTests/SharedOutputCoordinatorTests.swift | Test configuration coalescing, revalidation, and activation ownership. |
| Sources/AetherEngine/SharedOutputCoordinator.swift | Serialize and coalesce category configuration. |
| Sources/AetherEngine/AetherEngine+Loading.swift | Gate renderer activation with the new ownership flag. |
| Sources/AetherEngine/AetherEngine.swift | Expose the flag and validate category settings at load. |
| README.md | Update category-configuration timing documentation. |
| docs/formats.md | Clarify load-time audio-session setup. |
| docs/api.md | Document host-managed activation and lifecycle responsibilities. |
| CHANGELOG.md | Announce activation control and shared category setup. |
Review effort: Balanced
| /// iOS/tvOS 27 flag it as a hang risk on the main thread (AE#538): the same reasoning that moved `setCategory` off-main | ||
| /// in #114 and the teardown deactivation in #215. Only the track lookup, which reads published state, stays here. | ||
| func activateRendererAudioSession(audioSourceStreamIndex: Int32? = nil) async { | ||
| guard rendererAudioSessionActivationEnabled else { return } |
1a3975d to
3057c8a
Compare
…st activation own the channel preference (#872 follow-up) #872 moved the category declaration from init to every load and rewrote it whenever the session no longer matched. A host that switches the mode after the first load (Sodalite's music playback sets .playback/.default and activates) then had it flipped back to .moviePlayback on an active session at every track. The declaration now runs once: concurrent loads share it, a success is never repeated, a failure is retried, and a session the host already put on .playback keeps its mode and policy. rendererAudioSessionActivationEnabled = false now also covers route changes: ownsChannelPreference no longer writes the channel preference for a host that owns activation. The init-time diagnostic line (category, maxChannels, output) moves to the declaration so #24-style downmix reports still carry it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WJcXkGQrMiBPixVEFTSBJS
|
Merged in 3e256c5, thanks @jonluca, the activation switch and the coalesced category setup are a good fit for hosts that juggle several players. Follow-up in 24898a4, two changes on top:
The init-time |

Summary
Let hosts coordinating audible focus across several players own renderer audio-session activation. Coalesce concurrent category setup through the existing process-wide transition queue and validate current settings on later loads, avoiding repeated configuration of an already matching session.
What changed
rendererAudioSessionActivationEnabled, defaulting to true. When disabled before load, renderer loads and interruption recovery skip activation and channel preference changes.SharedOutputCoordinator.Test plan
-warnings-as-errors.git diff --checkpass.Checklist
CHANGELOG.mdupdated