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

Commit c2b14c2d authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 12704382 from 2f9ad130 to 25Q1-release

Change-Id: I718573b0d06ff278bc705b5fd37dfd790fd4044b
parents e710c2ef 2f9ad130
Loading
Loading
Loading
Loading
+234 −6
Original line number Diff line number Diff line
@@ -895,6 +895,180 @@ enum {
};
typedef uint32_t aaudio_channel_mask_t;

// The values are copied from JAVA SDK device types defined in android/media/AudioDeviceInfo.java
// When a new value is added, it should be added here and handled by the conversion at
// AAudioConvert_aaudioToAndroidDeviceType.
typedef enum AAudio_DeviceType : int32_t {
    /**
     * A device type describing the attached earphone speaker.
     */
    AAUDIO_DEVICE_BUILTIN_EARPIECE = 1,

    /**
     * A device type describing the speaker system (i.e. a mono speaker or stereo speakers) built
     * in a device.
     */
    AAUDIO_DEVICE_BUILTIN_SPEAKER = 2,

    /**
     * A device type describing a headset, which is the combination of a headphones and microphone.
     */
    AAUDIO_DEVICE_WIRED_HEADSET = 3,

    /**
     * A device type describing a pair of wired headphones.
     */
    AAUDIO_DEVICE_WIRED_HEADPHONES = 4,

    /**
     * A device type describing an analog line-level connection.
     */
    AAUDIO_DEVICE_LINE_ANALOG = 5,

    /**
     * A device type describing a digital line connection (e.g. SPDIF).
     */
    AAUDIO_DEVICE_LINE_DIGITAL = 6,

    /**
     * A device type describing a Bluetooth device typically used for telephony.
     */
    AAUDIO_DEVICE_BLUETOOTH_SCO = 7,

    /**
     * A device type describing a Bluetooth device supporting the A2DP profile.
     */
    AAUDIO_DEVICE_BLUETOOTH_A2DP = 8,

    /**
     * A device type describing an HDMI connection .
     */
    AAUDIO_DEVICE_HDMI = 9,

    /**
     * A device type describing the Audio Return Channel of an HDMI connection.
     */
    AAUDIO_DEVICE_HDMI_ARC = 10,

    /**
     * A device type describing a USB audio device.
     */
    AAUDIO_DEVICE_USB_DEVICE = 11,

    /**
     * A device type describing a USB audio device in accessory mode.
     */
    AAUDIO_DEVICE_USB_ACCESSORY = 12,

    /**
     * A device type describing the audio device associated with a dock.
     * Starting at API 34, this device type only represents digital docks, while docks with an
     * analog connection are represented with {@link #AAUDIO_DEVICE_DOCK_ANALOG}.
     */
    AAUDIO_DEVICE_DOCK = 13,

    /**
     * A device type associated with the transmission of audio signals over FM.
     */
    AAUDIO_DEVICE_FM = 14,

    /**
     * A device type describing the microphone(s) built in a device.
     */
    AAUDIO_DEVICE_BUILTIN_MIC = 15,

    /**
     * A device type for accessing the audio content transmitted over FM.
     */
    AAUDIO_DEVICE_FM_TUNER = 16,

    /**
     * A device type for accessing the audio content transmitted over the TV tuner system.
     */
    AAUDIO_DEVICE_TV_TUNER = 17,

    /**
     * A device type describing the transmission of audio signals over the telephony network.
     */
    AAUDIO_DEVICE_TELEPHONY = 18,

    /**
     * A device type describing the auxiliary line-level connectors.
     */
    AAUDIO_DEVICE_AUX_LINE = 19,

    /**
     * A device type connected over IP.
     */
    AAUDIO_DEVICE_IP = 20,

    /**
     * A type-agnostic device used for communication with external audio systems.
     */
    AAUDIO_DEVICE_BUS = 21,

    /**
     * A device type describing a USB audio headset.
     */
    AAUDIO_DEVICE_USB_HEADSET = 22,

    /**
     * A device type describing a Hearing Aid.
     */
    AAUDIO_DEVICE_HEARING_AID = 23,

    /**
     * A device type describing the speaker system (i.e. a mono speaker or stereo speakers) built
     * in a device, that is specifically tuned for outputting sounds like notifications and alarms
     * (i.e. sounds the user couldn't necessarily anticipate).
     * <p>Note that this physical audio device may be the same as {@link #TYPE_BUILTIN_SPEAKER}
     * but is driven differently to safely accommodate the different use case.</p>
     */
    AAUDIO_DEVICE_BUILTIN_SPEAKER_SAFE = 24,

    /**
     * A device type for rerouting audio within the Android framework between mixes and
     * system applications.
     */
    AAUDIO_DEVICE_REMOTE_SUBMIX = 25,
    /**
     * A device type describing a Bluetooth Low Energy (BLE) audio headset or headphones.
     * Headphones are grouped with headsets when the device is a sink:
     * the features of headsets and headphones with regard to playback are the same.
     */
    AAUDIO_DEVICE_BLE_HEADSET = 26,

    /**
     * A device type describing a Bluetooth Low Energy (BLE) audio speaker.
     */
    AAUDIO_DEVICE_BLE_SPEAKER = 27,

    /**
     * A device type describing an Echo Canceller loopback Reference.
     * This device is only used when capturing with MediaRecorder.AudioSource.ECHO_REFERENCE,
     * which requires privileged permission
     * {@link android.Manifest.permission#CAPTURE_AUDIO_OUTPUT}.
     *
     * Note that this is not exposed as it is a system API that requires privileged permission.
     */
    // AAUDIO_DEVICE_ECHO_REFERENCE = 28,

    /**
     * A device type describing the Enhanced Audio Return Channel of an HDMI connection.
     */
    AAUDIO_DEVICE_HDMI_EARC = 29,

    /**
     * A device type describing a Bluetooth Low Energy (BLE) broadcast group.
     */
    AAUDIO_DEVICE_BLE_BROADCAST = 30,

    /**
     * A device type describing the audio device associated with a dock using an analog connection.
     */
    AAUDIO_DEVICE_DOCK_ANALOG = 31
} AAudio_DeviceType;

