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

Commit 284808cf authored by Eric Laurent's avatar Eric Laurent Committed by Automerger Merge Worker
Browse files

Merge "audio policy: LE audio broadcast routing policy" into tm-dev am: 499caa57 am: f72483c3

parents 5da42c4b f72483c3
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -70,6 +70,13 @@ const DeviceTypeSet& getAudioDeviceOutAllBleSet() {
    return audioDeviceOutAllBleSet;
    return audioDeviceOutAllBleSet;
}
}


const DeviceTypeSet& getAudioDeviceOutLeAudioUnicastSet() {
    static const DeviceTypeSet audioDeviceOutLeAudioUnicastSet = DeviceTypeSet(
            std::begin(AUDIO_DEVICE_OUT_BLE_UNICAST_ARRAY),
            std::end(AUDIO_DEVICE_OUT_BLE_UNICAST_ARRAY));
    return audioDeviceOutLeAudioUnicastSet;
}

std::string deviceTypesToString(const DeviceTypeSet &deviceTypes) {
std::string deviceTypesToString(const DeviceTypeSet &deviceTypes) {
    if (deviceTypes.empty()) {
    if (deviceTypes.empty()) {
        return "Empty device types";
        return "Empty device types";
+1 −0
Original line number Original line Diff line number Diff line
@@ -41,6 +41,7 @@ const DeviceTypeSet& getAudioDeviceOutAllUsbSet();
const DeviceTypeSet& getAudioDeviceInAllSet();
const DeviceTypeSet& getAudioDeviceInAllSet();
const DeviceTypeSet& getAudioDeviceInAllUsbSet();
const DeviceTypeSet& getAudioDeviceInAllUsbSet();
const DeviceTypeSet& getAudioDeviceOutAllBleSet();
const DeviceTypeSet& getAudioDeviceOutAllBleSet();
const DeviceTypeSet& getAudioDeviceOutLeAudioUnicastSet();


template<typename T>
template<typename T>
static std::vector<T> Intersection(const std::set<T>& a, const std::set<T>& b) {
static std::vector<T> Intersection(const std::set<T>& a, const std::set<T>& b) {
+13 −0
Original line number Original line Diff line number Diff line
@@ -517,6 +517,14 @@ public:
                                      const sp<SwAudioOutputDescriptor>& desc,
                                      const sp<SwAudioOutputDescriptor>& desc,
                                      uint32_t inPastMs = 0, nsecs_t sysTime = 0) const;
                                      uint32_t inPastMs = 0, nsecs_t sysTime = 0) const;


    /**
     * @brief isStrategyActive checks if the given strategy is active
     * on the given output
     * @param ps product strategy to be checked upon activity status
     * @return true if an output following the strategy is active, false otherwise
     */
    bool isStrategyActive(product_strategy_t ps) const;

    /**
    /**
     * @brief clearSessionRoutesForDevice: when a device is disconnected, and if this device has
     * @brief clearSessionRoutesForDevice: when a device is disconnected, and if this device has
     * been chosen as the preferred device by any client, the policy manager shall
     * been chosen as the preferred device by any client, the policy manager shall
@@ -562,6 +570,11 @@ public:


    sp<SwAudioOutputDescriptor> getOutputForClient(audio_port_handle_t portId);
    sp<SwAudioOutputDescriptor> getOutputForClient(audio_port_handle_t portId);


    /**
     * return whether any output is active and routed to any of the specified devices
     */
    bool isAnyDeviceTypeActive(const DeviceTypeSet& deviceTypes) const;

    void dump(String8 *dst) const;
    void dump(String8 *dst) const;
};
};


+20 −0
Original line number Original line Diff line number Diff line
@@ -841,6 +841,16 @@ bool SwAudioOutputCollection::isStrategyActiveOnSameModule(product_strategy_t ps
    return false;
    return false;
}
}


bool SwAudioOutputCollection::isStrategyActive(product_strategy_t ps) const
{
    for (size_t i = 0; i < size(); i++) {
        if (valueAt(i)->isStrategyActive(ps)) {
            return true;
        }
    }
    return false;
}

audio_io_handle_t SwAudioOutputCollection::getA2dpOutput() const
audio_io_handle_t SwAudioOutputCollection::getA2dpOutput() const
{
{
    for (size_t i = 0; i < size(); i++) {
    for (size_t i = 0; i < size(); i++) {
@@ -916,6 +926,16 @@ void SwAudioOutputCollection::clearSessionRoutesForDevice(
        }
        }
    }
    }
}
}
bool SwAudioOutputCollection::isAnyDeviceTypeActive(const DeviceTypeSet& deviceTypes) const {
    for (size_t i = 0; i < size(); i++) {
        const sp<SwAudioOutputDescriptor> outputDesc = valueAt(i);
        if (outputDesc->isActive()
                && outputDesc->devices().containsDeviceAmongTypes(deviceTypes)) {
            return true;
        }
    }
    return false;
}


void SwAudioOutputCollection::dump(String8 *dst) const
void SwAudioOutputCollection::dump(String8 *dst) const
{
{
+4 −1
Original line number Original line Diff line number Diff line
@@ -72,9 +72,12 @@ status_t EngineBase::setDeviceConnectionState(const sp<DeviceDescriptor> devDesc
{
{
    audio_devices_t deviceType = devDesc->type();
    audio_devices_t deviceType = devDesc->type();
    if ((deviceType != AUDIO_DEVICE_NONE) && audio_is_output_device(deviceType)
    if ((deviceType != AUDIO_DEVICE_NONE) && audio_is_output_device(deviceType)
            && deviceType != AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET) {
            && deviceType != AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET
            && deviceType != AUDIO_DEVICE_OUT_BLE_BROADCAST) {
        // USB dock does not follow the rule of last removable device connected wins.
        // USB dock does not follow the rule of last removable device connected wins.
        // It is only used if no removable device is connected or if set as preferred device
        // It is only used if no removable device is connected or if set as preferred device
        // LE audio broadcast device has a specific policy depending on active strategies and
        // devices and does not follow the rule of last connected removable device.
        mLastRemovableMediaDevices.setRemovableMediaDevices(devDesc, state);
        mLastRemovableMediaDevices.setRemovableMediaDevices(devDesc, state);
    }
    }


Loading