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

Commit 56855ea2 authored by Łukasz Rymanowski's avatar Łukasz Rymanowski Committed by Automerger Merge Worker
Browse files

Merge "LE_Audio: Add missing spec defined sampling frequencies" into main am: c020543f

parents 5f249b17 c020543f
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -977,12 +977,19 @@ package android.bluetooth {
    field public static final int FRAME_DURATION_10000 = 2; // 0x2
    field public static final int FRAME_DURATION_7500 = 1; // 0x1
    field public static final int FRAME_DURATION_NONE = 0; // 0x0
    field @FlaggedApi("com.android.bluetooth.flags.leaudio_add_sampling_frequencies") public static final int SAMPLE_RATE_11025 = 2; // 0x2
    field public static final int SAMPLE_RATE_16000 = 4; // 0x4
    field @FlaggedApi("com.android.bluetooth.flags.leaudio_add_sampling_frequencies") public static final int SAMPLE_RATE_176400 = 1024; // 0x400
    field @FlaggedApi("com.android.bluetooth.flags.leaudio_add_sampling_frequencies") public static final int SAMPLE_RATE_192000 = 2048; // 0x800
    field @FlaggedApi("com.android.bluetooth.flags.leaudio_add_sampling_frequencies") public static final int SAMPLE_RATE_22050 = 8; // 0x8
    field public static final int SAMPLE_RATE_24000 = 16; // 0x10
    field public static final int SAMPLE_RATE_32000 = 32; // 0x20
    field @FlaggedApi("com.android.bluetooth.flags.leaudio_add_sampling_frequencies") public static final int SAMPLE_RATE_384000 = 4096; // 0x1000
    field public static final int SAMPLE_RATE_44100 = 64; // 0x40
    field public static final int SAMPLE_RATE_48000 = 128; // 0x80
    field public static final int SAMPLE_RATE_8000 = 1; // 0x1
    field @FlaggedApi("com.android.bluetooth.flags.leaudio_add_sampling_frequencies") public static final int SAMPLE_RATE_88200 = 256; // 0x100
    field @FlaggedApi("com.android.bluetooth.flags.leaudio_add_sampling_frequencies") public static final int SAMPLE_RATE_96000 = 512; // 0x200
    field public static final int SAMPLE_RATE_NONE = 0; // 0x0
    field public static final int SOURCE_CODEC_TYPE_INVALID = 1000000; // 0xf4240
    field public static final int SOURCE_CODEC_TYPE_LC3 = 0; // 0x0
+40 −2
Original line number Diff line number Diff line
@@ -16,12 +16,15 @@

package android.bluetooth;

import android.annotation.FlaggedApi;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.Parcel;
import android.os.Parcelable;

import com.android.bluetooth.flags.Flags;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Objects;
@@ -73,11 +76,18 @@ public final class BluetoothLeAudioCodecConfig implements Parcelable {
            value = {
                SAMPLE_RATE_NONE,
                SAMPLE_RATE_8000,
                SAMPLE_RATE_11025,
                SAMPLE_RATE_16000,
                SAMPLE_RATE_22050,
                SAMPLE_RATE_24000,
                SAMPLE_RATE_32000,
                SAMPLE_RATE_44100,
                SAMPLE_RATE_48000
                SAMPLE_RATE_48000,
                SAMPLE_RATE_88200,
                SAMPLE_RATE_96000,
                SAMPLE_RATE_176400,
                SAMPLE_RATE_192000,
                SAMPLE_RATE_384000
            })
    @Retention(RetentionPolicy.SOURCE)
    public @interface SampleRate {}
@@ -85,16 +95,24 @@ public final class BluetoothLeAudioCodecConfig implements Parcelable {
    /**
     * Codec sample rate 0 Hz. Default value used for codec sample rate. Values are the bit mask as
     * defined in the Bluetooth Assigned Numbers, Generic Audio, Supported_Sampling_Frequencies
     * table Note: We use only part of it.
     * table.
     */
    public static final int SAMPLE_RATE_NONE = 0;

    /** Codec sample rate 8000 Hz. */
    public static final int SAMPLE_RATE_8000 = 0x01 << 0;

    /** Codec sample rate 11025 Hz. */
    @FlaggedApi(Flags.FLAG_LEAUDIO_ADD_SAMPLING_FREQUENCIES)
    public static final int SAMPLE_RATE_11025 = 0x01 << 1;

    /** Codec sample rate 16000 Hz. */
    public static final int SAMPLE_RATE_16000 = 0x01 << 2;

    /** Codec sample rate 22050 Hz. */
    @FlaggedApi(Flags.FLAG_LEAUDIO_ADD_SAMPLING_FREQUENCIES)
    public static final int SAMPLE_RATE_22050 = 0x01 << 3;

    /** Codec sample rate 24000 Hz. */
    public static final int SAMPLE_RATE_24000 = 0x01 << 4;

@@ -107,6 +125,26 @@ public final class BluetoothLeAudioCodecConfig implements Parcelable {
    /** Codec sample rate 48000 Hz. */
    public static final int SAMPLE_RATE_48000 = 0x01 << 7;

    /** Codec sample rate 88200 Hz. */
    @FlaggedApi(Flags.FLAG_LEAUDIO_ADD_SAMPLING_FREQUENCIES)
    public static final int SAMPLE_RATE_88200 = 0x01 << 8;

    /** Codec sample rate 96000 Hz. */
    @FlaggedApi(Flags.FLAG_LEAUDIO_ADD_SAMPLING_FREQUENCIES)
    public static final int SAMPLE_RATE_96000 = 0x01 << 9;

    /** Codec sample rate 176400 Hz. */
    @FlaggedApi(Flags.FLAG_LEAUDIO_ADD_SAMPLING_FREQUENCIES)
    public static final int SAMPLE_RATE_176400 = 0x01 << 10;

    /** Codec sample rate 192000 Hz. */
    @FlaggedApi(Flags.FLAG_LEAUDIO_ADD_SAMPLING_FREQUENCIES)
    public static final int SAMPLE_RATE_192000 = 0x01 << 11;

    /** Codec sample rate 384000 Hz. */
    @FlaggedApi(Flags.FLAG_LEAUDIO_ADD_SAMPLING_FREQUENCIES)
    public static final int SAMPLE_RATE_384000 = 0x01 << 12;

    /** @hide */
    @IntDef(
            flag = true,
+62 −1
Original line number Diff line number Diff line
@@ -29,13 +29,18 @@ import static android.bluetooth.BluetoothLeAudioCodecConfig.SAMPLE_RATE_8000;
import static android.bluetooth.BluetoothLeAudioCodecConfig.SAMPLE_RATE_NONE;
import static android.bluetooth.BluetoothLeAudioCodecConfig.SampleRate;

import android.annotation.FlaggedApi;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.bluetooth.BluetoothLeAudioCodecConfig.FrameDuration;
import android.bluetooth.BluetoothLeAudioCodecConfig.SampleRate;
import android.bluetooth.BluetoothUtils.TypeValueEntry;
import android.os.Parcel;
import android.os.Parcelable;

import com.android.bluetooth.flags.Flags;

import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
@@ -70,6 +75,13 @@ public final class BluetoothLeAudioCodecConfigMetadata implements Parcelable {
    private static final int CONFIG_SAMPLING_FREQUENCY_32000 = 0x06;
    private static final int CONFIG_SAMPLING_FREQUENCY_44100 = 0x07;
    private static final int CONFIG_SAMPLING_FREQUENCY_48000 = 0x08;
    private static final int CONFIG_SAMPLING_FREQUENCY_11025 = 0x09;
    private static final int CONFIG_SAMPLING_FREQUENCY_22050 = 0x0a;
    private static final int CONFIG_SAMPLING_FREQUENCY_88200 = 0x0b;
    private static final int CONFIG_SAMPLING_FREQUENCY_96000 = 0x0c;
    private static final int CONFIG_SAMPLING_FREQUENCY_176400 = 0x0d;
    private static final int CONFIG_SAMPLING_FREQUENCY_192000 = 0x0e;
    private static final int CONFIG_SAMPLING_FREQUENCY_384000 = 0x0f;

    /** Audio codec config frame duration from metadata. */
    private static final int CONFIG_FRAME_DURATION_UNKNOWN = -1;
@@ -375,8 +387,21 @@ public final class BluetoothLeAudioCodecConfigMetadata implements Parcelable {
                    && sampleRate != SAMPLE_RATE_32000
                    && sampleRate != SAMPLE_RATE_44100
                    && sampleRate != SAMPLE_RATE_48000) {

                if (Flags.leaudioAddSamplingFrequencies()) {
                    if (sampleRate != BluetoothLeAudioCodecConfig.SAMPLE_RATE_11025
                            && sampleRate != BluetoothLeAudioCodecConfig.SAMPLE_RATE_22050
                            && sampleRate != BluetoothLeAudioCodecConfig.SAMPLE_RATE_88200
                            && sampleRate != BluetoothLeAudioCodecConfig.SAMPLE_RATE_96000
                            && sampleRate != BluetoothLeAudioCodecConfig.SAMPLE_RATE_176400
                            && sampleRate != BluetoothLeAudioCodecConfig.SAMPLE_RATE_192000
                            && sampleRate != BluetoothLeAudioCodecConfig.SAMPLE_RATE_384000) {
                        throw new IllegalArgumentException("Invalid sample rate " + sampleRate);
                    }
                } else {
                    throw new IllegalArgumentException("Invalid sample rate " + sampleRate);
                }
            }
            mSampleRate = sampleRate;
            return this;
        }
@@ -504,6 +529,24 @@ public final class BluetoothLeAudioCodecConfigMetadata implements Parcelable {
            case CONFIG_SAMPLING_FREQUENCY_48000:
                return SAMPLE_RATE_48000;
            default:
                if (Flags.leaudioAddSamplingFrequencies()) {
                    switch (samplingFrequencyValue) {
                        case CONFIG_SAMPLING_FREQUENCY_11025:
                            return BluetoothLeAudioCodecConfig.SAMPLE_RATE_11025;
                        case CONFIG_SAMPLING_FREQUENCY_22050:
                            return BluetoothLeAudioCodecConfig.SAMPLE_RATE_22050;
                        case CONFIG_SAMPLING_FREQUENCY_88200:
                            return BluetoothLeAudioCodecConfig.SAMPLE_RATE_88200;
                        case CONFIG_SAMPLING_FREQUENCY_96000:
                            return BluetoothLeAudioCodecConfig.SAMPLE_RATE_96000;
                        case CONFIG_SAMPLING_FREQUENCY_176400:
                            return BluetoothLeAudioCodecConfig.SAMPLE_RATE_176400;
                        case CONFIG_SAMPLING_FREQUENCY_192000:
                            return BluetoothLeAudioCodecConfig.SAMPLE_RATE_192000;
                        case CONFIG_SAMPLING_FREQUENCY_384000:
                            return BluetoothLeAudioCodecConfig.SAMPLE_RATE_384000;
                    }
                }
                return SAMPLE_RATE_NONE;
        }
    }
@@ -523,6 +566,24 @@ public final class BluetoothLeAudioCodecConfigMetadata implements Parcelable {
            case SAMPLE_RATE_48000:
                return CONFIG_SAMPLING_FREQUENCY_48000;
            default:
                if (Flags.leaudioAddSamplingFrequencies()) {
                    switch (sampleRateBitSet) {
                        case BluetoothLeAudioCodecConfig.SAMPLE_RATE_11025:
                            return CONFIG_SAMPLING_FREQUENCY_11025;
                        case BluetoothLeAudioCodecConfig.SAMPLE_RATE_22050:
                            return CONFIG_SAMPLING_FREQUENCY_22050;
                        case BluetoothLeAudioCodecConfig.SAMPLE_RATE_88200:
                            return CONFIG_SAMPLING_FREQUENCY_88200;
                        case BluetoothLeAudioCodecConfig.SAMPLE_RATE_96000:
                            return CONFIG_SAMPLING_FREQUENCY_96000;
                        case BluetoothLeAudioCodecConfig.SAMPLE_RATE_176400:
                            return CONFIG_SAMPLING_FREQUENCY_176400;
                        case BluetoothLeAudioCodecConfig.SAMPLE_RATE_192000:
                            return CONFIG_SAMPLING_FREQUENCY_192000;
                        case BluetoothLeAudioCodecConfig.SAMPLE_RATE_384000:
                            return CONFIG_SAMPLING_FREQUENCY_384000;
                    }
                }
                return CONFIG_SAMPLING_FREQUENCY_UNKNOWN;
        }
    }
+29 −1
Original line number Diff line number Diff line
@@ -102,11 +102,18 @@ typedef enum { QUALITY_STANDARD = 0, QUALITY_HIGH } btle_audio_quality_t;
typedef enum {
  LE_AUDIO_SAMPLE_RATE_INDEX_NONE = 0,
  LE_AUDIO_SAMPLE_RATE_INDEX_8000HZ = 0x01 << 0,
  LE_AUDIO_SAMPLE_RATE_INDEX_11025HZ = 0x01 << 1,
  LE_AUDIO_SAMPLE_RATE_INDEX_16000HZ = 0x01 << 2,
  LE_AUDIO_SAMPLE_RATE_INDEX_22050HZ = 0x01 << 3,
  LE_AUDIO_SAMPLE_RATE_INDEX_24000HZ = 0x01 << 4,
  LE_AUDIO_SAMPLE_RATE_INDEX_32000HZ = 0x01 << 5,
  LE_AUDIO_SAMPLE_RATE_INDEX_44100HZ = 0x01 << 6,
  LE_AUDIO_SAMPLE_RATE_INDEX_48000HZ = 0x01 << 7
  LE_AUDIO_SAMPLE_RATE_INDEX_48000HZ = 0x01 << 7,
  LE_AUDIO_SAMPLE_RATE_INDEX_88200HZ = 0x01 << 8,
  LE_AUDIO_SAMPLE_RATE_INDEX_96000HZ = 0x01 << 9,
  LE_AUDIO_SAMPLE_RATE_INDEX_176400HZ = 0x01 << 10,
  LE_AUDIO_SAMPLE_RATE_INDEX_192000HZ = 0x01 << 11,
  LE_AUDIO_SAMPLE_RATE_INDEX_384000HZ = 0x01 << 12
} btle_audio_sample_rate_index_t;

typedef enum {
@@ -162,9 +169,15 @@ typedef struct {
      case LE_AUDIO_SAMPLE_RATE_INDEX_8000HZ:
        sample_rate_str = "8000 hz";
        break;
      case LE_AUDIO_SAMPLE_RATE_INDEX_11025HZ:
        sample_rate_str = "11025 hz";
        break;
      case LE_AUDIO_SAMPLE_RATE_INDEX_16000HZ:
        sample_rate_str = "16000 hz";
        break;
      case LE_AUDIO_SAMPLE_RATE_INDEX_22050HZ:
        sample_rate_str = "22050 hz";
        break;
      case LE_AUDIO_SAMPLE_RATE_INDEX_24000HZ:
        sample_rate_str = "24000 hz";
        break;
@@ -177,6 +190,21 @@ typedef struct {
      case LE_AUDIO_SAMPLE_RATE_INDEX_48000HZ:
        sample_rate_str = "48000 hz";
        break;
      case LE_AUDIO_SAMPLE_RATE_INDEX_88200HZ:
        sample_rate_str = "88200 hz";
        break;
      case LE_AUDIO_SAMPLE_RATE_INDEX_96000HZ:
        sample_rate_str = "96000 hz";
        break;
      case LE_AUDIO_SAMPLE_RATE_INDEX_176400HZ:
        sample_rate_str = "176400 hz";
        break;
      case LE_AUDIO_SAMPLE_RATE_INDEX_192000HZ:
        sample_rate_str = "192000 hz";
        break;
      case LE_AUDIO_SAMPLE_RATE_INDEX_384000HZ:
        sample_rate_str = "384000 hz";
        break;
      default:
        sample_rate_str =
            "Unknown LE sample rate " + std::to_string(sample_rate);