typedef struct AAudioStreamStruct         AAudioStream;
typedef struct AAudioStreamBuilderStruct  AAudioStreamBuilder;

@@ -1998,18 +2172,17 @@ AAUDIO_API int32_t AAudioStream_getSamplesPerFrame(AAudioStream* _Nonnull stream
 * Available since API level 26.
 *
 * @param stream reference provided by AAudioStreamBuilder_openStream()
 * @return actual device id. If there are multiple device ids used, the first device picked by
 *         the audio policy engine will be returned.
 * @return actual device id. If there are multiple device ids used,
 *         this will return the first device id from AAudioStream_getDeviceIds().
 */
AAUDIO_API int32_t AAudioStream_getDeviceId(AAudioStream* _Nonnull stream) __INTRODUCED_IN(26);

/**
 * Available since API level 36.
 *
 * Call this function after AAudioStreamBuilder_openStream().
 * This function will crash if stream is null.
 * An array of size 16 should generally be large enough to fit all device identifiers.
 *
 * Available since API level 36.
 *
 * @param stream reference provided by AAudioStreamBuilder_openStream().
 * @param ids reference to an array of ids.
 * @params numIds size allocated to the array of ids.
@@ -2022,7 +2195,7 @@ AAUDIO_API int32_t AAudioStream_getDeviceId(AAudioStream* _Nonnull stream) __INT
 *         Otherwise, if ids is null, return {@link #AAUDIO_ERROR_ILLEGAL_ARGUMENT}.
 */
AAUDIO_API aaudio_result_t AAudioStream_getDeviceIds(AAudioStream* _Nonnull stream,
        int32_t* _Nonnull ids, int32_t* _Nonnull numIds) __INTRODUCED_IN(36);
        int32_t* _Nullable ids, int32_t* _Nullable numIds) __INTRODUCED_IN(36);

/**
 * Available since API level 26.
@@ -2343,6 +2516,61 @@ AAUDIO_API int32_t AAudioStream_getOffloadPadding(AAudioStream* _Nonnull stream)
AAUDIO_API aaudio_result_t AAudioStream_setOffloadEndOfStream(AAudioStream* _Nonnull stream)
        __INTRODUCED_IN(36);

/************************************************************************************
 * Helper functions for AAudio MMAP.
 * AAudio MMAP data path uses a memory region that is shared between the hardware and
 * the audio software. The shared memory is referenced using a file descriptor that is
 * generated by the ALSA driver. Apps can read/write directly from/to the shared
 * memory, which helps improve the audio latency.
 ************************************************************************************/

/**
 * When the audio is played/recorded via AAudio MMAP data path, the apps can write to/read from
 * a shared memory that will also be accessed directly by hardware. That reduces the audio latency.
 * The following values are used to describe how AAudio MMAP is supported.
 */
enum {
    /**
     * AAudio MMAP is disabled and never used.
     */
    AAUDIO_POLICY_NEVER = 1,

