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 <memory> 21 22 #include PATH(android/hardware/audio/effect/FILE_VERSION/IEffectsFactory.h) 23 #include <media/audiohal/EffectsFactoryHalInterface.h> 24 25 #include "EffectConversionHelperHidl.h" 26 27 namespace android { 28 namespace effect { 29 30 using ::android::hardware::hidl_vec; 31 using namespace ::android::hardware::audio::effect::CPP_VERSION; 32 33 class EffectDescriptorCache; 34 35 class EffectsFactoryHalHidl : public EffectsFactoryHalInterface, public EffectConversionHelperHidl 36 { 37 public: 38 EffectsFactoryHalHidl(sp<IEffectsFactory> effectsFactory); 39 40 // Returns the number of different effects in all loaded libraries. 41 virtual status_t queryNumberEffects(uint32_t *pNumEffects); 42 43 // Returns a descriptor of the next available effect. 44 virtual status_t getDescriptor(uint32_t index, 45 effect_descriptor_t *pDescriptor); 46 47 virtual status_t getDescriptor(const effect_uuid_t *pEffectUuid, 48 effect_descriptor_t *pDescriptor); 49 50 virtual status_t getDescriptors(const effect_uuid_t *pEffectType, 51 std::vector<effect_descriptor_t> *descriptors); 52 53 // Creates an effect engine of the specified type. 54 // To release the effect engine, it is necessary to release references 55 // to the returned effect object. 56 virtual status_t createEffect(const effect_uuid_t *pEffectUuid, 57 int32_t sessionId, int32_t ioId, int32_t deviceId, 58 sp<EffectHalInterface> *effect); 59 60 virtual status_t dumpEffects(int fd); 61 getHalVersion()62 virtual float getHalVersion() { return MAJOR_VERSION + (float)MINOR_VERSION / 10; } 63 64 status_t allocateBuffer(size_t size, sp<EffectBufferHalInterface>* buffer) override; 65 status_t mirrorBuffer(void* external, size_t size, 66 sp<EffectBufferHalInterface>* buffer) override; 67 68 private: 69 sp<IEffectsFactory> mEffectsFactory; 70 std::unique_ptr<EffectDescriptorCache> mCache; 71 }; 72 73 } // namespace effect 74 } // namespace android 75 76 #endif // ANDROID_HARDWARE_EFFECTS_FACTORY_HAL_HIDL_H 77