From 5795ef1ae4a095cb2f5f2f59a30ca565ae2a8696 Mon Sep 17 00:00:00 2001 From: Dean Wheatley Date: Wed, 13 Aug 2025 15:44:04 +1000 Subject: [PATCH] Use stereo channel mask for AC-4 passthrough The Ac4Util format builder can return channel counts up to 21. These channel counts do not have a matching channel mask. To support AC-4 offload/passthrough to offloaded decoders, override the channel count to 2 so that offload/passthrough AudioTracks are built with stereo channel mask so they can reach AC-4 offloaded decoders. This change restores the channel count used prior to 29bda3bb5ce9ee86225ca8c7f44d24183265ee9c for passthrough. --- .../androidx/media3/exoplayer/audio/AudioCapabilities.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/audio/AudioCapabilities.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/audio/AudioCapabilities.java index 9eb7f1c350..7112059bfd 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/audio/AudioCapabilities.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/audio/AudioCapabilities.java @@ -327,6 +327,11 @@ public Pair getEncodingAndChannelConfigForPassthrough( if (channelCount > 10) { return null; } + } else if (format.sampleMimeType.equals(MimeTypes.AUDIO_AC4)) { + // AC-4 content may contain channel (or object) count that does not have a matching channel + // mask. Override channel count to 2 (mapped to stereo channel masK) which is supported by + // all AC-4 offloaded decoders to avoid this limitation and allow track to open. + channelCount = 2; } else if (!audioProfile.supportsChannelCount(channelCount)) { return null; }