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