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

Commit ef4726a4 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "audio: fix aidl strategy name mapping error" into main am: b1a24c4e am: ba028d56

parents b4bc8ea4 ba028d56
Loading
Loading
Loading
Loading
+24 −1
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include <string>
#include <string>
#include <vector>
#include <unordered_map>

#define LOG_TAG "APM::AudioPolicyEngine/Config"
//#define LOG_NDEBUG 0
@@ -51,6 +52,27 @@ static const char *const gReferenceAttributeName = "name";

namespace {

ConversionResult<std::string> aidl2legacy_AudioHalProductStrategy_ProductStrategyType(int id) {
    using AudioProductStrategyType = media::audio::common::AudioProductStrategyType;

#define STRATEGY_ENTRY(name) {static_cast<int>(AudioProductStrategyType::name), "STRATEGY_" #name}
    static const std::unordered_map<int, std::string> productStrategyMap = {STRATEGY_ENTRY(MEDIA),
                            STRATEGY_ENTRY(PHONE),
                            STRATEGY_ENTRY(SONIFICATION),
                            STRATEGY_ENTRY(SONIFICATION_RESPECTFUL),
                            STRATEGY_ENTRY(DTMF),
                            STRATEGY_ENTRY(ENFORCED_AUDIBLE),
                            STRATEGY_ENTRY(TRANSMITTED_THROUGH_SPEAKER),
                            STRATEGY_ENTRY(ACCESSIBILITY)};
#undef STRATEGY_ENTRY

    auto it = productStrategyMap.find(id);
    if (it == productStrategyMap.end()) {
        return base::unexpected(BAD_VALUE);
    }
    return it->second;
}

ConversionResult<AttributesGroup> aidl2legacy_AudioHalAttributeGroup_AttributesGroup(
        const media::audio::common::AudioHalAttributesGroup& aidl) {
    AttributesGroup legacy;
@@ -65,7 +87,8 @@ ConversionResult<AttributesGroup> aidl2legacy_AudioHalAttributeGroup_AttributesG
ConversionResult<ProductStrategy> aidl2legacy_AudioHalProductStrategy_ProductStrategy(
        const media::audio::common::AudioHalProductStrategy& aidl) {
    ProductStrategy legacy;
    legacy.name = "strategy_" + std::to_string(aidl.id);
    legacy.name = VALUE_OR_RETURN(
                    aidl2legacy_AudioHalProductStrategy_ProductStrategyType(aidl.id));
    legacy.attributesGroups = VALUE_OR_RETURN(convertContainer<AttributesGroups>(
                    aidl.attributesGroups,
                    aidl2legacy_AudioHalAttributeGroup_AttributesGroup));