blob: 1ba262c1fe8efbc696ab26fb5d015db02ebb76cc [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#pragma once
18
19#include <aidl/android/hardware/audio/effect/IEffect.h>
20#include <media/audiohal/EffectHalInterface.h>
21#include <system/audio_effect.h>
22
Shunkai Yao284bb0d2023-01-10 00:42:36 +000023#include "EffectConversionHelperAidl.h"
24
Shunkai Yao51202502022-12-12 06:11:46 +000025namespace android {
26namespace effect {
27
Shunkai Yao284bb0d2023-01-10 00:42:36 +000028class EffectHalAidl : public EffectHalInterface, public EffectConversionHelperAidl {
Shunkai Yao51202502022-12-12 06:11:46 +000029 public:
30 // Set the input buffer.
31 status_t setInBuffer(const sp<EffectBufferHalInterface>& buffer) override;
32
33 // Set the output buffer.
34 status_t setOutBuffer(const sp<EffectBufferHalInterface>& buffer) override;
35
36 // Effect process function.
37 status_t process() override;
38
39 // Process reverse stream function. This function is used to pass
40 // a reference stream to the effect engine.
41 status_t processReverse() override;
42
43 // Send a command and receive a response to/from effect engine.
44 status_t command(uint32_t cmdCode, uint32_t cmdSize, void* pCmdData, uint32_t* replySize,
45 void* pReplyData) override;
46
47 // Returns the effect descriptor.
48 status_t getDescriptor(effect_descriptor_t *pDescriptor) override;
49
50 // Free resources on the remote side.
51 status_t close() override;
52
53 // Whether it's a local implementation.
54 bool isLocal() const override { return false; }
55
56 status_t dump(int fd) override;
57
58 uint64_t effectId() const override { return mEffectId; }
59
Shunkai Yao284bb0d2023-01-10 00:42:36 +000060 const std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect> getIEffect() const {
61 return mEffect;
62 }
63
Shunkai Yao51202502022-12-12 06:11:46 +000064 private:
Shunkai Yao284bb0d2023-01-10 00:42:36 +000065 friend class sp<EffectHalAidl>;
Shunkai Yao51202502022-12-12 06:11:46 +000066
67 const uint64_t mEffectId;
68 const int32_t mSessionId;
69 const int32_t mIoId;
Shunkai Yao284bb0d2023-01-10 00:42:36 +000070 const std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect> mEffect;
71 const ::aidl::android::hardware::audio::effect::Descriptor mDesc;
72
Shunkai Yao51202502022-12-12 06:11:46 +000073 sp<EffectBufferHalInterface> mInBuffer, mOutBuffer;
74 effect_config_t mConfig;
Shunkai Yao51202502022-12-12 06:11:46 +000075
76 // Can not be constructed directly by clients.
77 EffectHalAidl(const std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect>& effect,
Shunkai Yao284bb0d2023-01-10 00:42:36 +000078 uint64_t effectId, int32_t sessionId, int32_t ioId,
79 const ::aidl::android::hardware::audio::effect::Descriptor& desc);
80 bool setEffectReverse(bool reverse);
Shunkai Yao51202502022-12-12 06:11:46 +000081
82 // The destructor automatically releases the effect.
83 virtual ~EffectHalAidl();
84};
85
86} // namespace effect
87} // namespace android