diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 99510826c9..ab3989eaef 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -51,6 +51,10 @@ behavior of track and location fallback. Location fallback is currently only supported for DASH manifests with multiple base URLs. * Disable platform transcoding when playing content URIs on Android 12. + * Restrict use of `AudioTrack.isDirectPlaybackSupported` to TVs, to avoid + listing audio offload encodings as supported for passthrough mode on + mobile devices + ([#9239](https://github.com/google/ExoPlayer/issues/9239)). * Remove deprecated symbols: * Remove `Player.getPlaybackError`. Use `Player.getPlayerError` instead. * Remove `Player.getCurrentTag`. Use `Player.getCurrentMediaItem` and diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioCapabilities.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioCapabilities.java index 57e7f91aad..a12f63deeb 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioCapabilities.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioCapabilities.java @@ -88,9 +88,12 @@ public final class AudioCapabilities { && Global.getInt(context.getContentResolver(), EXTERNAL_SURROUND_SOUND_KEY, 0) == 1) { return EXTERNAL_SURROUND_SOUND_CAPABILITIES; } - if (Util.SDK_INT >= 29) { + // 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 devices, which generally shouldn't support audio offload for surround encodings. + if (Util.SDK_INT >= 29 && Util.isTv(context)) { return new AudioCapabilities( - AudioTrackWrapperV29.getDirectPlaybackSupportedEncodingsV29(), DEFAULT_MAX_CHANNEL_COUNT); + Api29.getDirectPlaybackSupportedEncodingsV29(), DEFAULT_MAX_CHANNEL_COUNT); } if (intent == null || intent.getIntExtra(AudioManager.EXTRA_AUDIO_PLUG_STATE, 0) == 0) { return DEFAULT_AUDIO_CAPABILITIES; @@ -185,7 +188,7 @@ public final class AudioCapabilities { } @RequiresApi(29) - private static final class AudioTrackWrapperV29 { + private static final class Api29 { @DoNotInline public static int[] getDirectPlaybackSupportedEncodingsV29() { ImmutableList.Builder supportedEncodingsListBuilder = ImmutableList.builder();