1 /*
2 * Copyright (C) 2020 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 "EffectsFactory7.0"
18 #include <log/log.h>
19
20 #include "EffectsFactory.h"
21 #include "EqualizerEffect.h"
22 #include "LoudnessEnhancerEffect.h"
23
24 using ::android::hardware::hidl_string;
25 using ::android::hardware::hidl_vec;
26 using ::android::hardware::Return;
27 using ::android::hardware::Void;
28 using namespace ::android::hardware::audio::common::V7_0;
29
30 namespace android::hardware::audio::effect::V7_0::implementation {
31
getAllDescriptors(getAllDescriptors_cb _hidl_cb)32 Return<void> EffectsFactory::getAllDescriptors(getAllDescriptors_cb _hidl_cb) {
33 hidl_vec<EffectDescriptor> descriptors;
34 descriptors.resize(2);
35 descriptors[0] = EqualizerEffect::getDescriptor();
36 descriptors[1] = LoudnessEnhancerEffect::getDescriptor();
37 _hidl_cb(Result::OK, descriptors);
38 return Void();
39 }
40
getDescriptor(const Uuid & uuid,getDescriptor_cb _hidl_cb)41 Return<void> EffectsFactory::getDescriptor(const Uuid& uuid, getDescriptor_cb _hidl_cb) {
42 if (auto desc = EqualizerEffect::getDescriptor(); uuid == desc.type || uuid == desc.uuid) {
43 _hidl_cb(Result::OK, desc);
44 } else if (auto desc = LoudnessEnhancerEffect::getDescriptor();
45 uuid == desc.type || uuid == desc.uuid) {
46 _hidl_cb(Result::OK, desc);
47 } else {
48 _hidl_cb(Result::INVALID_ARGUMENTS, EffectDescriptor{});
49 }
50 return Void();
51 }
52
createEffect(const Uuid & uuid,int32_t session,int32_t ioHandle,int32_t device,createEffect_cb _hidl_cb)53 Return<void> EffectsFactory::createEffect(const Uuid& uuid, int32_t session, int32_t ioHandle,
54 int32_t device, createEffect_cb _hidl_cb) {
55 (void)session;
56 (void)ioHandle;
57 (void)device;
58 if (auto desc = EqualizerEffect::getDescriptor(); uuid == desc.type || uuid == desc.uuid) {
59 _hidl_cb(Result::OK, new EqualizerEffect(), 0);
60 } else if (auto desc = LoudnessEnhancerEffect::getDescriptor();
61 uuid == desc.type || uuid == desc.uuid) {
62 _hidl_cb(Result::OK, new LoudnessEnhancerEffect(), 0);
63 } else {
64 _hidl_cb(Result::INVALID_ARGUMENTS, nullptr, 0);
65 }
66 return Void();
67 }
68
debug(const hidl_handle & fd,const hidl_vec<hidl_string> & options)69 Return<void> EffectsFactory::debug(const hidl_handle& fd, const hidl_vec<hidl_string>& options) {
70 (void)fd;
71 (void)options;
72 return Void();
73 }
74
75 } // namespace android::hardware::audio::effect::V7_0::implementation
76