OpenSLES_Android.h revision 6f0f5640d190b0187c356eb53bd96d9f9e49da60
1/*
2 * Copyright (C) 2010 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#ifndef OPENSL_ES_ANDROID_H_
18#define OPENSL_ES_ANDROID_H_
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24/*---------------------------------------------------------------------------*/
25/* Android common types                                                      */
26/*---------------------------------------------------------------------------*/
27
28typedef sl_int64_t             SLAint64;          /* 64 bit signed integer   */
29
30typedef sl_uint64_t            SLAuint64;         /* 64 bit unsigned integer */
31
32/*---------------------------------------------------------------------------*/
33/* Android Effect interface                                                  */
34/*---------------------------------------------------------------------------*/
35
36extern SL_API const SLInterfaceID SL_IID_ANDROIDEFFECT;
37
38/** Android Effect interface methods */
39
40struct SLAndroidEffectItf_;
41typedef const struct SLAndroidEffectItf_ * const * SLAndroidEffectItf;
42
43struct SLAndroidEffectItf_ {
44
45    SLresult (*CreateEffect) (SLAndroidEffectItf self,
46            SLInterfaceID effectImplementationId);
47
48    SLresult (*ReleaseEffect) (SLAndroidEffectItf self,
49            SLInterfaceID effectImplementationId);
50
51    SLresult (*SetEnabled) (SLAndroidEffectItf self,
52            SLInterfaceID effectImplementationId,
53            SLboolean enabled);
54
55    SLresult (*IsEnabled) (SLAndroidEffectItf self,
56            SLInterfaceID effectImplementationId,
57            SLboolean *pEnabled);
58
59    SLresult (*SendCommand) (SLAndroidEffectItf self,
60            SLInterfaceID effectImplementationId,
61            SLuint32 command,
62            SLuint32 commandSize,
63            void *pCommandData,
64            SLuint32 *replySize,
65            void *pReplyData);
66};
67
68
69/*---------------------------------------------------------------------------*/
70/* Android Effect Send interface                                             */
71/*---------------------------------------------------------------------------*/
72
73extern SL_API const SLInterfaceID SL_IID_ANDROIDEFFECTSEND;
74
75/** Android Effect Send interface methods */
76
77struct SLAndroidEffectSendItf_;
78typedef const struct SLAndroidEffectSendItf_ * const * SLAndroidEffectSendItf;
79
80struct SLAndroidEffectSendItf_ {
81    SLresult (*EnableEffectSend) (
82        SLAndroidEffectSendItf self,
83        SLInterfaceID effectImplementationId,
84        SLboolean enable,
85        SLmillibel initialLevel
86    );
87    SLresult (*IsEnabled) (
88        SLAndroidEffectSendItf self,
89        SLInterfaceID effectImplementationId,
90        SLboolean *pEnable
91    );
92    SLresult (*SetDirectLevel) (
93        SLAndroidEffectSendItf self,
94        SLmillibel directLevel
95    );
96    SLresult (*GetDirectLevel) (
97        SLAndroidEffectSendItf self,
98        SLmillibel *pDirectLevel
99    );
100    SLresult (*SetSendLevel) (
101        SLAndroidEffectSendItf self,
102        SLInterfaceID effectImplementationId,
103        SLmillibel sendLevel
104    );
105    SLresult (*GetSendLevel)(
106        SLAndroidEffectSendItf self,
107        SLInterfaceID effectImplementationId,
108        SLmillibel *pSendLevel
109    );
110};
111
112
113/*---------------------------------------------------------------------------*/
114/* Android Effect Capabilities interface                                     */
115/*---------------------------------------------------------------------------*/
116
117extern SL_API const SLInterfaceID SL_IID_ANDROIDEFFECTCAPABILITIES;
118
119/** Android Effect Capabilities interface methods */
120
121struct SLAndroidEffectCapabilitiesItf_;
122typedef const struct SLAndroidEffectCapabilitiesItf_ * const * SLAndroidEffectCapabilitiesItf;
123
124struct SLAndroidEffectCapabilitiesItf_ {
125
126    SLresult (*QueryNumEffects) (SLAndroidEffectCapabilitiesItf self,
127            SLuint32 *pNumSupportedEffects);
128
129
130    SLresult (*QueryEffect) (SLAndroidEffectCapabilitiesItf self,
131            SLuint32 index,
132            SLInterfaceID *pEffectType,
133            SLInterfaceID *pEffectImplementation,
134            SLchar *pName,
135            SLuint16 *pNameSize);
136};
137
138
139/*---------------------------------------------------------------------------*/
140/* Android Configuration interface                                           */
141/*---------------------------------------------------------------------------*/
142extern SL_API const SLInterfaceID SL_IID_ANDROIDCONFIGURATION;
143
144/** Android Configuration interface methods */
145
146struct SLAndroidConfigurationItf_;
147typedef const struct SLAndroidConfigurationItf_ * const * SLAndroidConfigurationItf;
148
149struct SLAndroidConfigurationItf_ {
150
151    SLresult (*SetConfiguration) (SLAndroidConfigurationItf self,
152            const SLchar *configKey,
153            const void *pConfigValue,
154            SLuint32 valueSize);
155
156    SLresult (*GetConfiguration) (SLAndroidConfigurationItf self,
157           const SLchar *configKey,
158           SLuint32 *pValueSize,
159           void *pConfigValue
160       );
161};
162
163
164/*---------------------------------------------------------------------------*/
165/* Android Simple Buffer Queue Interface                                     */
166/*---------------------------------------------------------------------------*/
167
168extern SL_API const SLInterfaceID SL_IID_ANDROIDSIMPLEBUFFERQUEUE;
169
170struct SLAndroidSimpleBufferQueueItf_;
171typedef const struct SLAndroidSimpleBufferQueueItf_ * const * SLAndroidSimpleBufferQueueItf;
172
173typedef void (SLAPIENTRY *slAndroidSimpleBufferQueueCallback)(
174	SLAndroidSimpleBufferQueueItf caller,
175	void *pContext
176);
177
178/** Android simple buffer queue state **/
179
180typedef struct SLAndroidSimpleBufferQueueState_ {
181	SLuint32	count;
182	SLuint32	index;
183} SLAndroidSimpleBufferQueueState;
184
185
186struct SLAndroidSimpleBufferQueueItf_ {
187	SLresult (*Enqueue) (
188		SLAndroidSimpleBufferQueueItf self,
189		const void *pBuffer,
190		SLuint32 size
191	);
192	SLresult (*Clear) (
193		SLAndroidSimpleBufferQueueItf self
194	);
195	SLresult (*GetState) (
196		SLAndroidSimpleBufferQueueItf self,
197		SLAndroidSimpleBufferQueueState *pState
198	);
199	SLresult (*RegisterCallback) (
200		SLAndroidSimpleBufferQueueItf self,
201		slAndroidSimpleBufferQueueCallback callback,
202		void* pContext
203	);
204};
205
206
207/*---------------------------------------------------------------------------*/
208/* Android Buffer Queue Interface                                            */
209/*---------------------------------------------------------------------------*/
210
211extern SL_API const SLInterfaceID SL_IID_ANDROIDBUFFERQUEUE;
212
213struct SLAndroidBufferQueueItf_;
214typedef const struct SLAndroidBufferQueueItf_ * const * SLAndroidBufferQueueItf;
215
216#define SL_ANDROID_ITEMKEY_NONE             ((SLuint32) 0x00000000)
217#define SL_ANDROID_ITEMKEY_EOS              ((SLuint32) 0x00000001)
218#define SL_ANDROID_ITEMKEY_DISCONTINUITY    ((SLuint32) 0x00000002)
219#define SL_ANDROID_ITEMKEY_BUFFERQUEUEEVENT ((SLuint32) 0x00000003)
220#define SL_ANDROID_ITEMKEY_FORMAT_CHANGE    ((SLuint32) 0x00000004)
221
222#define SL_ANDROIDBUFFERQUEUEEVENT_NONE        ((SLuint32) 0x00000000)
223#define SL_ANDROIDBUFFERQUEUEEVENT_PROCESSED   ((SLuint32) 0x00000001)
224#define SL_ANDROIDBUFFERQUEUEEVENT_UNREALIZED  ((SLuint32) 0x00000002)
225#define SL_ANDROIDBUFFERQUEUEEVENT_CLEARED     ((SLuint32) 0x00000004)
226#define SL_ANDROIDBUFFERQUEUEEVENT_STOPPED     ((SLuint32) 0x00000008)
227#define SL_ANDROIDBUFFERQUEUEEVENT_ERROR       ((SLuint32) 0x00000010)
228#define SL_ANDROIDBUFFERQUEUEEVENT_CONTENT_END ((SLuint32) 0x00000020)
229
230typedef struct SLAndroidBufferItem_ {
231    SLuint32 itemKey;  // identifies the item
232    SLuint32 itemSize;
233    SLuint8  itemData[0];
234} SLAndroidBufferItem;
235
236typedef SLresult (SLAPIENTRY *slAndroidBufferQueueCallback)(
237    SLAndroidBufferQueueItf caller,/* input */
238    void *pCallbackContext,        /* input */
239    void *pBufferContext,          /* input */
240    void *pBufferData,             /* input */
241    SLuint32 dataSize,             /* input */
242    SLuint32 dataUsed,             /* input */
243    const SLAndroidBufferItem *pItems,/* input */
244    SLuint32 itemsLength           /* input */
245);
246
247typedef struct SLAndroidBufferQueueState_ {
248    SLuint32    count;
249    SLuint32    index;
250} SLAndroidBufferQueueState;
251
252struct SLAndroidBufferQueueItf_ {
253    SLresult (*RegisterCallback) (
254        SLAndroidBufferQueueItf self,
255        slAndroidBufferQueueCallback callback,
256        void* pCallbackContext
257    );
258
259    SLresult (*Clear) (
260        SLAndroidBufferQueueItf self
261    );
262
263    SLresult (*Enqueue) (
264        SLAndroidBufferQueueItf self,
265        void *pBufferContext,
266        void *pData,
267        SLuint32 dataLength,
268        const SLAndroidBufferItem *pItems,
269        SLuint32 itemsLength
270    );
271
272    SLresult (*GetState) (
273        SLAndroidBufferQueueItf self,
274        SLAndroidBufferQueueState *pState
275    );
276
277    SLresult (*SetCallbackEventsMask) (
278            SLAndroidBufferQueueItf self,
279            SLuint32 eventFlags
280    );
281
282    SLresult (*GetCallbackEventsMask) (
283            SLAndroidBufferQueueItf self,
284            SLuint32 *pEventFlags
285    );
286};
287
288
289/*---------------------------------------------------------------------------*/
290/* Android File Descriptor Data Locator                                      */
291/*---------------------------------------------------------------------------*/
292
293/** Addendum to Data locator macros  */
294#define SL_DATALOCATOR_ANDROIDFD                ((SLuint32) 0x800007BC)
295
296#define SL_DATALOCATOR_ANDROIDFD_USE_FILE_SIZE ((SLAint64) 0xFFFFFFFFFFFFFFFFll)
297
298/** File Descriptor-based data locator definition, locatorType must be SL_DATALOCATOR_ANDROIDFD */
299typedef struct SLDataLocator_AndroidFD_ {
300    SLuint32        locatorType;
301    SLint32         fd;
302    SLAint64        offset;
303    SLAint64        length;
304} SLDataLocator_AndroidFD;
305
306
307/*---------------------------------------------------------------------------*/
308/* Android Android Simple Buffer Queue Data Locator                          */
309/*---------------------------------------------------------------------------*/
310
311/** Addendum to Data locator macros  */
312#define SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE ((SLuint32) 0x800007BD)
313
314/** BufferQueue-based data locator definition where locatorType must be SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE*/
315typedef struct SLDataLocator_AndroidSimpleBufferQueue {
316	SLuint32	locatorType;
317	SLuint32	numBuffers;
318} SLDataLocator_AndroidSimpleBufferQueue;
319
320
321/*---------------------------------------------------------------------------*/
322/* Android Buffer Queue Data Locator                                         */
323/*---------------------------------------------------------------------------*/
324
325/** Addendum to Data locator macros  */
326#define SL_DATALOCATOR_ANDROIDBUFFERQUEUE       ((SLuint32) 0x800007BE)
327
328/** Android Buffer Queue-based data locator definition,
329 *  locatorType must be SL_DATALOCATOR_ANDROIDBUFFERQUEUE */
330typedef struct SLDataLocator_AndroidBufferQueue_ {
331    SLuint32    locatorType;
332    SLuint32    numBuffers;
333} SLDataLocator_AndroidBufferQueue;
334
335#ifdef __cplusplus
336}
337#endif /* __cplusplus */
338
339#endif /* OPENSL_ES_ANDROID_H_ */
340