mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Reorder audio capability checks
Using the more accurate check available on later API versions first is likely better than falling back to a fallback solution from older API versions. PiperOrigin-RevId: 614612628 (cherry picked from commit 18cbbf3850df841f0396abcd2c7e5e8196e85bac)
This commit is contained in:
parent
a72a23266b
commit
a85d9e251c
@ -157,10 +157,7 @@ public final class AudioCapabilities {
|
||||
|
||||
ImmutableSet.Builder<Integer> supportedEncodings = new ImmutableSet.Builder<>();
|
||||
supportedEncodings.add(C.ENCODING_PCM_16BIT);
|
||||
if (deviceMaySetExternalSurroundSoundGlobalSetting()
|
||||
&& Global.getInt(context.getContentResolver(), EXTERNAL_SURROUND_SOUND_KEY, 0) == 1) {
|
||||
supportedEncodings.addAll(EXTERNAL_SURROUND_SOUND_ENCODINGS);
|
||||
}
|
||||
|
||||
// AudioTrack.isDirectPlaybackSupported returns true for encodings that are supported for audio
|
||||
// offload, as well as for encodings we want to list for passthrough mode. Therefore we only use
|
||||
// it on TV and automotive devices, which generally shouldn't support audio offload for surround
|
||||
@ -171,6 +168,11 @@ public final class AudioCapabilities {
|
||||
getAudioProfiles(Ints.toArray(supportedEncodings.build()), DEFAULT_MAX_CHANNEL_COUNT));
|
||||
}
|
||||
|
||||
if (deviceMaySetExternalSurroundSoundGlobalSetting()
|
||||
&& Global.getInt(context.getContentResolver(), EXTERNAL_SURROUND_SOUND_KEY, 0) == 1) {
|
||||
supportedEncodings.addAll(EXTERNAL_SURROUND_SOUND_ENCODINGS);
|
||||
}
|
||||
|
||||
if (intent != null && intent.getIntExtra(AudioManager.EXTRA_AUDIO_PLUG_STATE, 0) == 1) {
|
||||
@Nullable int[] encodingsFromExtra = intent.getIntArrayExtra(AudioManager.EXTRA_ENCODINGS);
|
||||
if (encodingsFromExtra != null) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user