Repository navigation
Conversation
…ptions Introduce system AudioFocus linkage to resolve issue shilapi#36 where native head-unit audio (e.g., Bluetooth phone calls, radio, navigation guidance) conflicts with CarPlay media playback. 1. AudioFocusCoordinator: requests system audio focus based on channel priority (MEDIA: GAIN, PHONE: GAIN_TRANSIENT, ASSISTANT: GAIN_TRANSIENT_MAY_DUCK). 2. Ducking & Auto-yield: ducks media playback to 20% volume on AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK, mutes media on AUDIOFOCUS_LOSS_TRANSIENT (e.g., car Bluetooth calls or native voice prompts), and restores full volume on AUDIOFOCUS_GAIN. 3. AirPlayPersistence & CarPlayHostActivity: adds user toggles for Audio Focus and temporary mute auto-yield with persistent storage and resolution summary. 4. AudioFocusCoordinatorTest: adds unit tests covering channel priority ordering and volume constants.
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
Introduce structured Android
AudioFocuscoordination for CarPlay media playback, automatically yielding audio to external car events (radio, Bluetooth calls, navigation announcements) and restoring playback seamlessly.Problem
The media sink previously played decoded PCM audio straight to
AudioTrackwithout requesting or monitoring AndroidAudioManager.OnAudioFocusChangeListener. When other audio sources in the car (such as native navigation alerts, cluster prompts, or external media apps) played, audio would either overlap harshly or compete for the hardware sound card.Solution
AudioFocusCoordinatorsupporting modernAudioFocusRequest(API 26+) and legacy focus management with ducking and transient loss handling.AndroidMediaSinkto request focus before playback and automatically pause/duck when focus is lost.