Skip to content

Commit 5e4cd12

Browse files
committed
Use AudioTrack.isDirectPlaybackSupported on TVs only
Issue: #9239 #minor-release PiperOrigin-RevId: 388437614
1 parent cc8f4dc commit 5e4cd12

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

RELEASENOTES.md

+4
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@
5151
behavior of track and location fallback. Location fallback is currently
5252
only supported for DASH manifests with multiple base URLs.
5353
* Disable platform transcoding when playing content URIs on Android 12.
54+
* Restrict use of `AudioTrack.isDirectPlaybackSupported` to TVs, to avoid
55+
listing audio offload encodings as supported for passthrough mode on
56+
mobile devices
57+
([#9239](https://github.com/google/ExoPlayer/issues/9239)).
5458
* Remove deprecated symbols:
5559
* Remove `Player.getPlaybackError`. Use `Player.getPlayerError` instead.
5660
* Remove `Player.getCurrentTag`. Use `Player.getCurrentMediaItem` and

library/core/src/main/java/com/google/android/exoplayer2/audio/AudioCapabilities.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,12 @@ public static AudioCapabilities getCapabilities(Context context) {
8888
&& Global.getInt(context.getContentResolver(), EXTERNAL_SURROUND_SOUND_KEY, 0) == 1) {
8989
return EXTERNAL_SURROUND_SOUND_CAPABILITIES;
9090
}
91-
if (Util.SDK_INT >= 29) {
91+
// AudioTrack.isDirectPlaybackSupported returns true for encodings that are supported for audio
92+
// offload, as well as for encodings we want to list for passthrough mode. Therefore we only use
93+
// it on TV devices, which generally shouldn't support audio offload for surround encodings.
94+
if (Util.SDK_INT >= 29 && Util.isTv(context)) {
9295
return new AudioCapabilities(
93-
AudioTrackWrapperV29.getDirectPlaybackSupportedEncodingsV29(), DEFAULT_MAX_CHANNEL_COUNT);
96+
Api29.getDirectPlaybackSupportedEncodingsV29(), DEFAULT_MAX_CHANNEL_COUNT);
9497
}
9598
if (intent == null || intent.getIntExtra(AudioManager.EXTRA_AUDIO_PLUG_STATE, 0) == 0) {
9699
return DEFAULT_AUDIO_CAPABILITIES;
@@ -185,7 +188,7 @@ private static boolean deviceMaySetExternalSurroundSoundGlobalSetting() {
185188
}
186189

187190
@RequiresApi(29)
188-
private static final class AudioTrackWrapperV29 {
191+
private static final class Api29 {
189192
@DoNotInline
190193
public static int[] getDirectPlaybackSupportedEncodingsV29() {
191194
ImmutableList.Builder<Integer> supportedEncodingsListBuilder = ImmutableList.builder();

0 commit comments

Comments
 (0)