Skip to content

[Feature] Add preferredAudioChannelCount for audio track selection#2996

Open
KanghyunJeon wants to merge 3 commits intoandroidx:mainfrom
KanghyunJeon:feature/preferred-audio-channel-count
Open

[Feature] Add preferredAudioChannelCount for audio track selection#2996
KanghyunJeon wants to merge 3 commits intoandroidx:mainfrom
KanghyunJeon:feature/preferred-audio-channel-count

Conversation

@KanghyunJeon
Copy link

Summary

This PR implements the feature requested in #2992.

Adds a new TrackSelectionParameters.preferredAudioChannelCount API that allows apps to prefer audio tracks with higher channel counts (e.g., 5.1, 7.1 surround) over stereo tracks, regardless of role flags (main vs alternate).

Changes

  • Add preferredAudioChannelCount field to TrackSelectionParameters
  • Add setPreferredAudioChannelCount(int) builder method
  • Modify AudioTrackInfo.compareTo() to prioritize higher channel count when preference is set
  • Reuse existing parameters and channelCount fields

Behavior

  • When preferredAudioChannelCount > 0, tracks are compared by channel count before role flags
  • Higher channel count tracks are preferred
  • Falls back to lower channel count if higher is not supported by the renderer
  • Set to 0 (default) to use original behavior based on role flags

Issue

#2992

@microkatz microkatz force-pushed the feature/preferred-audio-channel-count branch from 8100bcc to 9da6947 Compare February 25, 2026 15:02
@microkatz
Copy link
Contributor

I'm going to send this for internal review now. You may see some more commits being added as I make changes in response to review feedback. Please refrain from pushing any more substantive changes as it will complicate the internal review - thanks!

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.

2 participants