1 /*
2 * Copyright (C) 2004-2010 NXP Software
3 * Copyright (C) 2010 The Android Open Source Project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 /****************************************************************************************/
19 /* */
20 /* Header file defining the standard LifeVibes types for use in the application layer */
21 /* interface of all LifeVibes modules */
22 /* */
23 /****************************************************************************************/
24
25 #ifndef LVM_TYPES_H
26 #define LVM_TYPES_H
27
28 #include <stdint.h>
29 #include <system/audio.h>
30 /****************************************************************************************/
31 /* */
32 /* definitions */
33 /* */
34 /****************************************************************************************/
35
36 #define LVM_NULL 0 /* NULL pointer */
37
38 #define LVM_TRUE 1 /* Booleans */
39 #define LVM_FALSE 0
40
41 #define LVM_MAXINT_8 127 /* Maximum positive integer size */
42 #define LVM_MAXINT_16 32767
43 #define LVM_MAXINT_32 2147483647
44 #define LVM_MAXENUM 2147483647
45
46 #define LVM_MODULEID_MASK 0xFF00 /* Mask to extract the calling module ID from callbackId */
47 #define LVM_EVENTID_MASK 0x00FF /* Mask to extract the callback event from callbackId */
48
49 /* Memory table*/
50 #define LVM_MEMREGION_PERSISTENT_SLOW_DATA 0 /* Offset to the instance memory region */
51 #define LVM_MEMREGION_PERSISTENT_FAST_DATA 1 /* Offset to the persistent data memory region */
52 #define LVM_MEMREGION_PERSISTENT_FAST_COEF \
53 2 /* Offset to the persistent coefficient memory region */
54 #define LVM_MEMREGION_TEMPORARY_FAST 3 /* Offset to temporary memory region */
55
56 #define LVM_NR_MEMORY_REGIONS 4 /* Number of memory regions */
57
58 /****************************************************************************************/
59 /* */
60 /* Basic types */
61 /* */
62 /****************************************************************************************/
63
64 typedef char LVM_CHAR; /* ASCII character */
65
66 typedef int8_t LVM_INT8; /* Signed 8-bit word */
67 typedef uint8_t LVM_UINT8; /* Unsigned 8-bit word */
68
69 typedef int16_t LVM_INT16; /* Signed 16-bit word */
70 typedef uint16_t LVM_UINT16; /* Unsigned 16-bit word */
71
72 typedef int32_t LVM_INT32; /* Signed 32-bit word */
73 typedef uint32_t LVM_UINT32; /* Unsigned 32-bit word */
74 typedef int64_t LVM_INT64; /* Signed 64-bit word */
75
76 #define LVM_MAXFLOAT 1.f
77
78 typedef float LVM_FLOAT; /* single precision floating point */
79
80 // Select whether we expose int16_t or float buffers.
81
82 #define EFFECT_BUFFER_FORMAT AUDIO_FORMAT_PCM_FLOAT
83 typedef float effect_buffer_t;
84
85 #define LVM_MAX_CHANNELS FCC_24
86
87 /****************************************************************************************/
88 /* */
89 /* Standard Enumerated types */
90 /* */
91 /****************************************************************************************/
92
93 /* Operating mode */
94 typedef enum { LVM_MODE_OFF = 0, LVM_MODE_ON = 1, LVM_MODE_DUMMY = LVM_MAXENUM } LVM_Mode_en;
95
96 /* Format */
97 typedef enum {
98 LVM_STEREO = 0,
99 LVM_MONOINSTEREO = 1,
100 LVM_MONO = 2,
101 LVM_MULTICHANNEL = 3,
102 LVM_SOURCE_DUMMY = LVM_MAXENUM
103 } LVM_Format_en;
104
105 /* LVM sampling rates */
106 typedef enum {
107 LVM_FS_8000 = 0,
108 LVM_FS_11025 = 1,
109 LVM_FS_12000 = 2,
110 LVM_FS_16000 = 3,
111 LVM_FS_22050 = 4,
112 LVM_FS_24000 = 5,
113 LVM_FS_32000 = 6,
114 LVM_FS_44100 = 7,
115 LVM_FS_48000 = 8,
116 LVM_FS_88200 = 9,
117 LVM_FS_96000 = 10,
118 LVM_FS_176400 = 11,
119 LVM_FS_192000 = 12,
120 LVM_FS_INVALID = LVM_MAXENUM - 1,
121 LVM_FS_DUMMY = LVM_MAXENUM
122 } LVM_Fs_en;
123
lvmFsForSampleRate(int sampleRate)124 static inline LVM_Fs_en lvmFsForSampleRate(int sampleRate) {
125 static const std::map<int, LVM_Fs_en> kLVMFsMap = {
126 {8000, LVM_FS_8000}, {11025, LVM_FS_11025}, {12000, LVM_FS_12000},
127 {16000, LVM_FS_16000}, {22050, LVM_FS_22050}, {24000, LVM_FS_24000},
128 {32000, LVM_FS_32000}, {44100, LVM_FS_44100}, {48000, LVM_FS_48000},
129 {88200, LVM_FS_88200}, {96000, LVM_FS_96000}, {176400, LVM_FS_176400},
130 {192000, LVM_FS_192000}};
131 if (kLVMFsMap.find(sampleRate) != kLVMFsMap.end()) {
132 return kLVMFsMap.at(sampleRate);
133 }
134 return LVM_FS_INVALID;
135 }
136
137 /****************************************************************************************/
138 /* */
139 /* Standard Function Prototypes */
140 /* */
141 /****************************************************************************************/
142 typedef LVM_INT32 (*LVM_Callback)(
143 void* pCallbackData, /* Pointer to the callback data structure */
144 void* pGeneralPurpose, /* General purpose pointer (e.g. to a data structure needed in the
145 callback) */
146 LVM_INT16 GeneralPurpose); /* General purpose variable (e.g. to be used as callback ID) */
147
148 /****************************************************************************************/
149 /* */
150 /* End of file */
151 /* */
152 /****************************************************************************************/
153
154 #endif /* LVM_TYPES_H */
155