OpenSLES_Android.h revision d158d31a6bbb06426b71c3d097b7768bc3fb79a3
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 *pContext, /* input */ 228 const void *pBufferData, /* input */ 229 SLuint32 dataSize, /* input */ 230 SLuint32 dataUsed, /* input */ 231 const SLAndroidBufferItem *pItems,/* input */ 232 SLuint32 itemsLength /* input */ 233); 234 235typedef struct SLAndroidBufferQueueState_ { 236 SLuint32 count; 237 SLuint32 index; 238} SLAndroidBufferQueueState; 239 240struct SLAndroidBufferQueueItf_ { 241 SLresult (*RegisterCallback) ( 242 SLAndroidBufferQueueItf self, 243 slAndroidBufferQueueCallback callback, 244 void* pContext 245 ); 246 247 SLresult (*Clear) ( 248 SLAndroidBufferQueueItf self 249 ); 250 251 SLresult (*Enqueue) ( 252 SLAndroidBufferQueueItf self, 253 const void *pData, 254 SLuint32 dataLength, 255 const SLAndroidBufferItem *pItems, 256 SLuint32 itemsLength 257 ); 258 259 // FIXME TBD if needed 260 /* 261 SLResult (*SetCallbackEventMask) ( 262 SLAndroidBufferQueueItf self, 263 SLuint32 eventMask 264 ); 265 SLResult (*GetCallbackEventMask) ( 266 SLAndroidBufferQueueItf self, 267 SLuint32 *pEventMask 268 ); 269 */ 270}; 271 272 273/*---------------------------------------------------------------------------*/ 274/* Android File Descriptor Data Locator */ 275/*---------------------------------------------------------------------------*/ 276 277/** Addendum to Data locator macros */ 278#define SL_DATALOCATOR_ANDROIDFD ((SLuint32) 0x800007BC) 279 280#define SL_DATALOCATOR_ANDROIDFD_USE_FILE_SIZE ((SLAint64) 0xFFFFFFFFFFFFFFFFll) 281 282/** File Descriptor-based data locator definition, locatorType must be SL_DATALOCATOR_ANDROIDFD */ 283typedef struct SLDataLocator_AndroidFD_ { 284 SLuint32 locatorType; 285 SLint32 fd; 286 SLAint64 offset; 287 SLAint64 length; 288} SLDataLocator_AndroidFD; 289 290 291/*---------------------------------------------------------------------------*/ 292/* Android Android Simple Buffer Queue Data Locator */ 293/*---------------------------------------------------------------------------*/ 294 295/** Addendum to Data locator macros */ 296#define SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE ((SLuint32) 0x800007BD) 297 298/** BufferQueue-based data locator definition where locatorType must be SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE*/ 299typedef struct SLDataLocator_AndroidSimpleBufferQueue { 300 SLuint32 locatorType; 301 SLuint32 numBuffers; 302} SLDataLocator_AndroidSimpleBufferQueue; 303 304 305/*---------------------------------------------------------------------------*/ 306/* Android Buffer Queue Data Locator */ 307/*---------------------------------------------------------------------------*/ 308 309/** Addendum to Data locator macros */ 310#define SL_DATALOCATOR_ANDROIDBUFFERQUEUE ((SLuint32) 0x800007BE) 311 312/** Android Buffer Queue-based data locator definition, 313 * locatorType must be SL_DATALOCATOR_ANDROIDBUFFERQUEUE */ 314typedef struct SLDataLocator_AndroidBufferQueue_ { 315 SLuint32 locatorType; 316 SLuint32 numBuffers; 317} SLDataLocator_AndroidBufferQueue; 318 319#ifdef __cplusplus 320} 321#endif /* __cplusplus */ 322 323#endif /* OPENSL_ES_ANDROID_H_ */ 324