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

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

Merge "Do not use disabled devices when getting output device."

parents 39b00717 d0a8d6f0
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -463,7 +463,7 @@ DeviceVector Engine::getDevicesForStrategyInt(legacy_strategy strategy,
    }

    if (devices.isEmpty()) {
        ALOGV("%s no device found for strategy %d", __func__, strategy);
        ALOGI("%s no device found for strategy %d", __func__, strategy);
        sp<DeviceDescriptor> defaultOutputDevice = getApmObserver()->getDefaultOutputDevice();
        if (defaultOutputDevice != nullptr) {
            devices.add(defaultOutputDevice);
@@ -699,6 +699,18 @@ DeviceVector Engine::getPreferredAvailableDevicesForProductStrategy(
    return preferredAvailableDevVec;
}

DeviceVector Engine::getDisabledDevicesForProductStrategy(
        const DeviceVector &availableOutputDevices, product_strategy_t strategy) const {
    DeviceVector disabledDevices = {};
    AudioDeviceTypeAddrVector disabledDevicesTypeAddr;
    const status_t status = getDevicesForRoleAndStrategy(
            strategy, DEVICE_ROLE_DISABLED, disabledDevicesTypeAddr);
    if (status == NO_ERROR) {
        disabledDevices =
                availableOutputDevices.getDevicesFromDeviceTypeAddrVec(disabledDevicesTypeAddr);
    }
    return disabledDevices;
}

DeviceVector Engine::getDevicesForProductStrategy(product_strategy_t strategy) const {
    const SwAudioOutputCollection& outputs = getApmObserver()->getOutputs();
@@ -722,6 +734,11 @@ DeviceVector Engine::getDevicesForProductStrategy(product_strategy_t strategy) c
        return preferredAvailableDevVec;
    }

    // Remove all disabled devices from the available device list.
    DeviceVector disabledDevVec =
            getDisabledDevicesForProductStrategy(availableOutputDevices, strategy);
    availableOutputDevices.remove(disabledDevVec);

    return getDevicesForStrategyInt(legacyStrategy,
                                    availableOutputDevices,
                                    outputs);
+2 −0
Original line number Diff line number Diff line
@@ -96,6 +96,8 @@ private:
        const DeviceVector& availableOutputDevices, legacy_strategy legacyStrategy) const;
    DeviceVector getPreferredAvailableDevicesForProductStrategy(
        const DeviceVector& availableOutputDevices, product_strategy_t strategy) const;
    DeviceVector getDisabledDevicesForProductStrategy(
        const DeviceVector& availableOutputDevices, product_strategy_t strategy) const;

    DeviceStrategyMap mDevicesForStrategies;