Skip to content

Commit a85d9e2

Browse files
toniheiSheenaChhabra
authored andcommitted
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 18cbbf3)
1 parent a72a232 commit a85d9e2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

libraries/exoplayer/src/main/java/androidx/media3/exoplayer/audio/AudioCapabilities.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,7 @@ public static AudioCapabilities getCapabilities(
157157

158158
ImmutableSet.Builder<Integer> supportedEncodings = new ImmutableSet.Builder<>();
159159
supportedEncodings.add(C.ENCODING_PCM_16BIT);
160-
if (deviceMaySetExternalSurroundSoundGlobalSetting()
161-
&& Global.getInt(context.getContentResolver(), EXTERNAL_SURROUND_SOUND_KEY, 0) == 1) {
162-
supportedEncodings.addAll(EXTERNAL_SURROUND_SOUND_ENCODINGS);
163-
}
160+
164161
// AudioTrack.isDirectPlaybackSupported returns true for encodings that are supported for audio
165162
// offload, as well as for encodings we want to list for passthrough mode. Therefore we only use
166163
// it on TV and automotive devices, which generally shouldn't support audio offload for surround
@@ -171,6 +168,11 @@ public static AudioCapabilities getCapabilities(
171168
getAudioProfiles(Ints.toArray(supportedEncodings.build()), DEFAULT_MAX_CHANNEL_COUNT));
172169
}
173170

171+
if (deviceMaySetExternalSurroundSoundGlobalSetting()
172+
&& Global.getInt(context.getContentResolver(), EXTERNAL_SURROUND_SOUND_KEY, 0) == 1) {
173+
supportedEncodings.addAll(EXTERNAL_SURROUND_SOUND_ENCODINGS);
174+
}
175+
174176
if (intent != null && intent.getIntExtra(AudioManager.EXTRA_AUDIO_PLUG_STATE, 0) == 1) {
175177
@Nullable int[] encodingsFromExtra = intent.getIntArrayExtra(AudioManager.EXTRA_ENCODINGS);
176178
if (encodingsFromExtra != null) {

0 commit comments

Comments
 (0)