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

Commit c86a3e10 authored by Eric Laurent's avatar Eric Laurent Committed by Android Build Cherrypicker Worker
Browse files

Audio Policy Engine: remove recurrent warning in getDevicesForStrategyInt()

The legacy routing strategy STRATEGY_PATCH is reserved for internal use
when creating software audio patches and should never be passed to
getDevicesForStrategyInt() to get an output device.
Fixed call sites where this should happen.
Did not getDevicesForStrategyInt() because this method is supposed to
always return a valid device.

Test: basic manual audio regression tests
Flag: EXEMPT, bug fix.
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:b0d986eaf3507b1f4e231d1ab11cc1901ae34cf5)
Merged-In: Ibd3998b461468bc52e0b23711a7aa97e621b1f5b
Change-Id: Ibd3998b461468bc52e0b23711a7aa97e621b1f5b
parent 2dfaebcf
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -92,6 +92,10 @@ public:

    bool isDefault() const;

    bool isPatchStrategy() const {
        return getVolumeGroupForStreamType(AUDIO_STREAM_PATCH) != VOLUME_GROUP_NONE;
    }

    void dump(String8 *dst, int spaces = 0) const;

private:
+9 −0
Original line number Diff line number Diff line
@@ -311,6 +311,9 @@ StrategyVector EngineBase::getOrderedProductStrategies() const
    }
    StrategyVector orderedStrategies;
    for (const auto &iter : strategies) {
        if (iter.second->isPatchStrategy()) {
            continue;
        }
        orderedStrategies.push_back(iter.second->getId());
    }
    return orderedStrategies;
@@ -742,6 +745,9 @@ void EngineBase::initializeDeviceSelectionCache() {
    auto defaultDevices = DeviceVector(getApmObserver()->getDefaultOutputDevice());
    for (const auto &iter : getProductStrategies()) {
        const auto &strategy = iter.second;
        if (strategy->isPatchStrategy()) {
            continue;
        }
        mDevicesForStrategies[strategy->getId()] = defaultDevices;
        setStrategyDevices(strategy, defaultDevices);
    }
@@ -750,6 +756,9 @@ void EngineBase::initializeDeviceSelectionCache() {
void EngineBase::updateDeviceSelectionCache() {
    for (const auto &iter : getProductStrategies()) {
        const auto& strategy = iter.second;
        if (strategy->isPatchStrategy()) {
            continue;
        }
        auto devices = getDevicesForProductStrategy(strategy->getId());
        mDevicesForStrategies[strategy->getId()] = devices;
        setStrategyDevices(strategy, devices);
+5 −0
Original line number Diff line number Diff line
@@ -3496,6 +3496,11 @@ status_t AudioPolicyManager::setVolumeIndexForAttributes(const audio_attributes_
    }
    ALOGV("%s: group %d matching with %s index %d",
            __FUNCTION__, group, toString(attributes).c_str(), index);
    if (mEngine->getStreamTypeForAttributes(attributes) == AUDIO_STREAM_PATCH) {
        ALOGV("%s: cannot change volume for PATCH stream, attrs: %s",
                __FUNCTION__, toString(attributes).c_str());
        return NO_ERROR;
    }
    status_t status = NO_ERROR;
    IVolumeCurves &curves = getVolumeCurves(attributes);
    VolumeSource vs = toVolumeSource(group);