Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2022 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include <fcntl.h> |
| 18 | #include <inttypes.h> |
| 19 | #include <unistd.h> |
| 20 | #include <functional> |
| 21 | #include <unordered_map> |
| 22 | |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 23 | #define LOG_TAG "AHAL_Config" |
Lorena Torres-Huerta | 0f4d689 | 2022-12-14 20:00:26 +0000 | [diff] [blame] | 24 | #include <aidl/android/media/audio/common/AudioFlag.h> |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 25 | #include <aidl/android/media/audio/common/AudioHalEngineConfig.h> |
Lorena Torres-Huerta | 0f4d689 | 2022-12-14 20:00:26 +0000 | [diff] [blame] | 26 | #include <aidl/android/media/audio/common/AudioProductStrategyType.h> |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 27 | #include <android-base/logging.h> |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 28 | |
François Gaffie | 57ccab7 | 2024-04-17 11:47:51 +0200 | [diff] [blame] | 29 | #include "core-impl/CapEngineConfigXmlConverter.h" |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 30 | #include "core-impl/EngineConfigXmlConverter.h" |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 31 | #include "core-impl/XsdcConversion.h" |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 32 | |
François Gaffie | 57ccab7 | 2024-04-17 11:47:51 +0200 | [diff] [blame] | 33 | using aidl::android::hardware::audio::core::internal::CapEngineConfigXmlConverter; |
| 34 | using aidl::android::hardware::audio::core::internal::convertAudioUsageToAidl; |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 35 | using aidl::android::media::audio::common::AudioAttributes; |
| 36 | using aidl::android::media::audio::common::AudioContentType; |
| 37 | using aidl::android::media::audio::common::AudioFlag; |
| 38 | using aidl::android::media::audio::common::AudioHalAttributesGroup; |
| 39 | using aidl::android::media::audio::common::AudioHalCapCriterion; |
| 40 | using aidl::android::media::audio::common::AudioHalCapCriterionType; |
François Gaffie | 57ccab7 | 2024-04-17 11:47:51 +0200 | [diff] [blame] | 41 | using aidl::android::media::audio::common::AudioHalCapCriterionV2; |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 42 | using aidl::android::media::audio::common::AudioHalEngineConfig; |
| 43 | using aidl::android::media::audio::common::AudioHalProductStrategy; |
| 44 | using aidl::android::media::audio::common::AudioHalVolumeCurve; |
| 45 | using aidl::android::media::audio::common::AudioHalVolumeGroup; |
| 46 | using aidl::android::media::audio::common::AudioProductStrategyType; |
| 47 | using aidl::android::media::audio::common::AudioSource; |
| 48 | using aidl::android::media::audio::common::AudioStreamType; |
| 49 | using aidl::android::media::audio::common::AudioUsage; |
François Gaffie | 57ccab7 | 2024-04-17 11:47:51 +0200 | [diff] [blame] | 50 | |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 51 | using ::android::BAD_VALUE; |
| 52 | using ::android::base::unexpected; |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 53 | |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 54 | namespace eng_xsd = android::audio::policy::engine::configuration; |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 55 | |
| 56 | namespace aidl::android::hardware::audio::core::internal { |
| 57 | |
François Gaffie | 57ccab7 | 2024-04-17 11:47:51 +0200 | [diff] [blame] | 58 | /** Default path of audio policy cap engine configuration file. */ |
| 59 | static constexpr char kCapEngineConfigFileName[] = |
| 60 | "/parameter-framework/Settings/Policy/PolicyConfigurableDomains.xml"; |
| 61 | |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 62 | ConversionResult<int> EngineConfigXmlConverter::convertProductStrategyNameToAidl( |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 63 | const std::string& xsdcProductStrategyName) { |
| 64 | const auto [it, success] = mProductStrategyMap.insert( |
| 65 | std::make_pair(xsdcProductStrategyName, mNextVendorStrategy)); |
| 66 | if (success) { |
| 67 | mNextVendorStrategy++; |
| 68 | } |
| 69 | return it->second; |
| 70 | } |
| 71 | |
François Gaffie | 57ccab7 | 2024-04-17 11:47:51 +0200 | [diff] [blame] | 72 | ConversionResult<int> EngineConfigXmlConverter::convertProductStrategyIdToAidl(int xsdcId) { |
| 73 | if (xsdcId < AudioHalProductStrategy::VENDOR_STRATEGY_ID_START) { |
| 74 | return unexpected(BAD_VALUE); |
| 75 | } |
| 76 | return xsdcId; |
| 77 | } |
| 78 | |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 79 | bool isDefaultAudioAttributes(const AudioAttributes& attributes) { |
| 80 | return ((attributes.contentType == AudioContentType::UNKNOWN) && |
| 81 | (attributes.usage == AudioUsage::UNKNOWN) && |
| 82 | (attributes.source == AudioSource::DEFAULT) && (attributes.flags == 0) && |
| 83 | (attributes.tags.empty())); |
| 84 | } |
| 85 | |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 86 | ConversionResult<AudioAttributes> EngineConfigXmlConverter::convertAudioAttributesToAidl( |
| 87 | const eng_xsd::AttributesType& xsdcAudioAttributes) { |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 88 | if (xsdcAudioAttributes.hasAttributesRef()) { |
| 89 | if (mAttributesReferenceMap.empty()) { |
| 90 | mAttributesReferenceMap = |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 91 | generateReferenceMap<eng_xsd::AttributesRef, eng_xsd::AttributesRefType>( |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 92 | getXsdcConfig()->getAttributesRef()); |
| 93 | } |
| 94 | return convertAudioAttributesToAidl( |
| 95 | *(mAttributesReferenceMap.at(xsdcAudioAttributes.getAttributesRef()) |
| 96 | .getFirstAttributes())); |
| 97 | } |
| 98 | AudioAttributes aidlAudioAttributes; |
| 99 | if (xsdcAudioAttributes.hasContentType()) { |
François Gaffie | 57ccab7 | 2024-04-17 11:47:51 +0200 | [diff] [blame] | 100 | aidlAudioAttributes.contentType = VALUE_OR_FATAL(convertAudioContentTypeToAidl( |
| 101 | xsdcAudioAttributes.getFirstContentType()->getValue())); |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 102 | } |
| 103 | if (xsdcAudioAttributes.hasUsage()) { |
François Gaffie | 57ccab7 | 2024-04-17 11:47:51 +0200 | [diff] [blame] | 104 | aidlAudioAttributes.usage = VALUE_OR_FATAL( |
| 105 | convertAudioUsageToAidl(xsdcAudioAttributes.getFirstUsage()->getValue())); |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 106 | } |
| 107 | if (xsdcAudioAttributes.hasSource()) { |
François Gaffie | 57ccab7 | 2024-04-17 11:47:51 +0200 | [diff] [blame] | 108 | aidlAudioAttributes.source = VALUE_OR_FATAL( |
| 109 | convertAudioSourceToAidl(xsdcAudioAttributes.getFirstSource()->getValue())); |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 110 | } |
| 111 | if (xsdcAudioAttributes.hasFlags()) { |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 112 | std::vector<eng_xsd::FlagType> xsdcFlagTypeVec = |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 113 | xsdcAudioAttributes.getFirstFlags()->getValue(); |
François Gaffie | 57ccab7 | 2024-04-17 11:47:51 +0200 | [diff] [blame] | 114 | aidlAudioAttributes.flags = VALUE_OR_FATAL(convertAudioFlagsToAidl(xsdcFlagTypeVec)); |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 115 | } |
| 116 | if (xsdcAudioAttributes.hasBundle()) { |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 117 | const eng_xsd::BundleType* xsdcBundle = xsdcAudioAttributes.getFirstBundle(); |
François Gaffie | 57ccab7 | 2024-04-17 11:47:51 +0200 | [diff] [blame] | 118 | aidlAudioAttributes.tags.reserve(1); |
| 119 | aidlAudioAttributes.tags.push_back(xsdcBundle->getKey() + "_" + xsdcBundle->getValue()); |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 120 | } |
| 121 | if (isDefaultAudioAttributes(aidlAudioAttributes)) { |
| 122 | mDefaultProductStrategyId = std::optional<int>{-1}; |
| 123 | } |
| 124 | return aidlAudioAttributes; |
| 125 | } |
| 126 | |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 127 | ConversionResult<AudioHalAttributesGroup> EngineConfigXmlConverter::convertAttributesGroupToAidl( |
| 128 | const eng_xsd::AttributesGroup& xsdcAttributesGroup) { |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 129 | AudioHalAttributesGroup aidlAttributesGroup; |
| 130 | static const int kStreamTypeEnumOffset = |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 131 | static_cast<int>(eng_xsd::Stream::AUDIO_STREAM_VOICE_CALL) - |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 132 | static_cast<int>(AudioStreamType::VOICE_CALL); |
François Gaffie | 57ccab7 | 2024-04-17 11:47:51 +0200 | [diff] [blame] | 133 | aidlAttributesGroup.streamType = xsdcAttributesGroup.hasStreamType() |
| 134 | ? VALUE_OR_FATAL(convertAudioStreamTypeToAidl( |
| 135 | xsdcAttributesGroup.getStreamType())) |
| 136 | : AudioStreamType::INVALID; |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 137 | aidlAttributesGroup.volumeGroupName = xsdcAttributesGroup.getVolumeGroup(); |
| 138 | if (xsdcAttributesGroup.hasAttributes_optional()) { |
| 139 | aidlAttributesGroup.attributes = |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 140 | VALUE_OR_FATAL((convertCollectionToAidl<eng_xsd::AttributesType, AudioAttributes>( |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 141 | xsdcAttributesGroup.getAttributes_optional(), |
| 142 | std::bind(&EngineConfigXmlConverter::convertAudioAttributesToAidl, this, |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 143 | std::placeholders::_1)))); |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 144 | } else if (xsdcAttributesGroup.hasContentType_optional() || |
| 145 | xsdcAttributesGroup.hasUsage_optional() || |
| 146 | xsdcAttributesGroup.hasSource_optional() || |
| 147 | xsdcAttributesGroup.hasFlags_optional() || |
| 148 | xsdcAttributesGroup.hasBundle_optional()) { |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 149 | aidlAttributesGroup.attributes.push_back(VALUE_OR_FATAL(convertAudioAttributesToAidl( |
| 150 | eng_xsd::AttributesType(xsdcAttributesGroup.getContentType_optional(), |
| 151 | xsdcAttributesGroup.getUsage_optional(), |
| 152 | xsdcAttributesGroup.getSource_optional(), |
| 153 | xsdcAttributesGroup.getFlags_optional(), |
| 154 | xsdcAttributesGroup.getBundle_optional(), std::nullopt)))); |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 155 | |
| 156 | } else { |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 157 | LOG(ERROR) << __func__ << " Review Audio Policy config: no audio attributes provided for " |
| 158 | << aidlAttributesGroup.toString(); |
| 159 | return unexpected(BAD_VALUE); |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 160 | } |
| 161 | return aidlAttributesGroup; |
| 162 | } |
| 163 | |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 164 | ConversionResult<AudioHalProductStrategy> EngineConfigXmlConverter::convertProductStrategyToAidl( |
| 165 | const eng_xsd::ProductStrategies::ProductStrategy& xsdcProductStrategy) { |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 166 | AudioHalProductStrategy aidlProductStrategy; |
| 167 | |
Mikhail Naganov | e065c7f | 2024-12-26 10:39:53 -0800 | [diff] [blame] | 168 | if (xsdcProductStrategy.hasId()) { |
| 169 | aidlProductStrategy.id = |
| 170 | VALUE_OR_FATAL(convertProductStrategyIdToAidl(xsdcProductStrategy.getId())); |
| 171 | } else { |
| 172 | aidlProductStrategy.id = |
| 173 | VALUE_OR_FATAL(convertProductStrategyNameToAidl(xsdcProductStrategy.getName())); |
| 174 | } |
François Gaffie | 57ccab7 | 2024-04-17 11:47:51 +0200 | [diff] [blame] | 175 | aidlProductStrategy.name = xsdcProductStrategy.getName(); |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 176 | |
| 177 | if (xsdcProductStrategy.hasAttributesGroup()) { |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 178 | aidlProductStrategy.attributesGroups = VALUE_OR_FATAL( |
| 179 | (convertCollectionToAidl<eng_xsd::AttributesGroup, AudioHalAttributesGroup>( |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 180 | xsdcProductStrategy.getAttributesGroup(), |
| 181 | std::bind(&EngineConfigXmlConverter::convertAttributesGroupToAidl, this, |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 182 | std::placeholders::_1)))); |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 183 | } |
| 184 | if ((mDefaultProductStrategyId != std::nullopt) && (mDefaultProductStrategyId.value() == -1)) { |
| 185 | mDefaultProductStrategyId = aidlProductStrategy.id; |
| 186 | } |
| 187 | return aidlProductStrategy; |
| 188 | } |
| 189 | |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 190 | ConversionResult<AudioHalVolumeCurve> EngineConfigXmlConverter::convertVolumeCurveToAidl( |
| 191 | const eng_xsd::Volume& xsdcVolumeCurve) { |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 192 | AudioHalVolumeCurve aidlVolumeCurve; |
| 193 | aidlVolumeCurve.deviceCategory = |
| 194 | static_cast<AudioHalVolumeCurve::DeviceCategory>(xsdcVolumeCurve.getDeviceCategory()); |
| 195 | if (xsdcVolumeCurve.hasRef()) { |
| 196 | if (mVolumesReferenceMap.empty()) { |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 197 | mVolumesReferenceMap = generateReferenceMap<eng_xsd::VolumesType, eng_xsd::VolumeRef>( |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 198 | getXsdcConfig()->getVolumes()); |
| 199 | } |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 200 | aidlVolumeCurve.curvePoints = VALUE_OR_FATAL( |
| 201 | (convertCollectionToAidl<std::string, AudioHalVolumeCurve::CurvePoint>( |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 202 | mVolumesReferenceMap.at(xsdcVolumeCurve.getRef()).getPoint(), |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 203 | &convertCurvePointToAidl))); |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 204 | } else { |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 205 | aidlVolumeCurve.curvePoints = VALUE_OR_FATAL( |
| 206 | (convertCollectionToAidl<std::string, AudioHalVolumeCurve::CurvePoint>( |
| 207 | xsdcVolumeCurve.getPoint(), &convertCurvePointToAidl))); |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 208 | } |
| 209 | return aidlVolumeCurve; |
| 210 | } |
| 211 | |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 212 | ConversionResult<AudioHalVolumeGroup> EngineConfigXmlConverter::convertVolumeGroupToAidl( |
| 213 | const eng_xsd::VolumeGroupsType::VolumeGroup& xsdcVolumeGroup) { |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 214 | AudioHalVolumeGroup aidlVolumeGroup; |
| 215 | aidlVolumeGroup.name = xsdcVolumeGroup.getName(); |
| 216 | aidlVolumeGroup.minIndex = xsdcVolumeGroup.getIndexMin(); |
| 217 | aidlVolumeGroup.maxIndex = xsdcVolumeGroup.getIndexMax(); |
Lorena Torres-Huerta | aa8f76a | 2022-12-12 18:17:10 +0000 | [diff] [blame] | 218 | aidlVolumeGroup.volumeCurves = |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 219 | VALUE_OR_FATAL((convertCollectionToAidl<eng_xsd::Volume, AudioHalVolumeCurve>( |
Lorena Torres-Huerta | aa8f76a | 2022-12-12 18:17:10 +0000 | [diff] [blame] | 220 | xsdcVolumeGroup.getVolume(), |
| 221 | std::bind(&EngineConfigXmlConverter::convertVolumeCurveToAidl, this, |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 222 | std::placeholders::_1)))); |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 223 | return aidlVolumeGroup; |
| 224 | } |
| 225 | |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 226 | AudioHalEngineConfig& EngineConfigXmlConverter::getAidlEngineConfig() { |
| 227 | return mAidlEngineConfig; |
| 228 | } |
| 229 | |
| 230 | void EngineConfigXmlConverter::init() { |
François Gaffie | 460bd6d | 2025-01-17 14:33:30 +0100 | [diff] [blame] | 231 | mProductStrategyMap = getLegacyProductStrategyMap(); |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 232 | if (getXsdcConfig()->hasProductStrategies()) { |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 233 | mAidlEngineConfig.productStrategies = VALUE_OR_FATAL( |
| 234 | (convertWrappedCollectionToAidl<eng_xsd::ProductStrategies, |
| 235 | eng_xsd::ProductStrategies::ProductStrategy, |
| 236 | AudioHalProductStrategy>( |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 237 | getXsdcConfig()->getProductStrategies(), |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 238 | &eng_xsd::ProductStrategies::getProductStrategy, |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 239 | std::bind(&EngineConfigXmlConverter::convertProductStrategyToAidl, this, |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 240 | std::placeholders::_1)))); |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 241 | if (mDefaultProductStrategyId) { |
| 242 | mAidlEngineConfig.defaultProductStrategyId = mDefaultProductStrategyId.value(); |
| 243 | } |
| 244 | } |
| 245 | if (getXsdcConfig()->hasVolumeGroups()) { |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 246 | mAidlEngineConfig.volumeGroups = VALUE_OR_FATAL( |
| 247 | (convertWrappedCollectionToAidl<eng_xsd::VolumeGroupsType, |
| 248 | eng_xsd::VolumeGroupsType::VolumeGroup, |
| 249 | AudioHalVolumeGroup>( |
| 250 | getXsdcConfig()->getVolumeGroups(), |
| 251 | &eng_xsd::VolumeGroupsType::getVolumeGroup, |
| 252 | std::bind(&EngineConfigXmlConverter::convertVolumeGroupToAidl, this, |
| 253 | std::placeholders::_1)))); |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 254 | } |
| 255 | if (getXsdcConfig()->hasCriteria() && getXsdcConfig()->hasCriterion_types()) { |
| 256 | AudioHalEngineConfig::CapSpecificConfig capSpecificConfig; |
François Gaffie | 57ccab7 | 2024-04-17 11:47:51 +0200 | [diff] [blame] | 257 | capSpecificConfig.criteriaV2 = |
| 258 | std::make_optional<>(VALUE_OR_FATAL((convertCapCriteriaCollectionToAidl( |
| 259 | getXsdcConfig()->getCriteria(), getXsdcConfig()->getCriterion_types())))); |
| 260 | internal::CapEngineConfigXmlConverter capEngConfigConverter{ |
| 261 | ::android::audio_find_readable_configuration_file(kCapEngineConfigFileName)}; |
| 262 | if (capEngConfigConverter.getStatus() == ::android::OK) { |
| 263 | capSpecificConfig.domains = std::move(capEngConfigConverter.getAidlCapEngineConfig()); |
| 264 | } |
| 265 | mAidlEngineConfig.capSpecificConfig = capSpecificConfig; |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 266 | } |
| 267 | } |
Lorena Torres-Huerta | aa8f76a | 2022-12-12 18:17:10 +0000 | [diff] [blame] | 268 | } // namespace aidl::android::hardware::audio::core::internal |