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