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

Commit 9478094d authored by jiangyao's avatar jiangyao Committed by will Jiang
Browse files

audio: optimize variable assignment method to reduce resource consumption



Avoid looping through each productStrategy to obtain its corresponding AttributesVector. Only obtain the variable when the conditions are met.

Test: N/A

Change-Id: I40332a1914406abb31c0cacf9f7b08247226019d
Signed-off-by: default avatarjiangyao <jiangyao@xiaomi.com>
parent 20024657
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -7146,7 +7146,6 @@ DeviceVector AudioPolicyManager::getNewOutputDevices(const sp<SwAudioOutputDescr

    for (const auto &productStrategy : mEngine->getOrderedProductStrategies()) {
        StreamTypeVector streams = mEngine->getStreamTypesForProductStrategy(productStrategy);
        auto attr = mEngine->getAllAttributesForProductStrategy(productStrategy).front();
        auto hasStreamActive = [&](auto stream) {
            return hasStream(streams, stream) && isStreamActive(stream, 0);
        };
@@ -7171,6 +7170,7 @@ DeviceVector AudioPolicyManager::getNewOutputDevices(const sp<SwAudioOutputDescr
                mOutputs.isStrategyActiveOnSameModule(productStrategy, outputDesc))) {
            // Retrieval of devices for voice DL is done on primary output profile, cannot
            // check the route (would force modifying configuration file for this profile)
            auto attr = mEngine->getAllAttributesForProductStrategy(productStrategy).front();
            devices = mEngine->getOutputDevicesForAttributes(attr, nullptr, fromCache);
            break;
        }