blob: a31e23f8dbd6e33d37dc59489e19a7723deb80dc [file] [log] [blame]
Shunkai Yaoc23916b2022-07-13 04:59:37 +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 */
16
17#define LOG_TAG "AHAL_EffectFactory"
18#include <android-base/logging.h>
19
20#include "effectFactory-impl/EffectFactory.h"
21#include "equalizer-impl/Equalizer.h"
22#include "visualizer-impl/Visualizer.h"
23
24using aidl::android::media::audio::common::AudioUuid;
25
26namespace aidl::android::hardware::audio::effect {
27
28Factory::Factory() {
29 // TODO: implement this with xml parser on audio_effect.xml, and filter with optional
30 // parameters.
31 Descriptor::Identity id;
32 id.type = {static_cast<int32_t>(0x0bed4300),
33 0xddd6,
34 0x11db,
35 0x8f34,
36 {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
37 id.uuid = EqualizerUUID;
38 mIdentityList.push_back(id);
39 id.type = {static_cast<int32_t>(0xd3467faa),
40 0xacc7,
41 0x4d34,
42 0xacaf,
43 {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
44 id.uuid = VisualizerUUID;
45 mIdentityList.push_back(id);
46}
47
48ndk::ScopedAStatus Factory::queryEffects(const std::optional<AudioUuid>& in_type,
49 const std::optional<AudioUuid>& in_instance,
50 std::vector<Descriptor::Identity>* _aidl_return) {
51 std::copy_if(mIdentityList.begin(), mIdentityList.end(), std::back_inserter(*_aidl_return),
52 [&](auto& desc) {
53 return (!in_type.has_value() || in_type.value() == desc.type) &&
54 (!in_instance.has_value() || in_instance.value() == desc.uuid);
55 });
56 return ndk::ScopedAStatus::ok();
57}
58
59} // namespace aidl::android::hardware::audio::effect