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