mirror of
https://github.com/samsonjs/media.git
synced 2026-04-10 12:05:47 +00:00
Additional changes to AudioCapabilities.java and Util.java
This commit is contained in:
parent
b1ac7685bd
commit
924723d6b3
2 changed files with 5 additions and 43 deletions
|
|
@ -516,26 +516,6 @@ public final class Util {
|
|||
return concatenation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Integer array containing the concatenation of two non-null Integer arrays.
|
||||
*
|
||||
* @param first The first array.
|
||||
* @param second The second array.
|
||||
* @return The concatenated result.
|
||||
*/
|
||||
@UnstableApi
|
||||
@SuppressWarnings("nullness:assignment")
|
||||
public static int[] nullSafeIntegerArrayConcatenation(int[] first, int[] second) {
|
||||
int[] concatenation = Arrays.copyOf(first, first.length + second.length);
|
||||
System.arraycopy(
|
||||
/* src= */ second,
|
||||
+ /* srcPos= */ 0,
|
||||
/* dest= */ concatenation,
|
||||
/* destPos= */ first.length,
|
||||
/* length= */ second.length);
|
||||
return concatenation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove duplicates from an Integer array.
|
||||
*
|
||||
|
|
@ -576,23 +556,6 @@ public final class Util {
|
|||
list.toArray(array);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Integer array from a List of Integers.
|
||||
*
|
||||
* @param list The list of integers to convert.
|
||||
* @return Created array of integers.
|
||||
*/
|
||||
@UnstableApi
|
||||
@SuppressWarnings("nullness:assignment")
|
||||
public static int[] nullSafeIntegerListToArray(List<Integer> list) {
|
||||
int[] intList = new int[list.size()];
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
intList[i] = list.get(i);
|
||||
}
|
||||
return intList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link Handler} on the current {@link Looper} thread.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -112,9 +112,8 @@ public final class AudioCapabilities {
|
|||
// it on TV and automotive devices, which generally shouldn't support audio offload for surround
|
||||
// encodings.
|
||||
if (Util.SDK_INT >= 29 && (Util.isTv(context) || Util.isAutomotive(context))) {
|
||||
supportedEncodings = Util.nullSafeIntegerArrayConcatenation(supportedEncodings,
|
||||
Api29.getDirectPlaybackSupportedEncodings(
|
||||
Util.nullSafeIntegerListToArray(Api29.getAllSurroundEncodingsMaybeSupported())));
|
||||
supportedEncodings = Ints.concat(supportedEncodings,
|
||||
Api29.getDirectPlaybackSupportedEncodings(Api29.getAllSurroundEncodingsMaybeSupported()));
|
||||
}
|
||||
|
||||
if (intent == null || intent.getIntExtra(AudioManager.EXTRA_AUDIO_PLUG_STATE, 0) == 0) {
|
||||
|
|
@ -127,7 +126,7 @@ public final class AudioCapabilities {
|
|||
}
|
||||
}
|
||||
|
||||
supportedEncodings = Util.nullSafeIntegerArrayConcatenation(supportedEncodings,
|
||||
supportedEncodings = Ints.concat(supportedEncodings,
|
||||
intent.getIntArrayExtra(AudioManager.EXTRA_ENCODINGS));
|
||||
supportedEncodings = Util.nullSafeIntegerArrayDistinct(supportedEncodings);
|
||||
return new AudioCapabilities(
|
||||
|
|
@ -409,7 +408,7 @@ public final class AudioCapabilities {
|
|||
/**
|
||||
* Returns an array list of surround encodings that maybe supported.
|
||||
*/
|
||||
private static ImmutableList<Integer> getAllSurroundEncodingsMaybeSupported() {
|
||||
private static int[] 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.
|
||||
|
|
@ -418,7 +417,7 @@ public final class AudioCapabilities {
|
|||
}
|
||||
encodings.add(encoding);
|
||||
}
|
||||
return encodings.build();
|
||||
return Ints.toArray(encodings.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue