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

Commit 433e8a27 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Revert "Return DeviceDescriptor or DeviceVector in Engine.""

parents 28355761 bad450e5
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
@@ -255,6 +255,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());
        }
@@ -272,38 +273,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
@@ -73,14 +73,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;