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

Commit bad450e5 authored by Jiabin Huang's avatar Jiabin Huang
Browse files

Revert "Return DeviceDescriptor or DeviceVector in Engine."

This reverts commit 6cb004ae.

Reason for revert: This break telephony call

Bug: 138866657
Change-Id: Ie288c13a152491bf4df99595d30b80d9122b970c
parent 6cb004ae
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -116,13 +116,6 @@ public:
    DeviceVector getDevicesFromHwModule(audio_module_handle_t moduleHandle) const;
    audio_devices_t getDeviceTypesFromHwModule(audio_module_handle_t moduleHandle) const;

    DeviceVector getFirstDevicesFromTypes(std::vector<audio_devices_t> orderedTypes) const;
    sp<DeviceDescriptor> getFirstExistingDevice(std::vector<audio_devices_t> orderedTypes) const;

    // If there are devices with the given type and the devices to add is not empty,
    // remove all the devices with the given type and add all the devices to add.
    void replaceDevicesByType(audio_devices_t typeToRemove, const DeviceVector &devicesToAdd);

    bool contains(const sp<DeviceDescriptor>& item) const { return indexOf(item) >= 0; }

    /**
+1 −32
Original line number Diff line number Diff line
@@ -256,6 +256,7 @@ DeviceVector DeviceVector::getDevicesFromTypeMask(audio_devices_t type) const
        audio_devices_t curType = itemAt(i)->type() & ~AUDIO_DEVICE_BIT_IN;
        if ((isOutput == curIsOutput) && ((type & curType) != 0)) {
            devices.add(itemAt(i));
            type &= ~curType;
            ALOGV("DeviceVector::%s() for type %08x found %p",
                    __func__, itemAt(i)->type(), itemAt(i).get());
        }
@@ -273,38 +274,6 @@ sp<DeviceDescriptor> DeviceVector::getDeviceFromTagName(const String8 &tagName)
    return nullptr;
}

DeviceVector DeviceVector::getFirstDevicesFromTypes(
        std::vector<audio_devices_t> orderedTypes) const
{
    DeviceVector devices;
    for (auto deviceType : orderedTypes) {
        if (!(devices = getDevicesFromTypeMask(deviceType)).isEmpty()) {
            break;
        }
    }
    return devices;
}

sp<DeviceDescriptor> DeviceVector::getFirstExistingDevice(
        std::vector<audio_devices_t> orderedTypes) const {
    sp<DeviceDescriptor> device;
    for (auto deviceType : orderedTypes) {
        if ((device = getDevice(deviceType, String8(""), AUDIO_FORMAT_DEFAULT)) != nullptr) {
            break;
        }
    }
    return device;
}

void DeviceVector::replaceDevicesByType(
        audio_devices_t typeToRemove, const DeviceVector &devicesToAdd) {
    DeviceVector devicesToRemove = getDevicesFromTypeMask(typeToRemove);
    if (!devicesToRemove.isEmpty() && !devicesToAdd.isEmpty()) {
        remove(devicesToRemove);
        add(devicesToAdd);
    }
}

void DeviceVector::dump(String8 *dst, const String8 &tag, int spaces, bool verbose) const
{
    if (isEmpty()) {
+279 −217

File changed.

Preview size limit exceeded, changes collapsed.

+6 −5
Original line number Diff line number Diff line
@@ -74,14 +74,15 @@ private:

    status_t setDefaultDevice(audio_devices_t device);

    DeviceVector getDevicesForStrategyInt(legacy_strategy strategy,
    audio_devices_t getDeviceForStrategyInt(legacy_strategy strategy,
                                            DeviceVector availableOutputDevices,
                                            DeviceVector availableInputDevices,
                                          const SwAudioOutputCollection &outputs) const;
                                            const SwAudioOutputCollection &outputs,
                                            uint32_t outputDeviceTypesToIgnore) const;

    DeviceVector getDevicesForProductStrategy(product_strategy_t strategy) const;

    sp<DeviceDescriptor> getDeviceForInputSource(audio_source_t inputSource) const;
    audio_devices_t getDeviceForInputSource(audio_source_t inputSource) const;

    DeviceStrategyMap mDevicesForStrategies;