Skip to content

Commit

Permalink
Make the API 34 check inline and refactor the comment
Browse files Browse the repository at this point in the history
  • Loading branch information
tianyif committed May 25, 2023
1 parent f301214 commit 730cfec
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
2 changes: 1 addition & 1 deletion RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Ogg: Fix bug when seeking in files with a long duration
([#391](https://github.com/androidx/media/issues/391)).
* Audio:
* Add direct playback supports for DTS Express and DTS:X
* Add direct playback support for DTS Express and DTS:X
([#335](https://github.com/androidx/media/pull/335)).
* Audio Offload:
* Add `AudioSink.getFormatOffloadSupport(Format)` that retrieves level of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ private C() {}
@UnstableApi public static final int ENCODING_DTS = AudioFormat.ENCODING_DTS;
/** See {@link AudioFormat#ENCODING_DTS_HD}. */
@UnstableApi public static final int ENCODING_DTS_HD = AudioFormat.ENCODING_DTS_HD;
/** TODO: To replace with AudioFormat.ENCODING_DTS_UHD_P2 when Android 14.0 is released. */
// TODO(internal b/283949283): Use AudioFormat.ENCODING_DTS_UHD_P2 when Android 14 is released.
@UnstableApi public static final int ENCODING_DTS_UHD_P2 = 0x0000001e;
/** See {@link AudioFormat#ENCODING_DOLBY_TRUEHD}. */
@UnstableApi public static final int ENCODING_DOLBY_TRUEHD = AudioFormat.ENCODING_DOLBY_TRUEHD;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
@UnstableApi
public final class AudioCapabilities {

// TODO(internal b/283945513): Have separate default max channel counts in `AudioCapabilities`
// for PCM and compressed audio.
private static final int DEFAULT_MAX_CHANNEL_COUNT = 10;
@VisibleForTesting /* package */ static final int DEFAULT_SAMPLE_RATE_HZ = 48_000;

Expand Down Expand Up @@ -374,9 +376,12 @@ private Api29() {}

@DoNotInline
public static ImmutableList<Integer> getDirectPlaybackSupportedEncodings() {
ImmutableList<Integer> encodings = Api29.getAllSurroundEncodingsMaybeSupported();
ImmutableList.Builder<Integer> supportedEncodingsListBuilder = ImmutableList.builder();
for (int encoding : encodings) {
for (int encoding : ALL_SURROUND_ENCODINGS_AND_MAX_CHANNELS.keySet()) {
// AudioFormat.ENCODING_DTS_UHD_P2 is supported from API 34.
if (Util.SDK_INT < 34 && encoding == C.ENCODING_DTS_UHD_P2) {
continue;
}
if (AudioTrack.isDirectPlaybackSupported(
new AudioFormat.Builder()
.setChannelMask(AudioFormat.CHANNEL_OUT_STEREO)
Expand Down Expand Up @@ -413,19 +418,5 @@ public static int getMaxSupportedChannelCountForPassthrough(
}
return 0;
}

/** Returns a list of surround encodings that maybe supported. */
@DoNotInline
private static ImmutableList<Integer> getAllSurroundEncodingsMaybeSupported() {
ImmutableList.Builder<Integer> encodings = new ImmutableList.Builder<>();
for (int encoding : ALL_SURROUND_ENCODINGS_AND_MAX_CHANNELS.keySet()) {
// AudioFormat.ENCODING_DTS_UHD_P2 is supported from API 34.
if (Util.SDK_INT < 34 && encoding == C.ENCODING_DTS_UHD_P2) {
continue;
}
encodings.add(encoding);
}
return encodings.build();
}
}
}

0 comments on commit 730cfec

Please sign in to comment.