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 | |
| 23 | namespace android { |
| 24 | namespace effect { |
| 25 | |
| 26 | class EffectHalAidl : public EffectHalInterface { |
| 27 | public: |
| 28 | // Set the input buffer. |
| 29 | status_t setInBuffer(const sp<EffectBufferHalInterface>& buffer) override; |
| 30 | |
| 31 | // Set the output buffer. |
| 32 | status_t setOutBuffer(const sp<EffectBufferHalInterface>& buffer) override; |
| 33 | |
| 34 | // Effect process function. |
| 35 | status_t process() override; |
| 36 | |
| 37 | // Process reverse stream function. This function is used to pass |
| 38 | // a reference stream to the effect engine. |
| 39 | status_t processReverse() override; |
| 40 | |
| 41 | // Send a command and receive a response to/from effect engine. |
| 42 | status_t command(uint32_t cmdCode, uint32_t cmdSize, void* pCmdData, uint32_t* replySize, |
| 43 | void* pReplyData) override; |
| 44 | |
| 45 | // Returns the effect descriptor. |
| 46 | status_t getDescriptor(effect_descriptor_t *pDescriptor) override; |
| 47 | |
| 48 | // Free resources on the remote side. |
| 49 | status_t close() override; |
| 50 | |
| 51 | // Whether it's a local implementation. |
| 52 | bool isLocal() const override { return false; } |
| 53 | |
| 54 | status_t dump(int fd) override; |
| 55 | |
| 56 | uint64_t effectId() const override { return mEffectId; } |
| 57 | |
| 58 | private: |
| 59 | friend class EffectsFactoryHalAidl; |
| 60 | |
| 61 | const uint64_t mEffectId; |
| 62 | const int32_t mSessionId; |
| 63 | const int32_t mIoId; |
| 64 | sp<EffectBufferHalInterface> mInBuffer, mOutBuffer; |
| 65 | effect_config_t mConfig; |
| 66 | std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect> mEffect; |
| 67 | |
| 68 | // Can not be constructed directly by clients. |
| 69 | EffectHalAidl(const std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect>& effect, |
| 70 | uint64_t effectId, int32_t sessionId, int32_t ioId); |
| 71 | |
| 72 | status_t handleSetConfig(uint32_t cmdCode, uint32_t cmdSize, void* pCmdData, |
| 73 | uint32_t* replySize, void* pReplyData); |
| 74 | status_t handleGetConfig(uint32_t cmdCode, uint32_t cmdSize, void* pCmdData, |
| 75 | uint32_t* replySize, void* pReplyData); |
| 76 | status_t handleSetParameter(uint32_t cmdCode, uint32_t cmdSize, void* pCmdData, |
| 77 | uint32_t* replySize, void* pReplyData); |
| 78 | status_t handleGetParameter(uint32_t cmdCode, uint32_t cmdSize, void* pCmdData, |
| 79 | uint32_t* replySize, void* pReplyData); |
| 80 | |
| 81 | // The destructor automatically releases the effect. |
| 82 | virtual ~EffectHalAidl(); |
| 83 | }; |
| 84 | |
| 85 | } // namespace effect |
| 86 | } // namespace android |