Kevin Rocard | d4de288 | 2018-02-28 14:33:38 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 | |
Kevin Rocard | df9b420 | 2018-05-10 19:56:08 -0700 | [diff] [blame] | 17 | #ifndef ANDROID_HARDWARE_EFFECT_HAL_HIDL_H |
| 18 | #define ANDROID_HARDWARE_EFFECT_HAL_HIDL_H |
Kevin Rocard | d4de288 | 2018-02-28 14:33:38 -0800 | [diff] [blame] | 19 | |
Kevin Rocard | 95213bf | 2018-11-08 17:16:57 -0800 | [diff] [blame] | 20 | #include PATH(android/hardware/audio/effect/FILE_VERSION/IEffect.h) |
Kevin Rocard | d4de288 | 2018-02-28 14:33:38 -0800 | [diff] [blame] | 21 | #include <media/audiohal/EffectHalInterface.h> |
| 22 | #include <fmq/EventFlag.h> |
| 23 | #include <fmq/MessageQueue.h> |
| 24 | #include <system/audio_effect.h> |
| 25 | |
Mikhail Naganov | 288a343 | 2022-03-25 00:29:56 +0000 | [diff] [blame^] | 26 | #include "EffectConversionHelperHidl.h" |
| 27 | |
Kevin Rocard | d4de288 | 2018-02-28 14:33:38 -0800 | [diff] [blame] | 28 | using ::android::hardware::EventFlag; |
| 29 | using ::android::hardware::MessageQueue; |
| 30 | |
| 31 | namespace android { |
Mikhail Naganov | 595caa3 | 2018-12-13 11:08:28 -0800 | [diff] [blame] | 32 | namespace effect { |
Kevin Rocard | d4de288 | 2018-02-28 14:33:38 -0800 | [diff] [blame] | 33 | |
Mikhail Naganov | 595caa3 | 2018-12-13 11:08:28 -0800 | [diff] [blame] | 34 | using namespace ::android::hardware::audio::effect::CPP_VERSION; |
| 35 | |
Mikhail Naganov | 288a343 | 2022-03-25 00:29:56 +0000 | [diff] [blame^] | 36 | class EffectHalHidl : public EffectHalInterface, public EffectConversionHelperHidl |
Kevin Rocard | d4de288 | 2018-02-28 14:33:38 -0800 | [diff] [blame] | 37 | { |
| 38 | public: |
| 39 | // Set the input buffer. |
| 40 | virtual status_t setInBuffer(const sp<EffectBufferHalInterface>& buffer); |
| 41 | |
| 42 | // Set the output buffer. |
| 43 | virtual status_t setOutBuffer(const sp<EffectBufferHalInterface>& buffer); |
| 44 | |
| 45 | // Effect process function. |
| 46 | virtual status_t process(); |
| 47 | |
| 48 | // Process reverse stream function. This function is used to pass |
| 49 | // a reference stream to the effect engine. |
| 50 | virtual status_t processReverse(); |
| 51 | |
| 52 | // Send a command and receive a response to/from effect engine. |
| 53 | virtual status_t command(uint32_t cmdCode, uint32_t cmdSize, void *pCmdData, |
| 54 | uint32_t *replySize, void *pReplyData); |
| 55 | |
| 56 | // Returns the effect descriptor. |
| 57 | virtual status_t getDescriptor(effect_descriptor_t *pDescriptor); |
| 58 | |
| 59 | // Free resources on the remote side. |
| 60 | virtual status_t close(); |
| 61 | |
| 62 | // Whether it's a local implementation. |
| 63 | virtual bool isLocal() const { return false; } |
| 64 | |
Mikhail Naganov | 4d54767 | 2019-02-22 14:19:19 -0800 | [diff] [blame] | 65 | virtual status_t dump(int fd); |
| 66 | |
Mikhail Naganov | 6718c39 | 2022-01-27 22:17:21 +0000 | [diff] [blame] | 67 | virtual uint64_t effectId() const { return mEffectId; } |
Kevin Rocard | d4de288 | 2018-02-28 14:33:38 -0800 | [diff] [blame] | 68 | |
Kevin Rocard | d4de288 | 2018-02-28 14:33:38 -0800 | [diff] [blame] | 69 | private: |
| 70 | friend class EffectsFactoryHalHidl; |
Mikhail Naganov | 595caa3 | 2018-12-13 11:08:28 -0800 | [diff] [blame] | 71 | typedef MessageQueue<Result, hardware::kSynchronizedReadWrite> StatusMQ; |
Kevin Rocard | d4de288 | 2018-02-28 14:33:38 -0800 | [diff] [blame] | 72 | |
| 73 | sp<IEffect> mEffect; |
| 74 | const uint64_t mEffectId; |
| 75 | sp<EffectBufferHalInterface> mInBuffer; |
| 76 | sp<EffectBufferHalInterface> mOutBuffer; |
| 77 | bool mBuffersChanged; |
| 78 | std::unique_ptr<StatusMQ> mStatusMQ; |
| 79 | EventFlag* mEfGroup; |
Mikhail Naganov | 247b5f9 | 2021-01-15 19:16:12 +0000 | [diff] [blame] | 80 | bool mIsInput = false; |
Kevin Rocard | d4de288 | 2018-02-28 14:33:38 -0800 | [diff] [blame] | 81 | |
Kevin Rocard | d4de288 | 2018-02-28 14:33:38 -0800 | [diff] [blame] | 82 | // Can not be constructed directly by clients. |
| 83 | EffectHalHidl(const sp<IEffect>& effect, uint64_t effectId); |
| 84 | |
| 85 | // The destructor automatically releases the effect. |
| 86 | virtual ~EffectHalHidl(); |
| 87 | |
| 88 | status_t getConfigImpl(uint32_t cmdCode, uint32_t *replySize, void *pReplyData); |
| 89 | status_t prepareForProcessing(); |
| 90 | bool needToResetBuffers(); |
| 91 | status_t processImpl(uint32_t mqFlag); |
| 92 | status_t setConfigImpl( |
| 93 | uint32_t cmdCode, uint32_t cmdSize, void *pCmdData, |
| 94 | uint32_t *replySize, void *pReplyData); |
| 95 | status_t setProcessBuffers(); |
| 96 | }; |
| 97 | |
Mikhail Naganov | 595caa3 | 2018-12-13 11:08:28 -0800 | [diff] [blame] | 98 | } // namespace effect |
Kevin Rocard | d4de288 | 2018-02-28 14:33:38 -0800 | [diff] [blame] | 99 | } // namespace android |
| 100 | |
Kevin Rocard | df9b420 | 2018-05-10 19:56:08 -0700 | [diff] [blame] | 101 | #endif // ANDROID_HARDWARE_EFFECT_HAL_HIDL_H |