Skip to content

Commit

Permalink
Construct AudioCapabilities with HDMI reported MaxChannelCount.
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricxperi committed May 15, 2023
1 parent 56ff091 commit 78a0385
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ public static AudioCapabilities getCapabilities(Context context) {
supportedEncodings.addAll(Ints.asList(
intent.getIntArrayExtra(AudioManager.EXTRA_ENCODINGS)));
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()) {
Expand Down Expand Up @@ -226,7 +228,13 @@ public Pair<Integer, Integer> getEncodingAndChannelConfigForPassthrough(Format f
channelCount = getMaxSupportedChannelCountForPassthrough(encoding, sampleRate);
} else {
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;
}
}
Expand Down

0 comments on commit 78a0385

Please sign in to comment.