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_EFFECTS_FACTORY_HAL_HIDL_H |
| 18 | #define ANDROID_HARDWARE_EFFECTS_FACTORY_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/IEffectsFactory.h) |
| 21 | #include PATH(android/hardware/audio/effect/FILE_VERSION/types.h) |
Kevin Rocard | d4de288 | 2018-02-28 14:33:38 -0800 | [diff] [blame] | 22 | #include <media/audiohal/EffectsFactoryHalInterface.h> |
| 23 | |
| 24 | #include "ConversionHelperHidl.h" |
| 25 | |
| 26 | namespace android { |
Mikhail Naganov | 595caa3 | 2018-12-13 11:08:28 -0800 | [diff] [blame] | 27 | namespace effect { |
Kevin Rocard | 070e751 | 2018-05-22 09:29:13 -0700 | [diff] [blame] | 28 | namespace CPP_VERSION { |
Kevin Rocard | d4de288 | 2018-02-28 14:33:38 -0800 | [diff] [blame] | 29 | |
Kevin Rocard | d4de288 | 2018-02-28 14:33:38 -0800 | [diff] [blame] | 30 | using ::android::hardware::hidl_vec; |
Mikhail Naganov | 595caa3 | 2018-12-13 11:08:28 -0800 | [diff] [blame] | 31 | using ::android::CPP_VERSION::ConversionHelperHidl; |
| 32 | using namespace ::android::hardware::audio::effect::CPP_VERSION; |
Kevin Rocard | d4de288 | 2018-02-28 14:33:38 -0800 | [diff] [blame] | 33 | |
| 34 | class EffectsFactoryHalHidl : public EffectsFactoryHalInterface, public ConversionHelperHidl |
| 35 | { |
| 36 | public: |
Kevin Rocard | df9b420 | 2018-05-10 19:56:08 -0700 | [diff] [blame] | 37 | EffectsFactoryHalHidl(); |
| 38 | |
Kevin Rocard | d4de288 | 2018-02-28 14:33:38 -0800 | [diff] [blame] | 39 | // Returns the number of different effects in all loaded libraries. |
| 40 | virtual status_t queryNumberEffects(uint32_t *pNumEffects); |
| 41 | |
| 42 | // Returns a descriptor of the next available effect. |
| 43 | virtual status_t getDescriptor(uint32_t index, |
| 44 | effect_descriptor_t *pDescriptor); |
| 45 | |
| 46 | virtual status_t getDescriptor(const effect_uuid_t *pEffectUuid, |
| 47 | effect_descriptor_t *pDescriptor); |
| 48 | |
| 49 | // Creates an effect engine of the specified type. |
| 50 | // To release the effect engine, it is necessary to release references |
| 51 | // to the returned effect object. |
| 52 | virtual status_t createEffect(const effect_uuid_t *pEffectUuid, |
| 53 | int32_t sessionId, int32_t ioId, |
| 54 | sp<EffectHalInterface> *effect); |
| 55 | |
| 56 | virtual status_t dumpEffects(int fd); |
| 57 | |
| 58 | status_t allocateBuffer(size_t size, sp<EffectBufferHalInterface>* buffer) override; |
| 59 | status_t mirrorBuffer(void* external, size_t size, |
| 60 | sp<EffectBufferHalInterface>* buffer) override; |
| 61 | |
| 62 | private: |
Kevin Rocard | d4de288 | 2018-02-28 14:33:38 -0800 | [diff] [blame] | 63 | sp<IEffectsFactory> mEffectsFactory; |
| 64 | hidl_vec<EffectDescriptor> mLastDescriptors; |
| 65 | |
Kevin Rocard | d4de288 | 2018-02-28 14:33:38 -0800 | [diff] [blame] | 66 | status_t queryAllDescriptors(); |
| 67 | }; |
| 68 | |
Kevin Rocard | df9b420 | 2018-05-10 19:56:08 -0700 | [diff] [blame] | 69 | sp<EffectsFactoryHalInterface> createEffectsFactoryHal() { |
| 70 | return new EffectsFactoryHalHidl(); |
| 71 | } |
| 72 | |
Kevin Rocard | 070e751 | 2018-05-22 09:29:13 -0700 | [diff] [blame] | 73 | } // namespace CPP_VERSION |
Mikhail Naganov | 595caa3 | 2018-12-13 11:08:28 -0800 | [diff] [blame] | 74 | } // namespace effect |
Kevin Rocard | d4de288 | 2018-02-28 14:33:38 -0800 | [diff] [blame] | 75 | } // namespace android |
| 76 | |
Kevin Rocard | df9b420 | 2018-05-10 19:56:08 -0700 | [diff] [blame] | 77 | #endif // ANDROID_HARDWARE_EFFECTS_FACTORY_HAL_HIDL_H |