ios: recover the stream after an audio session interruption - #1295
Merged
roderickvd merged 3 commits intoJul 30, 2026
Merged
Conversation
A call, an alarm or Siri stops the audio unit through CoreAudio without going through cpal, so `StreamInner::playing` is left reading `true` for a unit that is no longer running. `play` then short-circuits on that flag, and the stream can never be resumed: the caller sees a successful `play` and silence, with no error to explain it. `AVAudioSessionInterruptionNotification` is now observed alongside the route-change and media-services notifications the manager already handles. Beginning an interruption stops the unit through the normal path, bringing the flag back in step with reality. When one ends carrying `ShouldResume`, the session is reactivated — it is left inactive, and a unit cannot start against an inactive session — and the unit started again, so a caller does not have to observe the notification itself just to get its stream back. Only streams the interruption stopped resume; one the caller had paused stays paused. Confirmed on device: an app pointed at this branch, with its own restart workaround and its interruption observer both removed, recovers its audio after an alarm is dismissed.
roderickvd
force-pushed
the
ios-audio-session-interruption-review
branch
2 times, most recently
from
July 30, 2026 16:45
954ffb7 to
1e9734e
Compare
- Replace the playing/interrupted bool pair with a PlaybackState enum, so pause() during an interruption can't leave a stale flag that restarts the stream on the next interruption end. - Narrow unsafe to the extern-static reads that actually need it. - Drop the redundant field comment, tighten changelog wording. Co-authored-by: Benoît Rouleau <benoit.rouleau@icloud.com>
roderickvd
force-pushed
the
ios-audio-session-interruption-review
branch
from
July 30, 2026 17:47
1e9734e to
1361cfc
Compare
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.
Continues #1289 (by @benface), addressing the second review round on top of it: pause() no longer leaves a stale flag that could restart a paused stream when the next interruption ends, unsafe is narrowed to the extern-static reads that need it, and the field comment/changelog wording are trimmed.
The
playing/interruptedbool pair became a singlePlaybackStateenum (Stopped/Playing/Interrupted), which also removes the race the two independent bools were prone to.Closes #1289.