    /**
     * AAudio MMAP support depends on device's availability. It will be used
     * when it is possible or fallback to the normal path, where the audio data
     * will be delivered via audio framework data pipeline.
     */
    AAUDIO_POLICY_AUTO,

    /**
     * AAudio MMAP must be used or fail.
     */
    AAUDIO_POLICY_ALWAYS
};
typedef int32_t aaudio_policy_t;

/**
 * Query how aaudio mmap is supported for the given device type.
 *
 * @param device device type
 * @param direction {@link AAUDIO_DIRECTION_OUTPUT} or {@link AAUDIO_DIRECTION_INPUT}
 * @return the mmap policy or {@link #AAUDIO_ERROR_ILLEGAL_ARGUMENT} if the device or direction
 *         is invalid or {@link #AAUDIO_ERROR_INTERNAL} if the audio HAL returns error.
 */
AAUDIO_API aaudio_policy_t AAudio_getPlatformMMapPolicy(
        AAudio_DeviceType device, aaudio_direction_t direction) __INTRODUCED_IN(36);

/**
 * Query how aaudio exclusive mmap is supported for the given device type.
 *
 * @param device device type
 * @param direction {@link AAUDIO_DIRECTION_OUTPUT} or {@link AAUDIO_DIRECTION_INPUT}
 * @return the mmap exclusive policy or or {@link #AAUDIO_ERROR_ILLEGAL_ARGUMENT} if the device
 *         or direction is invalid or {@link #AAUDIO_ERROR_INTERNAL} if the audio HAL returns error.
 */
AAUDIO_API aaudio_policy_t AAudio_getPlatformMMapExclusivePolicy(
        AAudio_DeviceType device, aaudio_direction_t direction) __INTRODUCED_IN(36);

