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