blob: c64ca3a5ca2504a098e8a71996d0546ee75e1761 [file] [log] [blame]
Kevin Rocardd4de2882018-02-28 14:33:38 -08001/*
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
Shunkai Yaodca65ce2022-12-02 05:35:41 +000017#pragma once
Kevin Rocardd4de2882018-02-28 14:33:38 -080018
Mikhail Naganov0288c752022-09-02 02:16:09 +000019#include <memory>
Shunkai Yaoe3e403d2023-04-18 23:14:25 +000020#include <vector>
Mikhail Naganov0288c752022-09-02 02:16:09 +000021
Kevin Rocard95213bf2018-11-08 17:16:57 -080022#include PATH(android/hardware/audio/effect/FILE_VERSION/IEffectsFactory.h)
Kevin Rocardd4de2882018-02-28 14:33:38 -080023#include <media/audiohal/EffectsFactoryHalInterface.h>
24
Mikhail Naganov288a3432022-03-25 00:29:56 +000025#include "EffectConversionHelperHidl.h"
Kevin Rocardd4de2882018-02-28 14:33:38 -080026
27namespace android {
Mikhail Naganov595caa32018-12-13 11:08:28 -080028namespace effect {
Kevin Rocardd4de2882018-02-28 14:33:38 -080029
Kevin Rocardd4de2882018-02-28 14:33:38 -080030using ::android::hardware::hidl_vec;
Mikhail Naganov595caa32018-12-13 11:08:28 -080031using namespace ::android::hardware::audio::effect::CPP_VERSION;
Kevin Rocardd4de2882018-02-28 14:33:38 -080032
Mikhail Naganov0288c752022-09-02 02:16:09 +000033class EffectDescriptorCache;
34
Shunkai Yaodca65ce2022-12-02 05:35:41 +000035class EffectsFactoryHalHidl final : public EffectsFactoryHalInterface,
36 public EffectConversionHelperHidl {
Kevin Rocardd4de2882018-02-28 14:33:38 -080037 public:
Kevin Rocardb9448c72019-06-25 16:08:29 -070038 EffectsFactoryHalHidl(sp<IEffectsFactory> effectsFactory);
Kevin Rocarddf9b4202018-05-10 19:56:08 -070039
Kevin Rocardd4de2882018-02-28 14:33:38 -080040 // Returns the number of different effects in all loaded libraries.
Shunkai Yaodca65ce2022-12-02 05:35:41 +000041 status_t queryNumberEffects(uint32_t *pNumEffects) override;
Kevin Rocardd4de2882018-02-28 14:33:38 -080042
43 // Returns a descriptor of the next available effect.
Shunkai Yaodca65ce2022-12-02 05:35:41 +000044 status_t getDescriptor(uint32_t index, effect_descriptor_t* pDescriptor) override;
Kevin Rocardd4de2882018-02-28 14:33:38 -080045
Shunkai Yaodca65ce2022-12-02 05:35:41 +000046 status_t getDescriptor(const effect_uuid_t* pEffectUuid,
47 effect_descriptor_t* pDescriptor) override;
Kevin Rocardd4de2882018-02-28 14:33:38 -080048
Shunkai Yaodca65ce2022-12-02 05:35:41 +000049 status_t getDescriptors(const effect_uuid_t* pEffectType,
50 std::vector<effect_descriptor_t>* descriptors) override;
Eric Laurent0ac7f8c2021-07-13 13:37:11 +020051
Kevin Rocardd4de2882018-02-28 14:33:38 -080052 // 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.
Shunkai Yaodca65ce2022-12-02 05:35:41 +000055 status_t createEffect(const effect_uuid_t* pEffectUuid, int32_t sessionId, int32_t ioId,
56 int32_t deviceId, sp<EffectHalInterface>* effect) override;
Kevin Rocardd4de2882018-02-28 14:33:38 -080057
Shunkai Yaodca65ce2022-12-02 05:35:41 +000058 status_t dumpEffects(int fd) override;
Eric Laurent9289bde2020-08-18 12:49:17 -070059
Kevin Rocardd4de2882018-02-28 14:33:38 -080060 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
Shunkai Yaodca65ce2022-12-02 05:35:41 +000064 android::detail::AudioHalVersionInfo getHalVersion() const override;
65
Shunkai Yaoe3e403d2023-04-18 23:14:25 +000066 const effectsConfig::EffectProcessings& getProcessings() const override;
67
Kevin Rocardd4de2882018-02-28 14:33:38 -080068 private:
Kevin Rocardd4de2882018-02-28 14:33:38 -080069 sp<IEffectsFactory> mEffectsFactory;
Mikhail Naganov0288c752022-09-02 02:16:09 +000070 std::unique_ptr<EffectDescriptorCache> mCache;
Shunkai Yaoe3e403d2023-04-18 23:14:25 +000071 // Configuration file parser result together with all processings from effect factory
72 const effectsConfig::EffectProcessings mEffectProcessings;
Kevin Rocardd4de2882018-02-28 14:33:38 -080073};
74
Mikhail Naganov595caa32018-12-13 11:08:28 -080075} // namespace effect
Kevin Rocardd4de2882018-02-28 14:33:38 -080076} // namespace android