mirror of
https://github.com/samsonjs/media.git
synced 2026-03-25 09:25:53 +00: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
This commit is contained in:
parent
eb6f607717
commit
18cbbf3850
1 changed files with 6 additions and 4 deletions
|
|
@ -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…
Reference in a new issue