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