1/*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef EFFECTTYPES_H
17#define EFFECTTYPES_H
18
19#include <stdbool.h>
20#include <stdint.h>
21
22#ifndef HDI_BUFF_MAX_SIZE
23#define HDI_BUFF_MAX_SIZE (1024 * 200)
24#endif
25
26#ifndef HDI_CHECK_VALUE_RETURN
27#define HDI_CHECK_VALUE_RETURN(lv, compare, rv, ret) do { \
28    if ((lv) compare (rv)) { \
29        return ret; \
30    } \
31} while (false)
32#endif
33
34#ifndef HDI_CHECK_VALUE_RET_GOTO
35#define HDI_CHECK_VALUE_RET_GOTO(lv, compare, rv, ret, value, table) do { \
36    if ((lv) compare (rv)) { \
37        ret = value; \
38        goto table; \
39    } \
40} while (false)
41#endif
42
43#ifdef __cplusplus
44extern "C" {
45#endif /* __cplusplus */
46
47struct HdfSBuf;
48
49struct EffectInfo {
50    char* libName;
51    char* effectId;
52    int32_t ioDirection;
53};
54
55struct ControllerId {
56    char* libName;
57    char* effectId;
58};
59
60struct EffectControllerDescriptor {
61    char* effectId;
62    char* effectName;
63    char* libName;
64    char* supplier;
65};
66
67enum AudioEffectBufferTag {
68    EFFECT_BUFFER_VOID_TYPE = 0,
69    EFFECT_BUFFER_FLOAT_SIGNED_32 = 1 << 0,
70    EFFECT_BUFFER_SINGED_32 = 1 << 1,
71    EFFECT_BUFFER_SIGNED_16 = 1 << 2,
72    EFFECT_BUFFER_UNSIGNED_8 = 1 << 3,
73};
74
75struct AudioEffectBuffer {
76    uint32_t frameCount;
77    int32_t datatag;
78    int8_t* rawData;
79    uint32_t rawDataLen;
80};
81
82enum EffectCommandTableIndex {
83    AUDIO_EFFECT_COMMAND_INIT_CONTOLLER,
84    AUDIO_EFFECT_COMMAND_SET_CONFIG,
85    AUDIO_EFFECT_COMMAND_GET_CONFIG,
86    AUDIO_EFFECT_COMMAND_RESET,
87    AUDIO_EFFECT_COMMAND_ENABLE,
88    AUDIO_EFFECT_COMMAND_DISABLE,
89    AUDIO_EFFECT_COMMAND_SET_PARAM,
90    AUDIO_EFFECT_COMMAND_GET_PARAM,
91};
92
93bool EffectInfoBlockMarshalling(struct HdfSBuf *data, const struct EffectInfo *dataBlock);
94
95bool EffectInfoBlockUnmarshalling(struct HdfSBuf *data, struct EffectInfo *dataBlock);
96
97void EffectInfoFree(struct EffectInfo *dataBlock, bool freeSelf);
98
99bool ControllerIdBlockMarshalling(struct HdfSBuf *data, const struct ControllerId *dataBlock);
100
101bool ControllerIdBlockUnmarshalling(struct HdfSBuf *data, struct ControllerId *dataBlock);
102
103void ControllerIdFree(struct ControllerId *dataBlock, bool freeSelf);
104
105bool EffectControllerDescriptorBlockMarshalling(struct HdfSBuf *data, const struct EffectControllerDescriptor *dataBlock);
106
107bool EffectControllerDescriptorBlockUnmarshalling(struct HdfSBuf *data, struct EffectControllerDescriptor *dataBlock);
108
109void EffectControllerDescriptorFree(struct EffectControllerDescriptor *dataBlock, bool freeSelf);
110
111bool AudioEffectBufferBlockMarshalling(struct HdfSBuf *data, const struct AudioEffectBuffer *dataBlock);
112
113bool AudioEffectBufferBlockUnmarshalling(struct HdfSBuf *data, struct AudioEffectBuffer *dataBlock);
114
115void AudioEffectBufferFree(struct AudioEffectBuffer *dataBlock, bool freeSelf);
116
117
118#ifdef __cplusplus
119}
120#endif /* __cplusplus */
121
122#endif // EFFECTTYPES_H