Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c2aa3557 authored by Andy Hung's avatar Andy Hung Committed by Android Git Automerger
Browse files

am 2bdd69c4: Merge "Add getChannelIndexMasks API to AudioDeviceInfo" into mnc-dev

* commit '2bdd69c4':
  Add getChannelIndexMasks API to AudioDeviceInfo
parents 393fc7f0 2bdd69c4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -14694,6 +14694,7 @@ package android.media {
  public final class AudioDeviceInfo {
    method public int[] getChannelCounts();
    method public int[] getChannelIndexMasks();
    method public int[] getChannelMasks();
    method public int[] getFormats();
    method public int getId();
+1 −0
Original line number Diff line number Diff line
@@ -15907,6 +15907,7 @@ package android.media {
  public final class AudioDeviceInfo {
    method public int[] getChannelCounts();
    method public int[] getChannelIndexMasks();
    method public int[] getChannelMasks();
    method public int[] getFormats();
    method public int getId();
+25 −9
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.media;

import android.annotation.NonNull;
import android.util.SparseIntArray;

/**
@@ -151,27 +152,38 @@ public final class AudioDeviceInfo {
    /**
     * @return An array of sample rates supported by the audio device.
     */
    public int[] getSampleRates() {
    public @NonNull int[] getSampleRates() {
        return mPort.samplingRates();
    }

    /**
     * @return An array of channel masks ({@link AudioFormat#CHANNEL_IN_STEREO},
     * {@link AudioFormat#CHANNEL_OUT_7POINT1) for which this audio device can be configured.
     * @return An array of channel position masks (e.g. {@link AudioFormat#CHANNEL_IN_STEREO},
     * {@link AudioFormat#CHANNEL_OUT_7POINT1}) for which this audio device can be configured.
     *
     * @see AudioFormat
     */
    public int[] getChannelMasks() {
    public @NonNull int[] getChannelMasks() {
        return mPort.channelMasks();
    }

    /**
     * @return An array of channel counts (1, 2, 4....) for which this audio device
     * @return An array of channel index masks for which this audio device can be configured.
     *
     * @see AudioFormat
     */
    public @NonNull int[] getChannelIndexMasks() {
        // TODO: implement
        return new int[0];
    }

    /**
     * @return An array of channel counts (1, 2, 4, ...) for which this audio device
     * can be configured.
     */
    public int[] getChannelCounts() {
    public @NonNull int[] getChannelCounts() {
        int[] masks = getChannelMasks();
        int[] counts = new int[masks.length];
        // TODO: consider channel index masks
        for (int mask_index = 0; mask_index < masks.length; mask_index++) {
            counts[mask_index] = isSink()
                    ? AudioFormat.channelCountFromOutChannelMask(masks[mask_index])
@@ -181,12 +193,16 @@ public final class AudioDeviceInfo {
    }

    /**
     * @return An array of audio format IDs (@link AudioFormat#ENCODING_PCM_16BIT,
     * {@link AudioFormat#ENCODING_PCM_FLOAT}...) supported by the audio device.
     * @return An array of audio encodings (e.g. {@link AudioFormat#ENCODING_PCM_16BIT},
     * {@link AudioFormat#ENCODING_PCM_FLOAT}) supported by the audio device.
     * <code>ENCODING_PCM_FLOAT</code> indicates the device supports more
     * than 16 bits of integer precision.  Specifying <code>ENCODING_PCM_FLOAT</code>
     * with {@link AudioTrack} or {@link AudioRecord} can preserve at least 24 bits of
     * integer precision to that device.
     *
     * @see AudioFormat
     */
    public int[] getFormats() {
    public @NonNull int[] getFormats() {
        return mPort.formats();
    }