#ifdef __cplusplus
}
#endif
+0 −219
Original line number Diff line number Diff line
@@ -31,225 +31,6 @@ extern "C" {
 * They may change or be removed at any time.
 ************************************************************************************/

/**
 * When the audio is played/recorded via AAudio MMAP data path, the apps can write to/read from
 * a shared memory that will also be accessed directly by hardware. That reduces the audio latency.
 * The following values are used to describe how AAudio MMAP is supported.
 */
enum {
    /**
     * AAudio MMAP is disabled and never used.
     */
    AAUDIO_POLICY_NEVER = 1,

    /**
     * AAudio MMAP support depends on device's availability. It will be used
     * when it is possible or fallback to the normal path, where the audio data
     * will be delivered via audio framework data pipeline.
     */
    AAUDIO_POLICY_AUTO,

    /**
     * AAudio MMAP must be used or fail.
     */
    AAUDIO_POLICY_ALWAYS
};
typedef int32_t aaudio_policy_t;

// The values are copied from JAVA SDK device types defined in android/media/AudioDeviceInfo.java
// When a new value is added, it should be added here and handled by the conversion at
// AAudioConvert_aaudioToAndroidDeviceType.
typedef enum AAudio_DeviceType : int32_t {
    /**
     * A device type describing the attached earphone speaker.
     */
    AAUDIO_DEVICE_BUILTIN_EARPIECE = 1,

    /**
     * A device type describing the speaker system (i.e. a mono speaker or stereo speakers) built
     * in a device.
     */
    AAUDIO_DEVICE_BUILTIN_SPEAKER = 2,

    /**
     * A device type describing a headset, which is the combination of a headphones and microphone.
     */
    AAUDIO_DEVICE_WIRED_HEADSET = 3,

    /**
     * A device type describing a pair of wired headphones.
     */
    AAUDIO_DEVICE_WIRED_HEADPHONES = 4,

    /**
     * A device type describing an analog line-level connection.
     */
    AAUDIO_DEVICE_LINE_ANALOG = 5,

    /**
     * A device type describing a digital line connection (e.g. SPDIF).
     */
    AAUDIO_DEVICE_LINE_DIGITAL = 6,

    /**
     * A device type describing a Bluetooth device typically used for telephony.
     */
    AAUDIO_DEVICE_BLUETOOTH_SCO = 7,

    /**
     * A device type describing a Bluetooth device supporting the A2DP profile.
     */
    AAUDIO_DEVICE_BLUETOOTH_A2DP = 8,

    /**
     * A device type describing an HDMI connection .
     */
    AAUDIO_DEVICE_HDMI = 9,

    /**
     * A device type describing the Audio Return Channel of an HDMI connection.
     */
    AAUDIO_DEVICE_HDMI_ARC = 10,

    /**
     * A device type describing a USB audio device.
     */
    AAUDIO_DEVICE_USB_DEVICE = 11,

    /**
     * A device type describing a USB audio device in accessory mode.
     */
    AAUDIO_DEVICE_USB_ACCESSORY = 12,

    /**
     * A device type describing the audio device associated with a dock.
     * Starting at API 34, this device type only represents digital docks, while docks with an
     * analog connection are represented with {@link #AAUDIO_DEVICE_DOCK_ANALOG}.
     */
    AAUDIO_DEVICE_DOCK = 13,

    /**
     * A device type associated with the transmission of audio signals over FM.
     */
    AAUDIO_DEVICE_FM = 14,

    /**
     * A device type describing the microphone(s) built in a device.
     */
    AAUDIO_DEVICE_BUILTIN_MIC = 15,

    /**
     * A device type for accessing the audio content transmitted over FM.
     */
    AAUDIO_DEVICE_FM_TUNER = 16,

    /**
     * A device type for accessing the audio content transmitted over the TV tuner system.
     */
    AAUDIO_DEVICE_TV_TUNER = 17,

    /**
     * A device type describing the transmission of audio signals over the telephony network.
     */
    AAUDIO_DEVICE_TELEPHONY = 18,

    /**
     * A device type describing the auxiliary line-level connectors.
     */
    AAUDIO_DEVICE_AUX_LINE = 19,

    /**
     * A device type connected over IP.
     */
    AAUDIO_DEVICE_IP = 20,

    /**
     * A type-agnostic device used for communication with external audio systems.
     */
    AAUDIO_DEVICE_BUS = 21,

    /**
     * A device type describing a USB audio headset.
     */
    AAUDIO_DEVICE_USB_HEADSET = 22,

    /**
     * A device type describing a Hearing Aid.
     */
    AAUDIO_DEVICE_HEARING_AID = 23,

    /**
     * A device type describing the speaker system (i.e. a mono speaker or stereo speakers) built
     * in a device, that is specifically tuned for outputting sounds like notifications and alarms
     * (i.e. sounds the user couldn't necessarily anticipate).
     * <p>Note that this physical audio device may be the same as {@link #TYPE_BUILTIN_SPEAKER}
     * but is driven differently to safely accommodate the different use case.</p>
     */
    AAUDIO_DEVICE_BUILTIN_SPEAKER_SAFE = 24,

    /**
     * A device type for rerouting audio within the Android framework between mixes and
     * system applications.
     */
    AAUDIO_DEVICE_REMOTE_SUBMIX = 25,
    /**
     * A device type describing a Bluetooth Low Energy (BLE) audio headset or headphones.
     * Headphones are grouped with headsets when the device is a sink:
     * the features of headsets and headphones with regard to playback are the same.
     */
    AAUDIO_DEVICE_BLE_HEADSET = 26,

    /**
     * A device type describing a Bluetooth Low Energy (BLE) audio speaker.
     */
    AAUDIO_DEVICE_BLE_SPEAKER = 27,

    /**
     * A device type describing an Echo Canceller loopback Reference.
     * This device is only used when capturing with MediaRecorder.AudioSource.ECHO_REFERENCE,
     * which requires privileged permission
     * {@link android.Manifest.permission#CAPTURE_AUDIO_OUTPUT}.
     *
     * Note that this is not exposed as it is a system API that requires privileged permission.
     */
    // AAUDIO_DEVICE_ECHO_REFERENCE = 28,

    /**
     * A device type describing the Enhanced Audio Return Channel of an HDMI connection.
     */
    AAUDIO_DEVICE_HDMI_EARC = 29,

    /**
     * A device type describing a Bluetooth Low Energy (BLE) broadcast group.
     */
    AAUDIO_DEVICE_BLE_BROADCAST = 30,

    /**
     * A device type describing the audio device associated with a dock using an analog connection.
     */
    AAUDIO_DEVICE_DOCK_ANALOG = 31
} AAudio_DeviceType;

/**
 * Query how aaudio mmap is supported for the given device type.
 *
 * @param device device type
 * @param direction {@link AAUDIO_DIRECTION_OUTPUT} or {@link AAUDIO_DIRECTION_INPUT}
 * @return the mmap policy or negative error
 */
AAUDIO_API aaudio_policy_t AAudio_getPlatformMMapPolicy(
        AAudio_DeviceType device, aaudio_direction_t direction) __INTRODUCED_IN(36);

/**
 * Query how aaudio exclusive mmap is supported for the given device type.
 *
 * @param device device type
 * @param direction {@link AAUDIO_DIRECTION_OUTPUT} or {@link AAUDIO_DIRECTION_INPUT}
 * @return the mmap exclusive policy or negative error
 */
AAUDIO_API aaudio_policy_t AAudio_getPlatformMMapExclusivePolicy(
        AAudio_DeviceType device, aaudio_direction_t direction) __INTRODUCED_IN(36);

/**
 * Control whether AAudioStreamBuilder_openStream() will use the new MMAP data path
 * or the older "Legacy" data path.
+0 −10
Original line number Diff line number Diff line
@@ -42,7 +42,6 @@
#include "fifo/FifoBuffer.h"
#include "utility/AudioClock.h"
#include <media/AidlConversion.h>
#include <com_android_media_aaudio.h>

#include "AudioStreamInternal.h"

@@ -197,15 +196,6 @@ aaudio_result_t AudioStreamInternal::open(const AudioStreamBuilder &builder) {
        setSampleRate(configurationOutput.getSampleRate());
    }

    if (!com::android::media::aaudio::sample_rate_conversion()) {
        if (getSampleRate() != getDeviceSampleRate()) {
            ALOGD("%s - skipping sample rate converter. SR = %d, Device SR = %d", __func__,
                    getSampleRate(), getDeviceSampleRate());
            result = AAUDIO_ERROR_INVALID_RATE;
            goto error;
        }
    }

    // Save device format so we can do format conversion and volume scaling together.
    setDeviceFormat(configurationOutput.getFormat());
    setDeviceSamplesPerFrame(configurationOutput.getSamplesPerFrame());
+33 −0
Original line number Diff line number Diff line
@@ -678,6 +678,28 @@ AImageReader::acquireLatestImage(/*out*/AImage** image, /*out*/int* acquireFence
    }
}

