Construct AudioCapabilities with HDMI reported MaxChannelCount.

This commit is contained in:
Cedric T 2023-05-15 10:36:37 +08:00 committed by Tianyi Feng
parent 905ad1ce33
commit cb29e8fb3d

View File

@ -119,7 +119,9 @@ public final class AudioCapabilities {
supportedEncodings.addAll(Ints.asList( supportedEncodings.addAll(Ints.asList(
intent.getIntArrayExtra(AudioManager.EXTRA_ENCODINGS))); intent.getIntArrayExtra(AudioManager.EXTRA_ENCODINGS)));
return new AudioCapabilities( return new AudioCapabilities(
Ints.toArray(supportedEncodings.build()), /* defaultValue= */ DEFAULT_MAX_CHANNEL_COUNT); Ints.toArray(supportedEncodings.build()),
intent.getIntExtra(AudioManager.EXTRA_MAX_CHANNEL_COUNT, /* defaultValue= */
DEFAULT_MAX_CHANNEL_COUNT));
} }
if (supportedEncodings.build().isEmpty()) { if (supportedEncodings.build().isEmpty()) {
@ -227,7 +229,13 @@ public final class AudioCapabilities {
channelCount = getMaxSupportedChannelCountForPassthrough(encoding, sampleRate); channelCount = getMaxSupportedChannelCountForPassthrough(encoding, sampleRate);
} else { } else {
channelCount = format.channelCount; channelCount = format.channelCount;
if (channelCount > maxChannelCount) { // To file a Bug: Some DTS:X TVs reports ACTION_HDMI_AUDIO_PLUG.EXTRA_MAX_CHANNEL_COUNT as 8
// instead of 10.
if (format.sampleMimeType == MimeTypes.AUDIO_DTS_X) {
if (channelCount > 10) {
return null;
}
} else if (channelCount > maxChannelCount) {
return null; return null;
} }
} }