sles_allinclusive.h revision 76dde6cd71bdb39459f38218e8aa2b7c19e790db
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#include "OpenSLES.h" 18#include <stddef.h> // offsetof 19#include <stdlib.h> // malloc 20#include <string.h> // memcmp 21#include <stdio.h> // debugging 22#include <assert.h> // debugging 23#include <pthread.h> 24#include <unistd.h> // usleep 25 26#include "MPH.h" 27#include "MPH_to.h" 28#include "devices.h" 29 30#ifdef USE_SNDFILE 31#include <sndfile.h> 32#endif // USE_SNDFILE 33 34#ifdef USE_SDL 35#include <SDL/SDL_audio.h> 36#endif // USE_SDL 37 38#if defined(USE_ANDROID) 39#include "media/AudioSystem.h" 40#include "media/AudioTrack.h" 41#include "media/mediaplayer.h" 42#define ANDROID_SL_MILLIBEL_MAX 0 43#endif 44 45#ifdef USE_OUTPUTMIXEXT 46#include "OutputMixExt.h" 47#endif 48 49// Hook functions 50 51typedef void (*VoidHook)(void *self); 52typedef SLresult (*StatusHook)(void *self); 53 54// Describes how an interface is related to a given class 55 56#define INTERFACE_IMPLICIT 0 57#define INTERFACE_EXPLICIT 1 58#define INTERFACE_OPTIONAL 2 59#define INTERFACE_DYNAMIC 3 60#define INTERFACE_DYNAMIC_GAME INTERFACE_DYNAMIC 61#define INTERFACE_DYNAMIC_MUSIC INTERFACE_DYNAMIC 62#define INTERFACE_DYNAMIC_MUSIC_GAME INTERFACE_DYNAMIC 63#define INTERFACE_EXPLICIT_GAME INTERFACE_EXPLICIT 64#define INTERFACE_GAME INTERFACE_OPTIONAL 65#define INTERFACE_GAME_MUSIC INTERFACE_OPTIONAL 66#define INTERFACE_MUSIC_GAME INTERFACE_OPTIONAL 67#define INTERFACE_OPTIONAL_DYNAMIC INTERFACE_DYNAMIC 68#define INTERFACE_PHONE_GAME INTERFACE_OPTIONAL 69#define INTERFACE_TBD INTERFACE_IMPLICIT 70 71// Maps an interface ID to its offset within the class that exposes it 72 73struct iid_vtable { 74 unsigned char mMPH; 75 unsigned char mInterface; // relationship 76 /*size_t*/ unsigned short mOffset; 77}; 78 79// Per-class const data shared by all instances of the same class 80 81typedef struct { 82 // needed by all classes (class class, the superclass of all classes) 83 const struct iid_vtable *mInterfaces; 84 SLuint32 mInterfaceCount; 85 const signed char *mMPH_to_index; 86 // FIXME not yet used 87 const char * const mName; 88 size_t mSize; 89 SLuint32 mObjectID; 90 StatusHook mRealize; 91 StatusHook mResume; 92 VoidHook mDestroy; 93 // append per-class data here 94} ClassTable; 95 96#ifdef USE_OUTPUTMIXEXT 97 98// Track describes each input to OutputMixer 99// FIXME not for Android 100 101struct Track { 102 const SLDataFormat_PCM *mDfPcm; 103 struct BufferQueue_interface *mBufferQueue; 104 struct Play_interface *mPlay; // mixer examines this track if non-NULL 105 const void *mReader; // pointer to next frame in BufferHeader.mBuffer 106 SLuint32 mAvail; // number of available bytes 107}; 108 109#endif 110 111// BufferHeader describes each element of a BufferQueue, other than the data 112 113struct BufferHeader { 114 const void *mBuffer; 115 SLuint32 mSize; 116}; 117 118#ifdef USE_OUTPUTMIXEXT 119 120// stereo is a frame consisting of a pair of 16-bit PCM samples 121 122typedef struct { 123 short left; 124 short right; 125} stereo; 126 127#endif 128 129#ifdef USE_SNDFILE 130 131struct SndFile { 132 // save URI also? 133 SLchar *mPathname; 134 SNDFILE *mSNDFILE; 135 // These are used when Enqueue returns SL_RESULT_BUFFER_INSUFFICIENT 136 const void *mRetryBuffer; 137 SLuint32 mRetrySize; 138 SLboolean mIs0; // which buffer to use next 139 // FIXME magic numbers 140 short mBuffer0[512]; 141 short mBuffer1[512]; 142}; 143 144#endif // USE_SNDFILE 145 146#ifdef __cplusplus 147#define this this_ 148#endif 149 150/* Interface structures */ 151 152typedef struct Object_interface { 153 const struct SLObjectItf_ *mItf; 154 // FIXME probably not needed for an Object, as it is always first, 155 // but look for lingering code that assumes it is here before deleting 156 struct Object_interface *mThis; 157 const ClassTable *mClass; 158 volatile SLuint32 mState; 159 slObjectCallback mCallback; 160 void *mContext; 161 unsigned mExposedMask; // exposed interfaces 162 unsigned mLossOfControlMask; // interfaces with loss of control enabled 163 SLint32 mPriority; 164 SLboolean mPreemptable; 165 pthread_mutex_t mMutex; 166 pthread_cond_t mCond; 167 // FIXME also an object ID for RPC 168 // FIXME and a human-readable name for debugging 169} IObject; 170 171#include "locks.h" 172 173typedef struct { 174 const struct SL3DCommitItf_ *mItf; 175 IObject *mThis; 176 SLboolean mDeferred; 177 SLuint32 mGeneration; // incremented each master clock cycle 178} I3DCommit; 179 180// FIXME move 181enum CartesianSphericalActive { 182 CARTESIAN_COMPUTED_SPHERICAL_SET, 183 CARTESIAN_REQUESTED_SPHERICAL_SET, 184 CARTESIAN_UNKNOWN_SPHERICAL_SET, 185 CARTESIAN_SET_SPHERICAL_COMPUTED, // not in 1.0.1 186 CARTESIAN_SET_SPHERICAL_REQUESTED, // not in 1.0.1 187 CARTESIAN_SET_SPHERICAL_UNKNOWN 188}; 189 190typedef struct { 191 const struct SL3DDopplerItf_ *mItf; 192 IObject *mThis; 193 // The API allows client to specify either Cartesian and spherical velocities. 194 // But an implementation will likely prefer one or the other. So for 195 // maximum portablity, we maintain both units and an indication of which 196 // unit was set most recently. In addition, we keep a flag saying whether 197 // the other unit has been derived yet. It can take significant time 198 // to compute the other unit, so this may be deferred to another thread. 199 // For this reason we also keep an indication of whether the secondary 200 // has been computed yet, and its accuracy. 201 // Though only one unit is primary at a time, a union is inappropriate: 202 // the application might read in both units (not in 1.0.1), 203 // and due to multi-threading concerns. 204 SLVec3D mVelocityCartesian; 205 struct { 206 SLmillidegree mAzimuth; 207 SLmillidegree mElevation; 208 SLmillidegree mSpeed; 209 } mVelocitySpherical; 210 enum CartesianSphericalActive mVelocityActive; 211 SLpermille mDopplerFactor; 212} I3DDoppler; 213 214typedef struct { 215 const struct SL3DGroupingItf_ *mItf; 216 IObject *mThis; 217 SLObjectItf mGroup; 218 // FIXME link to group's set 219} I3DGrouping; 220 221// FIXME move 222enum AnglesVectorsActive { 223 ANGLES_COMPUTED_VECTORS_SET, // not in 1.0.1 224 ANGLES_REQUESTED_VECTORS_SET, // not in 1.0.1 225 ANGLES_UNKNOWN_VECTORS_SET, 226 ANGLES_SET_VECTORS_COMPUTED, 227 ANGLES_SET_VECTORS_REQUESTED, 228 ANGLES_SET_VECTORS_UNKNOWN 229}; 230 231typedef struct { 232 const struct SL3DLocationItf_ *mItf; 233 IObject *mThis; 234 SLVec3D mLocationCartesian; 235 struct { 236 SLmillidegree mAzimuth; 237 SLmillidegree mElevation; 238 SLmillimeter mDistance; 239 } mLocationSpherical; 240 enum CartesianSphericalActive mLocationActive; 241 struct { 242 SLmillidegree mHeading; 243 SLmillidegree mPitch; 244 SLmillidegree mRoll; 245 } mOrientationAngles; 246 struct { 247 SLVec3D mFront; 248 SLVec3D mAbove; 249 SLVec3D mUp; 250 } mOrientationVectors; 251 enum AnglesVectorsActive mOrientationActive; 252 // Rotations can be slow, so are deferred. 253 SLmillidegree mTheta; 254 SLVec3D mAxis; 255 SLboolean mRotatePending; 256} I3DLocation; 257 258typedef struct { 259 const struct SL3DMacroscopicItf_ *mItf; 260 IObject *mThis; 261 struct { 262 SLmillimeter mWidth; 263 SLmillimeter mHeight; 264 SLmillimeter mDepth; 265 } mSize; 266 struct { 267 SLmillimeter mHeading; 268 SLmillimeter mPitch; 269 SLmillimeter mRoll; 270 } mOrientationAngles; 271 struct { 272 SLVec3D mFront; 273 SLVec3D mUp; 274 } mOrientationVectors; 275 enum AnglesVectorsActive mOrientationActive; 276 // FIXME no longer needed? was for optimization 277 // SLuint32 mGeneration; 278 // Rotations can be slow, so are deferred. 279 SLmillidegree mTheta; 280 SLVec3D mAxis; 281 SLboolean mRotatePending; 282} I3DMacroscopic; 283 284typedef struct { 285 const struct SL3DSourceItf_ *mItf; 286 IObject *mThis; 287 SLboolean mHeadRelative; 288 SLboolean mRolloffMaxDistanceMute; 289 SLmillimeter mMaxDistance; 290 SLmillimeter mMinDistance; 291 SLmillidegree mConeInnerAngle; 292 SLmillidegree mConeOuterAngle; 293 SLmillibel mConeOuterLevel; 294 SLpermille mRolloffFactor; 295 SLpermille mRoomRolloffFactor; 296 SLuint8 mDistanceModel; 297} I3DSource; 298 299typedef struct { 300 const struct SLAudioDecoderCapabilitiesItf_ *mItf; 301 IObject *mThis; 302} IAudioDecoderCapabilities; 303 304typedef struct { 305 const struct SLAudioEncoderItf_ *mItf; 306 IObject *mThis; 307 SLAudioEncoderSettings mSettings; 308} IAudioEncoder; 309 310typedef struct { 311 const struct SLAudioEncoderCapabilitiesItf_ *mItf; 312 IObject *mThis; 313} IAudioEncoderCapabilities; 314 315typedef struct { 316 const struct SLAudioIODeviceCapabilitiesItf_ *mItf; 317 IObject *mThis; 318 slAvailableAudioInputsChangedCallback mAvailableAudioInputsChangedCallback; 319 void *mAvailableAudioInputsChangedContext; 320 slAvailableAudioOutputsChangedCallback mAvailableAudioOutputsChangedCallback; 321 void *mAvailableAudioOutputsChangedContext; 322 slDefaultDeviceIDMapChangedCallback mDefaultDeviceIDMapChangedCallback; 323 void *mDefaultDeviceIDMapChangedContext; 324} IAudioIODeviceCapabilities; 325 326typedef struct { 327 const struct SLBassBoostItf_ *mItf; 328 IObject *mThis; 329 SLboolean mEnabled; 330 SLpermille mStrength; 331} IBassBoost; 332 333typedef struct BufferQueue_interface { 334 const struct SLBufferQueueItf_ *mItf; 335 IObject *mThis; 336 volatile SLBufferQueueState mState; 337 slBufferQueueCallback mCallback; 338 void *mContext; 339 SLuint32 mNumBuffers; 340 struct BufferHeader *mArray; 341 struct BufferHeader *mFront, *mRear; 342 SLuint32 mSizeConsumed; 343 // saves a malloc in the typical case 344#define BUFFER_HEADER_TYPICAL 4 345 struct BufferHeader mTypical[BUFFER_HEADER_TYPICAL+1]; 346} IBufferQueue; 347 348typedef struct { 349 const struct SLDeviceVolumeItf_ *mItf; 350 IObject *mThis; 351 SLint32 mVolume[2]; // FIXME Hard-coded for default in/out 352} IDeviceVolume; 353 354typedef struct { 355 const struct SLDynamicInterfaceManagementItf_ *mItf; 356 IObject *mThis; 357 unsigned mAddedMask; // added interfaces, a subset of exposed interfaces 358 slDynamicInterfaceManagementCallback mCallback; 359 void *mContext; 360} IDynamicInterfaceManagement; 361 362typedef struct { 363 const struct SLDynamicSourceItf_ *mItf; 364 IObject *mThis; 365 SLDataSource *mDataSource; 366} IDynamicSource; 367 368// FIXME Move this elsewhere 369 370#define AUX_ENVIRONMENTALREVERB 0 371#define AUX_PRESETREVERB 1 372#define AUX_MAX 2 373 374#if 0 375static const unsigned char AUX_to_MPH[AUX_MAX] = { 376 MPH_ENVIRONMENTALREVERB, 377 MPH_PRESETREVERB 378}; 379#endif 380 381// private 382 383struct EnableLevel { 384 SLboolean mEnable; 385 SLmillibel mSendLevel; 386}; 387 388typedef struct { 389 const struct SLEffectSendItf_ *mItf; 390 IObject *mThis; 391 struct OutputMix_class *mOutputMix; 392 SLmillibel mDirectLevel; 393 struct EnableLevel mEnableLevels[AUX_MAX]; 394} IEffectSend; 395 396// private 397 398typedef struct { 399 const struct SLEngineItf_ *mItf; 400 IObject *mThis; 401 SLboolean mLossOfControlGlobal; 402 // FIXME Per-class non-const data such as vector of created objects. 403 // Each engine is its own universe. 404 SLuint32 mInstanceCount; 405 // Vector<Type> instances; 406 // FIXME set of objects 407#define INSTANCE_MAX 32 // FIXME no magic numbers 408 IObject *mInstances[INSTANCE_MAX]; 409} IEngine; 410 411typedef struct { 412 const struct SLEngineCapabilitiesItf_ *mItf; 413 IObject *mThis; 414 SLboolean mThreadSafe; 415} IEngineCapabilities; 416 417typedef struct { 418 const struct SLEnvironmentalReverbItf_ *mItf; 419 IObject *mThis; 420 SLEnvironmentalReverbSettings mProperties; 421} IEnvironmentalReverb; 422 423// FIXME move 424struct EqualizerBand { 425 SLmilliHertz mMin; 426 SLmilliHertz mCenter; 427 SLmilliHertz mMax; 428}; 429 430typedef struct { 431 const struct SLEqualizerItf_ *mItf; 432 IObject *mThis; 433 SLboolean mEnabled; 434 SLuint16 mPreset; 435 SLmillibel *mLevels; 436 // const 437 SLuint16 mNumPresets; 438 SLuint16 mNumBands; 439 const struct EqualizerBand *mBands; 440 const SLchar * const *mPresetNames; 441 SLmillibel mBandLevelRangeMin; 442 SLmillibel mBandLevelRangeMax; 443} IEqualizer; 444 445typedef struct { 446 const struct SLLEDArrayItf_ *mItf; 447 IObject *mThis; 448 SLuint32 mLightMask; 449 SLHSL *mColor; 450 // const 451 SLuint8 mCount; 452} ILEDArray; 453 454// FIXME sort: MIDI goes here 455 456typedef struct { 457 const struct SLMetadataExtractionItf_ *mItf; 458 IObject *mThis; 459 SLuint32 mKeySize; 460 const void *mKey; 461 SLuint32 mKeyEncoding; 462 const SLchar *mValueLangCountry; 463 SLuint32 mValueEncoding; 464 SLuint8 mFilterMask; 465 /*FIXME*/ int mKeyFilter; 466} IMetadataExtraction; 467 468typedef struct { 469 const struct SLMetadataTraversalItf_ *mItf; 470 IObject *mThis; 471 SLuint32 mIndex; 472 SLuint32 mMode; 473 SLuint32 mCount; 474 SLuint32 mSize; 475} IMetadataTraversal; 476 477typedef struct { 478 const struct SLMIDIMessageItf_ *mItf; 479 IObject *mThis; 480 slMetaEventCallback mMetaEventCallback; 481 void *mMetaEventContext; 482 slMIDIMessageCallback mMessageCallback; 483 void *mMessageContext; 484 SLuint8 mMessageTypes; 485} IMIDIMessage; 486 487typedef struct { 488 const struct SLMIDIMuteSoloItf_ *mItf; 489 IObject *mThis; 490 SLuint16 mChannelMuteMask; 491 SLuint16 mChannelSoloMask; 492 SLuint32 mTrackMuteMask; 493 SLuint32 mTrackSoloMask; 494 // const ? 495 SLuint16 mTrackCount; 496} IMIDIMuteSolo; 497 498typedef struct { 499 const struct SLMIDITempoItf_ *mItf; 500 IObject *mThis; 501 SLuint32 mTicksPerQuarterNote; 502 SLuint32 mMicrosecondsPerQuarterNote; 503} IMIDITempo; 504 505typedef struct { 506 const struct SLMIDITimeItf_ *mItf; 507 IObject *mThis; 508 SLuint32 mDuration; 509 SLuint32 mPosition; 510 SLuint32 mStartTick; 511 SLuint32 mNumTicks; 512} IMIDITime; 513 514typedef struct { 515 const struct SLMuteSoloItf_ *mItf; 516 IObject *mThis; 517 SLuint32 mMuteMask; 518 SLuint32 mSoloMask; 519 // const 520 SLuint8 mNumChannels; 521} IMuteSolo; 522 523typedef struct { 524 const struct SLOutputMixItf_ *mItf; 525 IObject *mThis; 526 slMixDeviceChangeCallback mCallback; 527 void *mContext; 528#ifdef USE_OUTPUTMIXEXT 529 unsigned mActiveMask; // 1 bit per active track 530 struct Track mTracks[32]; // FIXME magic 531#endif 532} IOutputMix; 533 534#ifdef USE_OUTPUTMIXEXT 535typedef struct { 536 const struct SLOutputMixExtItf_ *mItf; 537 IObject *mThis; 538} IOutputMixExt; 539#endif 540 541typedef struct { 542 const struct SLPitchItf_ *mItf; 543 IObject *mThis; 544 SLpermille mPitch; 545 // const 546 SLpermille mMinPitch; 547 SLpermille mMaxPitch; 548} IPitch; 549 550typedef struct Play_interface { 551 const struct SLPlayItf_ *mItf; 552 IObject *mThis; 553 volatile SLuint32 mState; 554 SLmillisecond mDuration; 555 SLmillisecond mPosition; 556 // unsigned mPositionSamples; // position in sample units 557 slPlayCallback mCallback; 558 void *mContext; 559 SLuint32 mEventFlags; 560 SLmillisecond mMarkerPosition; 561 SLmillisecond mPositionUpdatePeriod; 562} IPlay; 563 564typedef struct { 565 const struct SLPlaybackRateItf_ *mItf; 566 IObject *mThis; 567 SLpermille mRate; 568 SLuint32 mProperties; 569 // const 570 SLpermille mMinRate; 571 SLpermille mMaxRate; 572 SLpermille mStepSize; 573 SLuint32 mCapabilities; 574} IPlaybackRate; 575 576typedef struct { 577 const struct SLPrefetchStatusItf_ *mItf; 578 IObject *mThis; 579 SLuint32 mStatus; 580 SLpermille mLevel; 581 slPrefetchCallback mCallback; 582 void *mContext; 583 SLuint32 mCallbackEventsMask; 584 SLpermille mFillUpdatePeriod; 585} IPrefetchStatus; 586 587typedef struct { 588 const struct SLPresetReverbItf_ *mItf; 589 IObject *mThis; 590 SLuint16 mPreset; 591} IPresetReverb; 592 593typedef struct { 594 const struct SLRatePitchItf_ *mItf; 595 IObject *mThis; 596 SLpermille mRate; 597 // const 598 SLpermille mMinRate; 599 SLpermille mMaxRate; 600} IRatePitch; 601 602typedef struct { 603 const struct SLRecordItf_ *mItf; 604 IObject *mThis; 605 SLuint32 mState; 606 SLmillisecond mDurationLimit; 607 SLmillisecond mPosition; 608 slRecordCallback mCallback; 609 void *mContext; 610 SLuint32 mCallbackEventsMask; 611 SLmillisecond mMarkerPosition; 612 SLmillisecond mPositionUpdatePeriod; 613} IRecord; 614 615typedef struct { 616 const struct SLSeekItf_ *mItf; 617 IObject *mThis; 618 SLmillisecond mPos; 619 SLboolean mLoopEnabled; 620 SLmillisecond mStartPos; 621 SLmillisecond mEndPos; 622} ISeek; 623 624typedef struct { 625 const struct SLThreadSyncItf_ *mItf; 626 IObject *mThis; 627 SLboolean mInCriticalSection; 628 SLboolean mWaiting; 629 pthread_t mOwner; 630} IThreadSync; 631 632typedef struct { 633 const struct SLVibraItf_ *mItf; 634 IObject *mThis; 635 SLboolean mVibrate; 636 SLmilliHertz mFrequency; 637 SLpermille mIntensity; 638} IVibra; 639 640typedef struct { 641 const struct SLVirtualizerItf_ *mItf; 642 IObject *mThis; 643 SLboolean mEnabled; 644 SLpermille mStrength; 645} IVirtualizer; 646 647typedef struct { 648 const struct SLVisualizationItf_ *mItf; 649 IObject *mThis; 650 slVisualizationCallback mCallback; 651 void *mContext; 652 SLmilliHertz mRate; 653} IVisualization; 654 655typedef struct { 656 const struct SLVolumeItf_ *mItf; 657 IObject *mThis; 658 SLmillibel mLevel; 659 SLboolean mMute; 660 SLboolean mEnableStereoPosition; 661 SLpermille mStereoPosition; 662#ifdef USE_ANDROID 663 /** 664 * Amplification (can be attenuation) factor derived for the VolumeLevel 665 */ 666 float mAmplFromVolLevel; 667 /** 668 * Left/right amplification (can be attenuations) factors derived for the StereoPosition 669 */ 670 float mAmplFromStereoPos[2]; 671 /** 672 * Channel mask for which channels are muted 673 */ 674 int mChannelMutes; 675 /** 676 * Channel mask for which channels are solo'ed 677 */ 678 int mChannelSolos; 679#endif 680} IVolume; 681 682/* Class structures */ 683 684typedef struct { 685 IObject mObject; 686 IDynamicInterfaceManagement mDynamicInterfaceManagement; 687 I3DLocation m3DLocation; 688 I3DDoppler m3DDoppler; 689 I3DSource m3DSource; 690 I3DMacroscopic m3DMacroscopic; 691 // FIXME set of objects 692} C3DGroup; 693 694#ifdef USE_ANDROID 695/* 696 * Used to define the mapping from an OpenSL ES audio player to an Android 697 * media framework object 698 */ 699enum AndroidObject_type { 700 INVALID_TYPE =-1, 701 MEDIAPLAYER = 0, 702 AUDIOTRACK_PUSH = 1, 703 AUDIOTRACK_PULL = 2, 704 NUM_AUDIOPLAYER_MAP_TYPES 705}; 706#endif 707 708typedef struct { 709 IObject mObject; 710 IDynamicInterfaceManagement mDynamicInterfaceManagement; 711 IPlay mPlay; 712 I3DDoppler m3DDoppler; 713 I3DGrouping m3DGrouping; 714 I3DLocation m3DLocation; 715 I3DSource m3DSource; 716 IBufferQueue mBufferQueue; 717 IEffectSend mEffectSend; 718 IMuteSolo mMuteSolo; 719 IMetadataExtraction mMetadataExtraction; 720 IMetadataTraversal mMetadataTraversal; 721 IPrefetchStatus mPrefetchStatus; 722 IRatePitch mRatePitch; 723 ISeek mSeek; 724 IVolume mVolume; 725 // optional interfaces 726 I3DMacroscopic m3DMacroscopic; 727 IBassBoost mBassBoost; 728 IDynamicSource mDynamicSource; 729 IEnvironmentalReverb mEnvironmentalReverb; 730 IEqualizer mEqualizer; 731 IPitch mPitch; 732 IPresetReverb mPresetReverb; 733 IPlaybackRate mPlaybackRate; 734 IVirtualizer mVirtualizer; 735 IVisualization mVisualization; 736 // rest of fields are not related to the interfaces 737#ifdef USE_SNDFILE 738 struct SndFile mSndFile; 739#endif // USE_SNDFILE 740#ifdef USE_ANDROID 741 enum AndroidObject_type mAndroidObjType; 742 union { 743 android::AudioTrack *mAudioTrack; 744 android::MediaPlayer *mMediaPlayer; 745 }; 746 // pthread_t mThread; 747#endif 748} CAudioPlayer; 749 750typedef struct { 751 // mandated interfaces 752 IObject mObject; 753 IDynamicInterfaceManagement mDynamicInterfaceManagement; 754 IRecord mRecord; 755 IAudioEncoder mAudioEncoder; 756 // optional interfaces 757 IBassBoost mBassBoost; 758 IDynamicSource mDynamicSource; 759 IEqualizer mEqualizer; 760 IVisualization mVisualization; 761 IVolume mVolume; 762} CAudioRecorder; 763 764typedef struct { 765 // mandated implicit interfaces 766 IObject mObject; 767 IDynamicInterfaceManagement mDynamicInterfaceManagement; 768 IEngine mEngine; 769 IEngineCapabilities mEngineCapabilities; 770 IThreadSync mThreadSync; 771 // mandated explicit interfaces 772 IAudioIODeviceCapabilities mAudioIODeviceCapabilities; 773 IAudioDecoderCapabilities mAudioDecoderCapabilities; 774 IAudioEncoderCapabilities mAudioEncoderCapabilities; 775 I3DCommit m3DCommit; 776 // optional interfaces 777 IDeviceVolume mDeviceVolume; 778 pthread_t mFrameThread; 779} CEngine; 780 781typedef struct { 782 // mandated interfaces 783 IObject mObject; 784 IDynamicInterfaceManagement mDynamicInterfaceManagement; 785 ILEDArray mLEDArray; 786 SLuint32 mDeviceID; 787} CLEDDevice; 788 789typedef struct { 790 // mandated interfaces 791 IObject mObject; 792 IDynamicInterfaceManagement mDynamicInterfaceManagement; 793 I3DDoppler m3DDoppler; 794 I3DLocation m3DLocation; 795} CListener; 796 797typedef struct { 798 // mandated interfaces 799 IObject mObject; 800 IDynamicInterfaceManagement mDynamicInterfaceManagement; 801 IDynamicSource mDynamicSource; 802 IMetadataExtraction mMetadataExtraction; 803 IMetadataTraversal mMetadataTraversal; 804} CMetadataExtractor; 805 806typedef struct { 807 // mandated interfaces 808 IObject mObject; 809 IDynamicInterfaceManagement mDynamicInterfaceManagement; 810 IPlay mPlay; 811 I3DDoppler m3DDoppler; 812 I3DGrouping m3DGrouping; 813 I3DLocation m3DLocation; 814 I3DSource m3DSource; 815 IBufferQueue mBufferQueue; 816 IEffectSend mEffectSend; 817 IMuteSolo mMuteSolo; 818 IMetadataExtraction mMetadataExtraction; 819 IMetadataTraversal mMetadataTraversal; 820 IMIDIMessage mMIDIMessage; 821 IMIDITime mMIDITime; 822 IMIDITempo mMIDITempo; 823 IMIDIMuteSolo mMIDIMuteSolo; 824 IPrefetchStatus mPrefetchStatus; 825 ISeek mSeek; 826 IVolume mVolume; 827 // optional interfaces 828 I3DMacroscopic m3DMacroscopic; 829 IBassBoost mBassBoost; 830 IDynamicSource mDynamicSource; 831 IEnvironmentalReverb mEnvironmentalReverb; 832 IEqualizer mEqualizer; 833 IPitch mPitch; 834 IPresetReverb mPresetReverb; 835 IPlaybackRate mPlaybackRate; 836 IVirtualizer mVirtualizer; 837 IVisualization mVisualization; 838} CMidiPlayer; 839 840typedef struct OutputMix_class { 841 // mandated interfaces 842 IObject mObject; 843 IDynamicInterfaceManagement mDynamicInterfaceManagement; 844 IOutputMix mOutputMix; 845#ifdef USE_OUTPUTMIXEXT 846 IOutputMixExt mOutputMixExt; 847#endif 848 IEnvironmentalReverb mEnvironmentalReverb; 849 IEqualizer mEqualizer; 850 IPresetReverb mPresetReverb; 851 IVirtualizer mVirtualizer; 852 IVolume mVolume; 853 // optional interfaces 854 IBassBoost mBassBoost; 855 IVisualization mVisualization; 856} COutputMix; 857 858typedef struct { 859 // mandated interfaces 860 IObject mObject; 861 IDynamicInterfaceManagement mDynamicInterfaceManagement; 862 IVibra mVibra; 863 // 864 SLuint32 mDeviceID; 865} CVibraDevice; 866 867extern const ClassTable C3DGroup_class; 868 869struct MPH_init { 870 // unsigned char mMPH; 871 VoidHook mInit; 872 VoidHook mDeinit; 873}; 874 875extern /*static*/ int IID_to_MPH(const SLInterfaceID iid); 876extern /*static*/ const struct MPH_init MPH_init_table[MPH_MAX]; 877extern SLresult checkInterfaces(const ClassTable *class__, 878 SLuint32 numInterfaces, const SLInterfaceID *pInterfaceIds, 879 const SLboolean *pInterfaceRequired, unsigned *pExposedMask); 880extern IObject *construct(const ClassTable *class__, 881 unsigned exposedMask, SLEngineItf engine); 882extern const ClassTable *objectIDtoClass(SLuint32 objectID); 883extern const struct SLInterfaceID_ SL_IID_array[MPH_MAX]; 884