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

Commit ee1d5e19 authored by Eric Laurent's avatar Eric Laurent Committed by Android (Google) Code Review
Browse files

Merge changes I9eb9de96,Id1e037af

* changes:
  audiopolicy: fixup! audiopolicy: HW Bridge Sink matching rule
  Revert "Revert "audiopolicy: HW Bridge Sink matching rule""
parents d24a4c8e 2725f332
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -65,6 +65,9 @@ public:

    bool supportsFormat(audio_format_t format);

    void setDynamic() { mIsDynamic = true; }
    bool isDynamic() const { return mIsDynamic; }

    // PolicyAudioPortConfig
    virtual sp<PolicyAudioPort> getPolicyAudioPort() const {
        return static_cast<PolicyAudioPort*>(const_cast<DeviceDescriptor*>(this));
@@ -105,6 +108,8 @@ private:
    std::string mTagName; // Unique human readable identifier for a device port found in conf file.
    FormatVector        mEncodedFormats;
    audio_format_t      mCurrentEncodedFormat;
    bool                mIsDynamic = false;
    const std::string   mDeclaredAddress; // Original device address
};

class DeviceVector : public SortedVector<sp<DeviceDescriptor> >
+14 −1
Original line number Diff line number Diff line
@@ -52,8 +52,12 @@ public:
        devices.merge(mDynamicDevices);
        return devices;
    }
    std::string getTagForDevice(audio_devices_t device,
                                const String8 &address = String8(),
                                audio_format_t codec = AUDIO_FORMAT_DEFAULT);
    void addDynamicDevice(const sp<DeviceDescriptor> &device)
    {
        device->setDynamic();
        mDynamicDevices.add(device);
    }

@@ -131,8 +135,17 @@ class HwModuleCollection : public Vector<sp<HwModule> >
public:
    sp<HwModule> getModuleFromName(const char *name) const;

    /**
     * @brief getModuleForDeviceType try to get a device from type / format on all modules
     * @param device type to consider
     * @param encodedFormat to consider
     * @param[out] tagName if not null, if a matching device is found, will return the tagName
     * of original device from XML file so that audio routes matchin rules work.
     * @return valid module if considered device found, nullptr otherwise.
     */
    sp<HwModule> getModuleForDeviceType(audio_devices_t device,
                                        audio_format_t encodedFormat) const;
                                        audio_format_t encodedFormat,
                                        std::string *tagName = nullptr) const;

    sp<HwModule> getModuleForDevice(const sp<DeviceDescriptor> &device,
                                    audio_format_t encodedFormat) const;
+19 −0
Original line number Diff line number Diff line
@@ -111,6 +111,19 @@ public:
               (!areOutputDevices || devicesSupportEncodedFormats(deviceTypes));
    }

    /**
     * @brief getTag
     * @param deviceTypes to be considered
     * @return tagName of first matching device for the considered types, empty string otherwise.
     */
    std::string getTag(const DeviceTypeSet& deviceTypes) const
    {
        if (supportsDeviceTypes(deviceTypes)) {
            return mSupportedDevices.getDevicesFromTypes(deviceTypes).itemAt(0)->getTagName();
        }
        return {};
    }

    /**
     * @brief supportsDevice
     * @param device to be checked against
@@ -152,6 +165,12 @@ public:
    }
    void removeSupportedDevice(const sp<DeviceDescriptor> &device)
    {
        ssize_t ret = mSupportedDevices.indexOf(device);
        if (ret >= 0 && !mSupportedDevices.itemAt(ret)->isDynamic()) {
            // devices equality checks only type, address, name and format
            // Prevents from removing non dynamically added devices
            return;
        }
        mSupportedDevices.remove(device);
    }
    void setSupportedDevices(const DeviceVector &devices)
+5 −0
Original line number Diff line number Diff line
@@ -42,6 +42,11 @@ public:

    virtual const std::string getTagName() const = 0;

    bool equals(const sp<PolicyAudioPort> &right) const
    {
        return getTagName() == right->getTagName();
    }

    virtual sp<AudioPort> asAudioPort() const = 0;

    virtual void setFlags(uint32_t flags)
+2 −2
Original line number Diff line number Diff line
@@ -39,12 +39,12 @@ void AudioRoute::dump(String8 *dst, int spaces) const
bool AudioRoute::supportsPatch(const sp<PolicyAudioPort> &srcPort,
                               const sp<PolicyAudioPort> &dstPort) const
{
    if (mSink == 0 || dstPort == 0 || dstPort != mSink) {
    if (mSink == 0 || dstPort == 0 || !dstPort->equals(mSink)) {
        return false;
    }
    ALOGV("%s: sinks %s matching", __FUNCTION__, mSink->getTagName().c_str());
    for (const auto &sourcePort : mSources) {
        if (sourcePort == srcPort) {
        if (sourcePort->equals(srcPort)) {
            ALOGV("%s: sources %s matching", __FUNCTION__, sourcePort->getTagName().c_str());
            return true;
        }
Loading