blob: 482114db87e942a594ce27df9b2a1fe324947a9c [file] [log] [blame]
Shunkai Yao242521c2023-01-29 18:08:09 +00001/*
2 * Copyright (C) 2023 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 <cstdint>
18#include <cstring>
19#include <optional>
20#define LOG_TAG "AidlConversionVirtualizer"
21//#define LOG_NDEBUG 0
22
23#include <error/expected_utils.h>
24#include <media/AidlConversionNdk.h>
25#include <media/AidlConversionEffect.h>
26#include <media/audiohal/AudioEffectUuid.h>
27#include <system/audio_effects/effect_spatializer.h>
28
29#include <utils/Log.h>
30
31#include "AidlConversionVirtualizer.h"
32
33namespace android {
34namespace effect {
35
36using ::aidl::android::aidl_utils::statusTFromBinderStatus;
37using ::aidl::android::hardware::audio::effect::Parameter;
38using ::android::status_t;
39using utils::EffectParamReader;
40using utils::EffectParamWriter;
41
42status_t AidlConversionVirtualizer::setParameter(EffectParamReader& param) {
43 uint32_t type = 0;
44 uint16_t value = 0;
45 if (!param.validateParamValueSize(sizeof(uint32_t), sizeof(uint16_t)) ||
46 OK != param.readFromParameter(&type) || OK != param.readFromValue(&value)) {
47 ALOGE("%s invalid param %s", __func__, param.toString().c_str());
48 return BAD_VALUE;
49 }
50 Parameter aidlParam;
51 // TODO
52 return statusTFromBinderStatus(mEffect->setParameter(aidlParam));
53}
54
55status_t AidlConversionVirtualizer::getParameter(EffectParamWriter& param) {
56 uint32_t type = 0, value = 0;
57 if (!param.validateParamValueSize(sizeof(uint32_t), sizeof(uint32_t)) ||
58 OK != param.readFromParameter(&type)) {
59 ALOGE("%s invalid param %s", __func__, param.toString().c_str());
60 param.setStatus(BAD_VALUE);
61 return BAD_VALUE;
62 }
63 // TODO
64 return param.writeToValue(&value);
65}
66
67} // namespace effect
68} // namespace android