#define ENCODING_E_AC3 6
#define ENCODING_DTS 7
#define ENCODING_DTS_HD 8
+#define ENCODING_MP3 9
+#define ENCODING_AAC_LC 10
+#define ENCODING_AAC_HE_V1 11
+#define ENCODING_AAC_HE_V2 12
#define ENCODING_INVALID 0
#define ENCODING_DEFAULT 1
return AUDIO_FORMAT_DTS;
case ENCODING_DTS_HD:
return AUDIO_FORMAT_DTS_HD;
+ case ENCODING_MP3:
+ return AUDIO_FORMAT_MP3;
+ case ENCODING_AAC_LC:
+ return AUDIO_FORMAT_AAC_LC;
+ case ENCODING_AAC_HE_V1:
+ return AUDIO_FORMAT_AAC_HE_V1;
+ case ENCODING_AAC_HE_V2:
+ return AUDIO_FORMAT_AAC_HE_V2;
case ENCODING_DEFAULT:
return AUDIO_FORMAT_DEFAULT;
default:
return ENCODING_DTS;
case AUDIO_FORMAT_DTS_HD:
return ENCODING_DTS_HD;
+ case AUDIO_FORMAT_MP3:
+ return ENCODING_MP3;
+ case AUDIO_FORMAT_AAC_LC:
+ return ENCODING_AAC_LC;
+ case AUDIO_FORMAT_AAC_HE_V1:
+ return ENCODING_AAC_HE_V1;
+ case AUDIO_FORMAT_AAC_HE_V2:
+ return ENCODING_AAC_HE_V2;
case AUDIO_FORMAT_DEFAULT:
return ENCODING_DEFAULT;
default:
* @see AudioFormat
*/
public @NonNull int[] getEncodings() {
- return mPort.formats();
+ return AudioFormat.filterPublicFormats(mPort.formats());
}
/**
import android.annotation.NonNull;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.util.Arrays;
/**
* The AudioFormat class is used to access a number of audio format and
public static final int ENCODING_DTS = 7;
/** Audio data format: DTS HD compressed */
public static final int ENCODING_DTS_HD = 8;
+ /** Audio data format: MP3 compressed
+ * @hide
+ * */
+ public static final int ENCODING_MP3 = 9;
+ /** Audio data format: AAC LC compressed
+ * @hide
+ * */
+ public static final int ENCODING_AAC_LC = 10;
+ /** Audio data format: AAC HE V1 compressed
+ * @hide
+ * */
+ public static final int ENCODING_AAC_HE_V1 = 11;
+ /** Audio data format: AAC HE V2 compressed
+ * @hide
+ * */
+ public static final int ENCODING_AAC_HE_V2 = 12;
/** Invalid audio channel configuration */
/** @deprecated Use {@link #CHANNEL_INVALID} instead. */
case ENCODING_E_AC3:
case ENCODING_DTS:
case ENCODING_DTS_HD:
+ case ENCODING_MP3:
+ case ENCODING_AAC_LC:
+ case ENCODING_AAC_HE_V1:
+ case ENCODING_AAC_HE_V2:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ /** @hide */
+ public static boolean isPublicEncoding(int audioFormat)
+ {
+ switch (audioFormat) {
+ case ENCODING_PCM_8BIT:
+ case ENCODING_PCM_16BIT:
+ case ENCODING_PCM_FLOAT:
+ case ENCODING_AC3:
+ case ENCODING_E_AC3:
+ case ENCODING_DTS:
+ case ENCODING_DTS_HD:
return true;
default:
return false;
case ENCODING_E_AC3:
case ENCODING_DTS:
case ENCODING_DTS_HD:
+ case ENCODING_MP3:
+ case ENCODING_AAC_LC:
+ case ENCODING_AAC_HE_V1:
+ case ENCODING_AAC_HE_V2:
return false;
case ENCODING_INVALID:
default:
}
}
+ /**
+ * Returns an array of public encoding values extracted from an array of
+ * encoding values.
+ * @hide
+ */
+ public static int[] filterPublicFormats(int[] formats) {
+ if (formats == null) {
+ return null;
+ }
+ int[] myCopy = Arrays.copyOf(formats, formats.length);
+ int size = 0;
+ for (int i = 0; i < myCopy.length; i++) {
+ if (isPublicEncoding(myCopy[i])) {
+ if (size != i) {
+ myCopy[size] = myCopy[i];
+ }
+ size++;
+ }
+ }
+ return Arrays.copyOf(myCopy, size);
+ }
+
/** @removed */
public AudioFormat()
{
audioFormat = AudioFormat.ENCODING_PCM_16BIT;
}
- if (!AudioFormat.isValidEncoding(audioFormat)) {
+ if (!AudioFormat.isPublicEncoding(audioFormat)) {
throw new IllegalArgumentException("Unsupported audio encoding.");
}
mAudioFormat = audioFormat;
}
}
- if (!AudioFormat.isValidEncoding(audioFormat)) {
+ if (!AudioFormat.isPublicEncoding(audioFormat)) {
loge("getMinBufferSize(): Invalid audio format.");
return ERROR_BAD_VALUE;
}
if (devicePort.type() == AudioManager.DEVICE_OUT_HDMI ||
devicePort.type() == AudioManager.DEVICE_OUT_HDMI_ARC) {
// format the list of supported encodings
- int[] formats = devicePort.formats();
+ int[] formats = AudioFormat.filterPublicFormats(devicePort.formats());
if (formats.length > 0) {
ArrayList<Integer> encodingList = new ArrayList(1);
for (int format : formats) {