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

Commit 663c4123 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Allow AudioAttributes tags to route calibration to FlexConnect...

Merge "Allow AudioAttributes tags to route calibration to FlexConnect ECHO_REFERENCE" into main am: aaafa175 am: e008c7c6

Original change: https://android-review.googlesource.com/c/platform/frameworks/av/+/3440161



Change-Id: I0be0d633ed15a744928e38ab9b5964866cd39aa3
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents f8039df2 e008c7c6
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -157,7 +157,8 @@ static inline bool apm_audio_out_device_distinguishes_on_address(audio_devices_t
static inline bool apm_audio_in_device_distinguishes_on_address(audio_devices_t device)
{
    return device == AUDIO_DEVICE_IN_REMOTE_SUBMIX ||
           device == AUDIO_DEVICE_IN_BUS;
           device == AUDIO_DEVICE_IN_BUS ||
           device == AUDIO_DEVICE_IN_ECHO_REFERENCE;
}

/**
+3 −0
Original line number Diff line number Diff line
@@ -235,6 +235,9 @@ protected:
     */
    virtual DeviceVector getDevicesForProductStrategy(product_strategy_t strategy) const = 0;

    sp<DeviceDescriptor> getInputDeviceForEchoRef(const audio_attributes_t &attr,
            const DeviceVector &availableInputDevices) const;

    DeviceStrategyMap mDevicesForStrategies;
};

+35 −0
Original line number Diff line number Diff line
@@ -798,6 +798,41 @@ DeviceVector EngineBase::getDisabledDevicesForProductStrategy(
    return disabledDevices;
}

sp<DeviceDescriptor> EngineBase::getInputDeviceForEchoRef(const audio_attributes_t &attr,
            const DeviceVector &availableInputDevices) const
{
    // get the first input device whose address matches a tag

    std::string tags { attr.tags }; // tags separate by ';'
    std::size_t posBegin = 0; // first index of current tag, inclusive
    std::size_t posEnd; // last index of current tag, exclusive

    while (posBegin < tags.size()) {
        // ';' is used as the delimiter of tags
        // find the first delimiter after posBegin
        posEnd = tags.find(';', posBegin);

        std::string tag;

        if (posEnd == std::string::npos) { // no more delimiter found
            tag = tags.substr(posBegin); // last tag
        } else {
            // get next tag
            tag = tags.substr(posBegin, posEnd - posBegin);
        }
        // get the input device whose address matches the tag
        sp<DeviceDescriptor> device = availableInputDevices.getDevice(
                AUDIO_DEVICE_IN_ECHO_REFERENCE, String8(tag.c_str()), AUDIO_FORMAT_DEFAULT);
        if (device != nullptr) {
            return device;
        }

        // update posBegin for next tag
        posBegin = posEnd + 1;
    }
    return nullptr;
}

void EngineBase::dumpCapturePresetDevicesRoleMap(String8 *dst, int spaces) const
{
    dst->appendFormat("\n%*sDevice role per capture preset dump:", spaces, "");
+8 −0
Original line number Diff line number Diff line
@@ -500,6 +500,14 @@ sp<DeviceDescriptor> Engine::getInputDeviceForAttributes(const audio_attributes_

    audio_devices_t deviceType = getPropertyForKey<audio_devices_t, audio_source_t>(attr.source);

    if (deviceType == AUDIO_DEVICE_IN_ECHO_REFERENCE) {
        device = getInputDeviceForEchoRef(attr, availableInputDevices);
        if (device != nullptr) {
            return device;
        }
    }


    if (audio_is_remote_submix_device(deviceType)) {
        address = "0";
        std::size_t pos;
+8 −0
Original line number Diff line number Diff line
@@ -900,6 +900,14 @@ sp<DeviceDescriptor> Engine::getInputDeviceForAttributes(const audio_attributes_
    }

    device = getDeviceForInputSource(attr.source);

    if (device->type() == AUDIO_DEVICE_IN_ECHO_REFERENCE) {
        sp<DeviceDescriptor> device2 = getInputDeviceForEchoRef(attr, availableInputDevices);
        if (device2 != nullptr) {
            return device2;
        }
    }

    if (device == nullptr || !audio_is_remote_submix_device(device->type())) {
        // Return immediately if the device is null or it is not a remote submix device.
        return device;