Skip to content

Commit

Permalink
Use AudioTrack.isDirectPlaybackSupported on TVs only
Browse files Browse the repository at this point in the history
Issue: #9239

#minor-release

PiperOrigin-RevId: 388437614
  • Loading branch information
andrewlewis committed Aug 3, 2021
1 parent cc8f4dc commit 5e4cd12
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,12 @@ public static AudioCapabilities getCapabilities(Context context) {
&& 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;
Expand Down Expand Up @@ -185,7 +188,7 @@ private static boolean deviceMaySetExternalSurroundSoundGlobalSetting() {
}

@RequiresApi(29)
private static final class AudioTrackWrapperV29 {
private static final class Api29 {
@DoNotInline
public static int[] getDirectPlaybackSupportedEncodingsV29() {
ImmutableList.Builder<Integer> supportedEncodingsListBuilder = ImmutableList.builder();
Expand Down

0 comments on commit 5e4cd12

Please sign in to comment.