blob: 3346459031874f430f21f81550b017fb744d490d [file] [log] [blame]
Shunkai Yao51202502022-12-12 06:11:46 +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 "EffectHalAidl"
18//#define LOG_NDEBUG 0
19
Mikhail Naganov5e406ba2023-01-13 00:27:22 +000020#include <error/expected_utils.h>
Shunkai Yao51202502022-12-12 06:11:46 +000021#include <media/AidlConversionCppNdk.h>
22#include <media/AidlConversionNdk.h>
Mikhail Naganov5e406ba2023-01-13 00:27:22 +000023#include <media/AidlConversionUtil.h>
Shunkai Yao51202502022-12-12 06:11:46 +000024#include <media/EffectsFactoryApi.h>
25#include <mediautils/TimeCheck.h>
26#include <utils/Log.h>
27
Shunkai Yao284bb0d2023-01-10 00:42:36 +000028#include <system/audio_effects/effect_aec.h>
29#include <system/audio_effects/effect_downmix.h>
30#include <system/audio_effects/effect_dynamicsprocessing.h>
31#include <system/audio_effects/effect_hapticgenerator.h>
32#include <system/audio_effects/effect_ns.h>
33#include <system/audio_effects/effect_spatializer.h>
34#include <system/audio_effects/effect_visualizer.h>
35
Shunkai Yao51202502022-12-12 06:11:46 +000036#include "EffectHalAidl.h"
37
38#include <system/audio.h>
Shunkai Yao51202502022-12-12 06:11:46 +000039#include <aidl/android/hardware/audio/effect/IEffect.h>
40
Mikhail Naganov5e406ba2023-01-13 00:27:22 +000041using ::aidl::android::aidl_utils::statusTFromBinderStatus;
Shunkai Yao51202502022-12-12 06:11:46 +000042using ::aidl::android::hardware::audio::effect::CommandId;
43using ::aidl::android::hardware::audio::effect::Descriptor;
44using ::aidl::android::hardware::audio::effect::IEffect;
Shunkai Yao51202502022-12-12 06:11:46 +000045using ::aidl::android::hardware::audio::effect::Parameter;
46
47namespace android {
48namespace effect {
49
50EffectHalAidl::EffectHalAidl(const std::shared_ptr<IEffect>& effect, uint64_t effectId,
Shunkai Yao284bb0d2023-01-10 00:42:36 +000051 int32_t sessionId, int32_t ioId, const Descriptor& desc)
52 : EffectConversionHelperAidl(effect, sessionId, ioId, desc.common.id.type),
53 mEffectId(effectId),
54 mSessionId(sessionId),
55 mIoId(ioId),
56 mEffect(effect),
57 mDesc(desc) {}
Shunkai Yao51202502022-12-12 06:11:46 +000058
59EffectHalAidl::~EffectHalAidl() {}
60
61status_t EffectHalAidl::setInBuffer(const sp<EffectBufferHalInterface>& buffer) {
62 if (buffer == nullptr) {
63 return BAD_VALUE;
64 }
65 ALOGW("%s not implemented yet", __func__);
66 return OK;
67}
68
69status_t EffectHalAidl::setOutBuffer(const sp<EffectBufferHalInterface>& buffer) {
70 if (buffer == nullptr) {
71 return BAD_VALUE;
72 }
73 ALOGW("%s not implemented yet", __func__);
74 return OK;
75}
76
77status_t EffectHalAidl::process() {
78 ALOGW("%s not implemented yet", __func__);
Shunkai Yao284bb0d2023-01-10 00:42:36 +000079 // write to input FMQ here, and wait for statusMQ STATUS_OK
Shunkai Yao51202502022-12-12 06:11:46 +000080 return OK;
81}
82
83// TODO: no one using, maybe deprecate this interface
84status_t EffectHalAidl::processReverse() {
85 ALOGW("%s not implemented yet", __func__);
86 return OK;
87}
88
Shunkai Yao51202502022-12-12 06:11:46 +000089status_t EffectHalAidl::command(uint32_t cmdCode, uint32_t cmdSize, void* pCmdData,
90 uint32_t* replySize, void* pReplyData) {
Shunkai Yao284bb0d2023-01-10 00:42:36 +000091 return handleCommand(cmdCode, cmdSize, pCmdData, replySize, pReplyData);
Shunkai Yao51202502022-12-12 06:11:46 +000092}
93
94status_t EffectHalAidl::getDescriptor(effect_descriptor_t* pDescriptor) {
95 ALOGW("%s %p", __func__, pDescriptor);
96 if (pDescriptor == nullptr) {
97 return BAD_VALUE;
98 }
99 Descriptor aidlDesc;
Mikhail Naganov5e406ba2023-01-13 00:27:22 +0000100 RETURN_STATUS_IF_ERROR(statusTFromBinderStatus(mEffect->getDescriptor(&aidlDesc)));
Shunkai Yao51202502022-12-12 06:11:46 +0000101
102 *pDescriptor = VALUE_OR_RETURN_STATUS(
103 ::aidl::android::aidl2legacy_Descriptor_effect_descriptor(aidlDesc));
104 return OK;
105}
106
107status_t EffectHalAidl::close() {
Shunkai Yao284bb0d2023-01-10 00:42:36 +0000108 RETURN_STATUS_IF_ERROR(statusTFromBinderStatus(mEffect->close()));
109 return OK;
Shunkai Yao51202502022-12-12 06:11:46 +0000110}
111
112status_t EffectHalAidl::dump(int fd) {
113 ALOGW("%s not implemented yet, fd %d", __func__, fd);
114 return OK;
115}
116
117} // namespace effect
118} // namespace android