OpenSLES_Android.h revision 1c853a41d9d9886e60618a7c878ce3912f46bf3c
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#define SL_ANDROID_ITEMKEY_BUFFERQUEUEEVENT ((SLuint32) 0x00000003) 219 220#define SL_ANDROIDBUFFERQUEUEEVENT_NONE ((SLuint32) 0x00000000) 221#define SL_ANDROIDBUFFERQUEUEEVENT_PROCESSED ((SLuint32) 0x00000001) 222#define SL_ANDROIDBUFFERQUEUEEVENT_UNREALIZED ((SLuint32) 0x00000002) 223#define SL_ANDROIDBUFFERQUEUEEVENT_CLEARED ((SLuint32) 0x00000004) 224#define SL_ANDROIDBUFFERQUEUEEVENT_STOPPED ((SLuint32) 0x00000008) 225#define SL_ANDROIDBUFFERQUEUEEVENT_ERROR ((SLuint32) 0x00000010) 226#define SL_ANDROIDBUFFERQUEUEEVENT_CONTENT_END ((SLuint32) 0x00000020) 227 228typedef struct SLAndroidBufferItem_ { 229 SLuint32 itemKey; // identifies the item 230 SLuint32 itemSize; 231 SLuint8 itemData[0]; 232} SLAndroidBufferItem; 233 234typedef SLresult (SLAPIENTRY *slAndroidBufferQueueCallback)( 235 SLAndroidBufferQueueItf caller,/* input */ 236 void *pCallbackContext, /* input */ 237 void *pBufferContext, /* input */ 238 void *pBufferData, /* input */ 239 SLuint32 dataSize, /* input */ 240 SLuint32 dataUsed, /* input */ 241 const SLAndroidBufferItem *pItems,/* input */ 242 SLuint32 itemsLength /* input */ 243); 244 245typedef struct SLAndroidBufferQueueState_ { 246 SLuint32 count; 247 SLuint32 index; 248} SLAndroidBufferQueueState; 249 250struct SLAndroidBufferQueueItf_ { 251 SLresult (*RegisterCallback) ( 252 SLAndroidBufferQueueItf self, 253 slAndroidBufferQueueCallback callback, 254 void* pCallbackContext 255 ); 256 257 SLresult (*Clear) ( 258 SLAndroidBufferQueueItf self 259 ); 260 261 SLresult (*Enqueue) ( 262 SLAndroidBufferQueueItf self, 263 void *pBufferContext, 264 void *pData, 265 SLuint32 dataLength, 266 const SLAndroidBufferItem *pItems, 267 SLuint32 itemsLength 268 ); 269 270 SLresult (*GetState) ( 271 SLAndroidBufferQueueItf self, 272 SLAndroidBufferQueueState *pState 273 ); 274 275 SLresult (*SetCallbackEventsMask) ( 276 SLAndroidBufferQueueItf self, 277 SLuint32 eventFlags 278 ); 279 280 SLresult (*GetCallbackEventsMask) ( 281 SLAndroidBufferQueueItf self, 282 SLuint32 *pEventFlags 283 ); 284}; 285 286 287/*---------------------------------------------------------------------------*/ 288/* Android File Descriptor Data Locator */ 289/*---------------------------------------------------------------------------*/ 290 291/** Addendum to Data locator macros */ 292#define SL_DATALOCATOR_ANDROIDFD ((SLuint32) 0x800007BC) 293 294#define SL_DATALOCATOR_ANDROIDFD_USE_FILE_SIZE ((SLAint64) 0xFFFFFFFFFFFFFFFFll) 295 296/** File Descriptor-based data locator definition, locatorType must be SL_DATALOCATOR_ANDROIDFD */ 297typedef struct SLDataLocator_AndroidFD_ { 298 SLuint32 locatorType; 299 SLint32 fd; 300 SLAint64 offset; 301 SLAint64 length; 302} SLDataLocator_AndroidFD; 303 304 305/*---------------------------------------------------------------------------*/ 306/* Android Android Simple Buffer Queue Data Locator */ 307/*---------------------------------------------------------------------------*/ 308 309/** Addendum to Data locator macros */ 310#define SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE ((SLuint32) 0x800007BD) 311 312/** BufferQueue-based data locator definition where locatorType must be SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE*/ 313typedef struct SLDataLocator_AndroidSimpleBufferQueue { 314 SLuint32 locatorType; 315 SLuint32 numBuffers; 316} SLDataLocator_AndroidSimpleBufferQueue; 317 318 319/*---------------------------------------------------------------------------*/ 320/* Android Buffer Queue Data Locator */ 321/*---------------------------------------------------------------------------*/ 322 323/** Addendum to Data locator macros */ 324#define SL_DATALOCATOR_ANDROIDBUFFERQUEUE ((SLuint32) 0x800007BE) 325 326/** Android Buffer Queue-based data locator definition, 327 * locatorType must be SL_DATALOCATOR_ANDROIDBUFFERQUEUE */ 328typedef struct SLDataLocator_AndroidBufferQueue_ { 329 SLuint32 locatorType; 330 SLuint32 numBuffers; 331} SLDataLocator_AndroidBufferQueue; 332 333#ifdef __cplusplus 334} 335#endif /* __cplusplus */ 336 337#endif /* OPENSL_ES_ANDROID_H_ */ 338