media_status_t
AImageReader::setUsage(uint64_t usage) {
    Mutex::Autolock _l(mLock);
    if (!mIsOpen || mBufferItemConsumer == nullptr) {
        ALOGE("not ready to perform setUsage()");
        return AMEDIA_ERROR_INVALID_PARAMETER;
    }
    if (mUsage == usage) {
        return AMEDIA_OK;
    }

    uint64_t halUsage = AHardwareBuffer_convertToGrallocUsageBits(mUsage);
    status_t ret = mBufferItemConsumer->setConsumerUsageBits(halUsage);
    if (ret != OK) {
        ALOGE("setConsumerUsageBits() failed %d", ret);
        return AMEDIA_ERROR_UNKNOWN;
    }
    mUsage = usage;
    mHalUsage = halUsage;
    return AMEDIA_OK;
}

static
media_status_t validateParameters(int32_t width, int32_t height, int32_t format,
                                  uint64_t usage, int32_t maxImages,
@@ -935,3 +957,14 @@ media_status_t AImageReader_setBufferRemovedListener(
    reader->setBufferRemovedListener(listener);
    return AMEDIA_OK;
}

EXPORT
media_status_t AImageReader_setUsage(
    AImageReader *reader, uint64_t usage) {
    ALOGV("%s", __FUNCTION__);
    if (reader == nullptr) {
        ALOGE("%s: invalid argument! reader %p", __FUNCTION__, reader);
        return AMEDIA_ERROR_INVALID_PARAMETER;
    }
    return reader->setUsage(usage);
}
+3 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include <inttypes.h>

#include <media/NdkImageReader.h>
#include <media-vndk/VndkImageReader.h>

#include <utils/List.h>
#include <utils/Mutex.h>
@@ -68,6 +69,7 @@ struct AImageReader : public RefBase {

    media_status_t setImageListener(AImageReader_ImageListener* listener);
    media_status_t setBufferRemovedListener(AImageReader_BufferRemovedListener* listener);
    media_status_t setUsage(uint64_t usage);

    media_status_t acquireNextImage(/*out*/AImage** image, /*out*/int* fenceFd);
    media_status_t acquireLatestImage(/*out*/AImage** image, /*out*/int* fenceFd);
@@ -121,7 +123,7 @@ struct AImageReader : public RefBase {
    const int32_t mWidth;
    const int32_t mHeight;
    int32_t mFormat;
    const uint64_t mUsage;  // AHARDWAREBUFFER_USAGE_* flags.
    uint64_t mUsage;  // AHARDWAREBUFFER_USAGE_* flags.
    const int32_t mMaxImages;

    // TODO(jwcai) Seems completely unused in AImageReader class.
Loading