Swap HDMI case and non-HDMI case in AudioCapabilities.

This commit is contained in:
Cedric T 2023-05-12 09:44:07 +08:00 committed by Tianyi Feng
parent 773d3c52f1
commit 6b4cf4d362

View File

@ -115,7 +115,13 @@ public final class AudioCapabilities {
supportedEncodings.addAll(Ints.asList(Api29.getDirectPlaybackSupportedEncodings())); supportedEncodings.addAll(Ints.asList(Api29.getDirectPlaybackSupportedEncodings()));
} }
if (intent == null || intent.getIntExtra(AudioManager.EXTRA_AUDIO_PLUG_STATE, 0) == 0) { if (intent == null || intent.getIntExtra(AudioManager.EXTRA_AUDIO_PLUG_STATE, 0) == 1) {
supportedEncodings.addAll(Ints.asList(
intent.getIntArrayExtra(AudioManager.EXTRA_ENCODINGS)));
return new AudioCapabilities(
Ints.toArray(supportedEncodings.build()), /* defaultValue= */ DEFAULT_MAX_CHANNEL_COUNT);
}
if (supportedEncodings.build().isEmpty()) { if (supportedEncodings.build().isEmpty()) {
return DEFAULT_AUDIO_CAPABILITIES; return DEFAULT_AUDIO_CAPABILITIES;
} else { } else {
@ -124,12 +130,6 @@ public final class AudioCapabilities {
} }
} }
supportedEncodings.addAll(Ints.asList(
intent.getIntArrayExtra(AudioManager.EXTRA_ENCODINGS)));
return new AudioCapabilities(
Ints.toArray(supportedEncodings.build()), /* defaultValue= */ DEFAULT_MAX_CHANNEL_COUNT);
}
/** /**
* Returns the global settings {@link Uri} used by the device to specify external surround sound, * Returns the global settings {@link Uri} used by the device to specify external surround sound,
* or null if the device does not support this functionality. * or null if the device does not support this functionality.