Skip to content

Commit 8117b82

Browse files
committed
Fix AudioCapabilities regression
Since DEFAULT_MAX_CHANNEL_COUNT was increased from 8 to 10, getMaxSupportedChannelCountForPassthrough always throws if its loop enters its second iteration (channelCount of 9). This is due to Util.getAudioTrackChannelConfig returning CHANNEL_INVALID when passed a channelCount of 9, and setting CHANNEL_INVALID as the AudioFormat's channel mask throws an exception. This change skips each iteration where CHANNEL_INVALID is returned.
1 parent 4ebe630 commit 8117b82

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

libraries/exoplayer/src/main/java/androidx/media3/exoplayer/audio/AudioCapabilities.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,11 +406,15 @@ public static int getMaxSupportedChannelCountForPassthrough(
406406
// TODO(internal b/234351617): Query supported channel masks directly once it's supported,
407407
// see also b/25994457.
408408
for (int channelCount = DEFAULT_MAX_CHANNEL_COUNT; channelCount > 0; channelCount--) {
409+
int channelConfig = Util.getAudioTrackChannelConfig(channelCount);
410+
if (channelConfig == AudioFormat.CHANNEL_INVALID) {
411+
continue;
412+
}
409413
AudioFormat audioFormat =
410414
new AudioFormat.Builder()
411415
.setEncoding(encoding)
412416
.setSampleRate(sampleRate)
413-
.setChannelMask(Util.getAudioTrackChannelConfig(channelCount))
417+
.setChannelMask(channelConfig)
414418
.build();
415419
if (AudioTrack.isDirectPlaybackSupported(audioFormat, DEFAULT_AUDIO_ATTRIBUTES)) {
416420
return channelCount;

0 commit comments

Comments
 (0)