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 #include <vector> 19 20 #include <media/audiohal/EffectHalInterface.h> 21 #include <media/EffectsConfig.h> 22 #include <system/audio_effect.h> 23 #include <utils/Errors.h> 24 #include <utils/RefBase.h> 25 26 #include "AudioHalVersionInfo.h" 27 #include "FactoryHal.h" 28 29 namespace android { 30 31 class EffectsFactoryHalInterface : public RefBase 32 { 33 public: 34 // Returns the number of different effects in all loaded libraries. 35 virtual status_t queryNumberEffects(uint32_t *pNumEffects) = 0; 36 37 // Returns a descriptor of the next available effect. 38 virtual status_t getDescriptor(uint32_t index, effect_descriptor_t* pDescriptor) = 0; 39 40 virtual status_t getDescriptor(const effect_uuid_t* pEffectUuid, 41 effect_descriptor_t* pDescriptor) = 0; 42 43 virtual status_t getDescriptors(const effect_uuid_t *pEffectType, 44 std::vector<effect_descriptor_t> *descriptors) = 0; 45 46 virtual std::shared_ptr<const effectsConfig::Processings> getProcessings() const = 0; 47 48 // status_t if parser return error, skipped elements if parsing result is OK (always 0 for AIDL) 49 virtual error::Result<size_t> getSkippedElements() const = 0; 50 51 // Creates an effect engine of the specified type. 52 // To release the effect engine, it is necessary to release references 53 // to the returned effect object. 54 virtual status_t createEffect(const effect_uuid_t* pEffectUuid, int32_t sessionId, int32_t ioId, 55 int32_t deviceId, sp<EffectHalInterface>* effect) = 0; 56 57 virtual status_t dumpEffects(int fd) = 0; 58 59 static sp<EffectsFactoryHalInterface> create(); 60 61 virtual status_t allocateBuffer(size_t size, sp<EffectBufferHalInterface>* buffer) = 0; 62 virtual status_t mirrorBuffer(void* external, size_t size, 63 sp<EffectBufferHalInterface>* buffer) = 0; 64 65 virtual android::detail::AudioHalVersionInfo getHalVersion() const = 0; 66 67 // Helper function to compare effect uuid to EFFECT_UUID_NULL. 68 static bool isNullUuid(const effect_uuid_t* pEffectUuid); 69 70 protected: 71 // Subclasses can not be constructed directly by clients. EffectsFactoryHalInterface()72 EffectsFactoryHalInterface() {} 73 ~EffectsFactoryHalInterface()74 virtual ~EffectsFactoryHalInterface() {} 75 }; 76 77 } // namespace android 78