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 #pragma once 18 19 #include <memory> 20 #include <vector> 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 final : public EffectsFactoryHalInterface, 36 public EffectConversionHelperHidl { 37 public: 38 EffectsFactoryHalHidl(sp<IEffectsFactory> effectsFactory); 39 40 // Returns the number of different effects in all loaded libraries. 41 status_t queryNumberEffects(uint32_t *pNumEffects) override; 42 43 // Returns a descriptor of the next available effect. 44 status_t getDescriptor(uint32_t index, effect_descriptor_t* pDescriptor) override; 45 46 status_t getDescriptor(const effect_uuid_t* pEffectUuid, 47 effect_descriptor_t* pDescriptor) override; 48 49 status_t getDescriptors(const effect_uuid_t* pEffectType, 50 std::vector<effect_descriptor_t>* descriptors) override; 51 52 // Creates an effect engine of the specified type. 53 // To release the effect engine, it is necessary to release references 54 // to the returned effect object. 55 status_t createEffect(const effect_uuid_t* pEffectUuid, int32_t sessionId, int32_t ioId, 56 int32_t deviceId, sp<EffectHalInterface>* effect) override; 57 58 status_t dumpEffects(int fd) override; 59 60 status_t allocateBuffer(size_t size, sp<EffectBufferHalInterface>* buffer) override; 61 status_t mirrorBuffer(void* external, size_t size, 62 sp<EffectBufferHalInterface>* buffer) override; 63 64 android::detail::AudioHalVersionInfo getHalVersion() const override; 65 66 std::shared_ptr<const effectsConfig::Processings> getProcessings() const override; 67 68 ::android::error::Result<size_t> getSkippedElements() const override; 69 70 private: 71 const sp<IEffectsFactory> mEffectsFactory; 72 const std::unique_ptr<EffectDescriptorCache> mCache; 73 /** 74 * Configuration file parser result, used by getProcessings() and getConfigParseResult(). 75 * This struct holds the result of parsing a configuration file. The result includes the parsed 76 * configuration data, as well as any errors that occurred during parsing. 77 */ 78 const effectsConfig::ParsingResult mParsingResult; 79 }; 80 81 } // namespace effect 82 } // namespace android 83