Commit 5e4cd129 by andrewlewis Committed by Andrew Lewis

Use AudioTrack.isDirectPlaybackSupported on TVs only

Issue: #9239

#minor-release

PiperOrigin-RevId: 388437614
parent cc8f4dcc
...@@ -51,6 +51,10 @@ ...@@ -51,6 +51,10 @@
behavior of track and location fallback. Location fallback is currently behavior of track and location fallback. Location fallback is currently
only supported for DASH manifests with multiple base URLs. only supported for DASH manifests with multiple base URLs.
* Disable platform transcoding when playing content URIs on Android 12. * 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 deprecated symbols:
* Remove `Player.getPlaybackError`. Use `Player.getPlayerError` instead. * Remove `Player.getPlaybackError`. Use `Player.getPlayerError` instead.
* Remove `Player.getCurrentTag`. Use `Player.getCurrentMediaItem` and * Remove `Player.getCurrentTag`. Use `Player.getCurrentMediaItem` and
......
...@@ -88,9 +88,12 @@ public final class AudioCapabilities { ...@@ -88,9 +88,12 @@ public final class AudioCapabilities {
&& Global.getInt(context.getContentResolver(), EXTERNAL_SURROUND_SOUND_KEY, 0) == 1) { && Global.getInt(context.getContentResolver(), EXTERNAL_SURROUND_SOUND_KEY, 0) == 1) {
return EXTERNAL_SURROUND_SOUND_CAPABILITIES; 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( 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) { if (intent == null || intent.getIntExtra(AudioManager.EXTRA_AUDIO_PLUG_STATE, 0) == 0) {
return DEFAULT_AUDIO_CAPABILITIES; return DEFAULT_AUDIO_CAPABILITIES;
...@@ -185,7 +188,7 @@ public final class AudioCapabilities { ...@@ -185,7 +188,7 @@ public final class AudioCapabilities {
} }
@RequiresApi(29) @RequiresApi(29)
private static final class AudioTrackWrapperV29 { private static final class Api29 {
@DoNotInline @DoNotInline
public static int[] getDirectPlaybackSupportedEncodingsV29() { public static int[] getDirectPlaybackSupportedEncodingsV29() {
ImmutableList.Builder<Integer> supportedEncodingsListBuilder = ImmutableList.builder(); ImmutableList.Builder<Integer> supportedEncodingsListBuilder = ImmutableList.builder();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment