blob: 87c0ace6d247adb675085e825a64071b997c8c88 [file] [log] [blame]
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +00001/*
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-Huertadb11b2d2022-08-19 02:58:59 +000016
Lorena Torres-Huertabc585bd2022-10-23 20:41:35 +000017#define LOG_TAG "AHAL_Config"
Lorena Torres-Huerta0ba91e52022-10-05 21:56:42 +000018#include <android-base/logging.h>
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +000019
Lorena Torres-Huertabc585bd2022-10-23 20:41:35 +000020#include <system/audio_config.h>
21
22#include "core-impl/AudioPolicyConfigXmlConverter.h"
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +000023#include "core-impl/Config.h"
Lorena Torres-Huertabc585bd2022-10-23 20:41:35 +000024#include "core-impl/EngineConfigXmlConverter.h"
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +000025
Lorena Torres-Huertadb11b2d2022-08-19 02:58:59 +000026using aidl::android::media::audio::common::AudioHalEngineConfig;
27
Lorena Torres-Huerta0ba91e52022-10-05 21:56:42 +000028namespace aidl::android::hardware::audio::core {
29ndk::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-Huertadb11b2d2022-08-19 02:58:59 +000036
37ndk::ScopedAStatus Config::getEngineConfig(AudioHalEngineConfig* _aidl_return) {
Lorena Torres-Huertabc585bd2022-10-23 20:41:35 +000038 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 }
50 return engConfig;
51 }();
52 *_aidl_return = returnEngCfg;
Lorena Torres-Huertadb11b2d2022-08-19 02:58:59 +000053 LOG(DEBUG) << __func__ << ": returning " << _aidl_return->toString();
54 return ndk::ScopedAStatus::ok();
55}
Lorena Torres-Huerta0ba91e52022-10-05 21:56:42 +000056} // namespace aidl::android::hardware::audio::core