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

Commit 6f52ff9e authored by Francois Gaffie's avatar Francois Gaffie Committed by Eric Laurent
Browse files

[BUG] audiopolicy: engineconfigurable: prevent illegal map access



If any request to get OutputDevice for a given attributes is performed
before the cache has been initalized, an illegal access to the vector
happens.
This CL fixes by returning empty device vector when cache is empty.

Test: build & boot configurable engine target & basic audio

Signed-off-by: default avatarFrancois Gaffie <francois.gaffie@renault.com>
Change-Id: I1371765401441732319be56a9cae6fbf3c5cc2bf
parent 9c9bafff
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -299,8 +299,13 @@ DeviceVector Engine::getOutputDevicesForAttributes(const audio_attributes_t &att
    if (device != nullptr) {
        return DeviceVector(device);
    }
    return fromCache? getCachedDevices(strategy) : getDevicesForProductStrategy(strategy);
}

    return fromCache? mDevicesForStrategies.at(strategy) : getDevicesForProductStrategy(strategy);
DeviceVector Engine::getCachedDevices(product_strategy_t ps) const
{
    return mDevicesForStrategies.find(ps) != mDevicesForStrategies.end() ?
                mDevicesForStrategies.at(ps) : DeviceVector{};
}

DeviceVector Engine::getOutputDevicesForStream(audio_stream_type_t stream, bool fromCache) const
+1 −0
Original line number Diff line number Diff line
@@ -126,6 +126,7 @@ private:
    status_t loadAudioPolicyEngineConfig();

    DeviceVector getDevicesForProductStrategy(product_strategy_t strategy) const;
    DeviceVector getCachedDevices(product_strategy_t ps) const;

    /**
     * Policy Parameter Manager hidden through a wrapper.