Mikhail Naganov | df5adfd | 2021-11-11 22:09:22 +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 | */ |
Lorena Torres-Huerta | db11b2d | 2022-08-19 02:58:59 +0000 | [diff] [blame] | 16 | |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 17 | #define LOG_TAG "AHAL_Config" |
Lorena Torres-Huerta | 0ba91e5 | 2022-10-05 21:56:42 +0000 | [diff] [blame] | 18 | #include <android-base/logging.h> |
Mikhail Naganov | df5adfd | 2021-11-11 22:09:22 +0000 | [diff] [blame] | 19 | |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 20 | #include <system/audio_config.h> |
| 21 | |
| 22 | #include "core-impl/AudioPolicyConfigXmlConverter.h" |
Mikhail Naganov | df5adfd | 2021-11-11 22:09:22 +0000 | [diff] [blame] | 23 | #include "core-impl/Config.h" |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 24 | #include "core-impl/EngineConfigXmlConverter.h" |
Mikhail Naganov | df5adfd | 2021-11-11 22:09:22 +0000 | [diff] [blame] | 25 | |
Lorena Torres-Huerta | db11b2d | 2022-08-19 02:58:59 +0000 | [diff] [blame] | 26 | using aidl::android::media::audio::common::AudioHalEngineConfig; |
| 27 | |
Lorena Torres-Huerta | 0ba91e5 | 2022-10-05 21:56:42 +0000 | [diff] [blame] | 28 | namespace aidl::android::hardware::audio::core { |
| 29 | ndk::ScopedAStatus Config::getSurroundSoundConfig(SurroundSoundConfig* _aidl_return) { |
| 30 | SurroundSoundConfig surroundSoundConfig; |
| 31 | // TODO: parse from XML; for now, use empty config as default |
| 32 | *_aidl_return = std::move(surroundSoundConfig); |
| 33 | LOG(DEBUG) << __func__ << ": returning " << _aidl_return->toString(); |
| 34 | return ndk::ScopedAStatus::ok(); |
| 35 | } |
Lorena Torres-Huerta | db11b2d | 2022-08-19 02:58:59 +0000 | [diff] [blame] | 36 | |
| 37 | ndk::ScopedAStatus Config::getEngineConfig(AudioHalEngineConfig* _aidl_return) { |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 38 | static const AudioHalEngineConfig returnEngCfg = [this]() { |
| 39 | AudioHalEngineConfig engConfig; |
| 40 | if (mEngConfigConverter.getStatus() == ::android::OK) { |
| 41 | engConfig = mEngConfigConverter.getAidlEngineConfig(); |
| 42 | } else { |
| 43 | LOG(INFO) << __func__ << mEngConfigConverter.getError(); |
| 44 | if (mAudioPolicyConverter.getStatus() == ::android::OK) { |
| 45 | engConfig = mAudioPolicyConverter.getAidlEngineConfig(); |
| 46 | } else { |
| 47 | LOG(WARNING) << __func__ << mAudioPolicyConverter.getError(); |
| 48 | } |
| 49 | } |
Mikhail Naganov | 26526f1 | 2023-05-12 13:51:06 -0700 | [diff] [blame] | 50 | // Logging full contents of the config is an overkill, just provide statistics. |
| 51 | LOG(DEBUG) << "getEngineConfig: number of strategies parsed: " |
| 52 | << engConfig.productStrategies.size() |
| 53 | << ", default strategy: " << engConfig.defaultProductStrategyId |
| 54 | << ", number of volume groups parsed: " << engConfig.volumeGroups.size(); |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 55 | return engConfig; |
| 56 | }(); |
| 57 | *_aidl_return = returnEngCfg; |
Lorena Torres-Huerta | db11b2d | 2022-08-19 02:58:59 +0000 | [diff] [blame] | 58 | return ndk::ScopedAStatus::ok(); |
| 59 | } |
Lorena Torres-Huerta | 0ba91e5 | 2022-10-05 21:56:42 +0000 | [diff] [blame] | 60 | } // namespace aidl::android::hardware::audio::core |