Shunkai Yao | 5120250 | 2022-12-12 06:11:46 +0000 | [diff] [blame] | 1 | /* |
| 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 Yao | 284bb0d | 2023-01-10 00:42:36 +0000 | [diff] [blame^] | 23 | #include "EffectConversionHelperAidl.h" |
| 24 | |
Shunkai Yao | 5120250 | 2022-12-12 06:11:46 +0000 | [diff] [blame] | 25 | namespace android { |
| 26 | namespace effect { |
| 27 | |
Shunkai Yao | 284bb0d | 2023-01-10 00:42:36 +0000 | [diff] [blame^] | 28 | class EffectHalAidl : public EffectHalInterface, public EffectConversionHelperAidl { |
Shunkai Yao | 5120250 | 2022-12-12 06:11:46 +0000 | [diff] [blame] | 29 | 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 Yao | 284bb0d | 2023-01-10 00:42:36 +0000 | [diff] [blame^] | 60 | const std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect> getIEffect() const { |
| 61 | return mEffect; |
| 62 | } |
| 63 | |
Shunkai Yao | 5120250 | 2022-12-12 06:11:46 +0000 | [diff] [blame] | 64 | private: |
Shunkai Yao | 284bb0d | 2023-01-10 00:42:36 +0000 | [diff] [blame^] | 65 | friend class sp<EffectHalAidl>; |
Shunkai Yao | 5120250 | 2022-12-12 06:11:46 +0000 | [diff] [blame] | 66 | |
| 67 | const uint64_t mEffectId; |
| 68 | const int32_t mSessionId; |
| 69 | const int32_t mIoId; |
Shunkai Yao | 284bb0d | 2023-01-10 00:42:36 +0000 | [diff] [blame^] | 70 | const std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect> mEffect; |
| 71 | const ::aidl::android::hardware::audio::effect::Descriptor mDesc; |
| 72 | |
Shunkai Yao | 5120250 | 2022-12-12 06:11:46 +0000 | [diff] [blame] | 73 | sp<EffectBufferHalInterface> mInBuffer, mOutBuffer; |
| 74 | effect_config_t mConfig; |
Shunkai Yao | 5120250 | 2022-12-12 06:11:46 +0000 | [diff] [blame] | 75 | |
| 76 | // Can not be constructed directly by clients. |
| 77 | EffectHalAidl(const std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect>& effect, |
Shunkai Yao | 284bb0d | 2023-01-10 00:42:36 +0000 | [diff] [blame^] | 78 | uint64_t effectId, int32_t sessionId, int32_t ioId, |
| 79 | const ::aidl::android::hardware::audio::effect::Descriptor& desc); |
| 80 | bool setEffectReverse(bool reverse); |
Shunkai Yao | 5120250 | 2022-12-12 06:11:46 +0000 | [diff] [blame] | 81 | |
| 82 | // The destructor automatically releases the effect. |
| 83 | virtual ~EffectHalAidl(); |
| 84 | }; |
| 85 | |
| 86 | } // namespace effect |
| 87 | } // namespace android |