itfstruct.h revision 70c49ae2867094072a4365423417ea452bf82231
116c4d154dca43c662571129af31b27433b919a32Adam Lesinski/*
216c4d154dca43c662571129af31b27433b919a32Adam Lesinski * Copyright (C) 2010 The Android Open Source Project
316c4d154dca43c662571129af31b27433b919a32Adam Lesinski *
416c4d154dca43c662571129af31b27433b919a32Adam Lesinski * Licensed under the Apache License, Version 2.0 (the "License");
516c4d154dca43c662571129af31b27433b919a32Adam Lesinski * you may not use this file except in compliance with the License.
616c4d154dca43c662571129af31b27433b919a32Adam Lesinski * You may obtain a copy of the License at
716c4d154dca43c662571129af31b27433b919a32Adam Lesinski *
816c4d154dca43c662571129af31b27433b919a32Adam Lesinski *      http://www.apache.org/licenses/LICENSE-2.0
916c4d154dca43c662571129af31b27433b919a32Adam Lesinski *
1016c4d154dca43c662571129af31b27433b919a32Adam Lesinski * Unless required by applicable law or agreed to in writing, software
1116c4d154dca43c662571129af31b27433b919a32Adam Lesinski * distributed under the License is distributed on an "AS IS" BASIS,
1216c4d154dca43c662571129af31b27433b919a32Adam Lesinski * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1316c4d154dca43c662571129af31b27433b919a32Adam Lesinski * See the License for the specific language governing permissions and
1416c4d154dca43c662571129af31b27433b919a32Adam Lesinski * limitations under the License.
1516c4d154dca43c662571129af31b27433b919a32Adam Lesinski */
1616c4d154dca43c662571129af31b27433b919a32Adam Lesinski
1716c4d154dca43c662571129af31b27433b919a32Adam Lesinski/* Interface structures */
1816c4d154dca43c662571129af31b27433b919a32Adam Lesinski
1916c4d154dca43c662571129af31b27433b919a32Adam Lesinskitypedef struct Object_interface {
2016c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct SLObjectItf_ *mItf;    // const
2116c4d154dca43c662571129af31b27433b919a32Adam Lesinski    // field mThis would be redundant within an IObject, so we substitute mEngine
2216c4d154dca43c662571129af31b27433b919a32Adam Lesinski    CEngine *mEngine;               // const
2316c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const ClassTable *mClass;       // const
2416c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint32 mInstanceID;           // const for debugger and for RPC, 0 means unpublished
2516c4d154dca43c662571129af31b27433b919a32Adam Lesinski    slObjectCallback mCallback;
2616c4d154dca43c662571129af31b27433b919a32Adam Lesinski    void *mContext;
2716c4d154dca43c662571129af31b27433b919a32Adam Lesinski    unsigned mGottenMask;           ///< bit-mask of interfaces exposed or added, then gotten
2816c4d154dca43c662571129af31b27433b919a32Adam Lesinski    unsigned mLossOfControlMask;    // interfaces with loss of control enabled
2916c4d154dca43c662571129af31b27433b919a32Adam Lesinski    unsigned mAttributesMask;       // attributes which have changed since last sync
3016c4d154dca43c662571129af31b27433b919a32Adam Lesinski#if USE_PROFILES & USE_PROFILES_BASE
3116c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLint32 mPriority;
3216c4d154dca43c662571129af31b27433b919a32Adam Lesinski#endif
3316c4d154dca43c662571129af31b27433b919a32Adam Lesinski    pthread_mutex_t mMutex;
3416c4d154dca43c662571129af31b27433b919a32Adam Lesinski#ifdef USE_DEBUG
3516c4d154dca43c662571129af31b27433b919a32Adam Lesinski    pthread_t mOwner;
3616c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const char *mFile;
3716c4d154dca43c662571129af31b27433b919a32Adam Lesinski    int mLine;
3816c4d154dca43c662571129af31b27433b919a32Adam Lesinski#endif
3916c4d154dca43c662571129af31b27433b919a32Adam Lesinski    pthread_cond_t mCond;
4016c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint8 mState;                 // really SLuint32, but SLuint8 to save space
4116c4d154dca43c662571129af31b27433b919a32Adam Lesinski#if USE_PROFILES & USE_PROFILES_BASE
4216c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint8 mPreemptable;           // really SLboolean, but SLuint8 to save space
4316c4d154dca43c662571129af31b27433b919a32Adam Lesinski#else
4448d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad    SLuint8 mPadding;
4516c4d154dca43c662571129af31b27433b919a32Adam Lesinski#endif
4616c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint8 mStrongRefCount;        // number of strong references to this object
4716c4d154dca43c662571129af31b27433b919a32Adam Lesinski    // (object cannot be destroyed as long as > 0, and referrers _prefer_ it stay in Realized state)
4816c4d154dca43c662571129af31b27433b919a32Adam Lesinski    // for best alignment, do not add any fields here
4916c4d154dca43c662571129af31b27433b919a32Adam Lesinski#define INTERFACES_Default 1
5016c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint8 mInterfaceStates[INTERFACES_Default];    // state of each of interface
5116c4d154dca43c662571129af31b27433b919a32Adam Lesinski    // do not add any fields here
5216c4d154dca43c662571129af31b27433b919a32Adam Lesinski} IObject;
5316c4d154dca43c662571129af31b27433b919a32Adam Lesinski
5416c4d154dca43c662571129af31b27433b919a32Adam Lesinski#include "locks.h"
5516c4d154dca43c662571129af31b27433b919a32Adam Lesinski
5616c4d154dca43c662571129af31b27433b919a32Adam Lesinskitypedef struct {
5716c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct SL3DCommitItf_ *mItf;
5816c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IObject *mThis;
5916c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLboolean mDeferred;
6016c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint32 mGeneration;   // incremented each master clock cycle
6116c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint32 mWaiting;      // number of threads waiting in Commit
6216c4d154dca43c662571129af31b27433b919a32Adam Lesinski} I3DCommit;
6316c4d154dca43c662571129af31b27433b919a32Adam Lesinski
6416c4d154dca43c662571129af31b27433b919a32Adam Lesinskienum CartesianSphericalActive {
6516c4d154dca43c662571129af31b27433b919a32Adam Lesinski    CARTESIAN_COMPUTED_SPHERICAL_SET,
6616c4d154dca43c662571129af31b27433b919a32Adam Lesinski    CARTESIAN_REQUESTED_SPHERICAL_SET,
6716c4d154dca43c662571129af31b27433b919a32Adam Lesinski    CARTESIAN_UNKNOWN_SPHERICAL_SET,
6816c4d154dca43c662571129af31b27433b919a32Adam Lesinski    CARTESIAN_SET_SPHERICAL_COMPUTED,   // not in 1.0.1
6916c4d154dca43c662571129af31b27433b919a32Adam Lesinski    CARTESIAN_SET_SPHERICAL_REQUESTED,  // not in 1.0.1
7016c4d154dca43c662571129af31b27433b919a32Adam Lesinski    CARTESIAN_SET_SPHERICAL_UNKNOWN
7116c4d154dca43c662571129af31b27433b919a32Adam Lesinski};
7216c4d154dca43c662571129af31b27433b919a32Adam Lesinski
7316c4d154dca43c662571129af31b27433b919a32Adam Lesinskitypedef struct {
7416c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct SL3DDopplerItf_ *mItf;
7516c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IObject *mThis;
7648d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad    // The API allows client to specify either Cartesian and spherical velocities.
77de898ff42912bd7ca1bfb099cd439562496765a4Adam Lesinski    // But an implementation will likely prefer one or the other. So for
7816c4d154dca43c662571129af31b27433b919a32Adam Lesinski    // maximum portablity, we maintain both units and an indication of which
7916c4d154dca43c662571129af31b27433b919a32Adam Lesinski    // unit was set most recently. In addition, we keep a flag saying whether
8016c4d154dca43c662571129af31b27433b919a32Adam Lesinski    // the other unit has been derived yet. It can take significant time
8116c4d154dca43c662571129af31b27433b919a32Adam Lesinski    // to compute the other unit, so this may be deferred to another thread.
8216c4d154dca43c662571129af31b27433b919a32Adam Lesinski    // For this reason we also keep an indication of whether the secondary
8316c4d154dca43c662571129af31b27433b919a32Adam Lesinski    // has been computed yet, and its accuracy.
8416c4d154dca43c662571129af31b27433b919a32Adam Lesinski    // Though only one unit is primary at a time, a union is inappropriate:
8565a05fd56dbc9fd9c2511a97f49c445a748fb3c5Mårten Kongstad    // the application might read in both units (not in 1.0.1),
8648d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad    // and due to multi-threading concerns.
8748d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad    SLVec3D mVelocityCartesian;
8848d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad    struct {
8948d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad        SLmillidegree mAzimuth;
9048d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad        SLmillidegree mElevation;
9165a05fd56dbc9fd9c2511a97f49c445a748fb3c5Mårten Kongstad        SLmillidegree mSpeed;
9216c4d154dca43c662571129af31b27433b919a32Adam Lesinski    } mVelocitySpherical;
9316c4d154dca43c662571129af31b27433b919a32Adam Lesinski    enum CartesianSphericalActive mVelocityActive;
9416c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLpermille mDopplerFactor;
9516c4d154dca43c662571129af31b27433b919a32Adam Lesinski} I3DDoppler;
9616c4d154dca43c662571129af31b27433b919a32Adam Lesinski
9716c4d154dca43c662571129af31b27433b919a32Adam Lesinskitypedef struct {
9848d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad    const struct SL3DGroupingItf_ *mItf;
9916c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IObject *mThis;
10016c4d154dca43c662571129af31b27433b919a32Adam Lesinski    C3DGroup *mGroup;   // strong reference to associated group or NULL
10116c4d154dca43c662571129af31b27433b919a32Adam Lesinski} I3DGrouping;
10216c4d154dca43c662571129af31b27433b919a32Adam Lesinski
10316c4d154dca43c662571129af31b27433b919a32Adam Lesinskienum AnglesVectorsActive {
10416c4d154dca43c662571129af31b27433b919a32Adam Lesinski    ANGLES_COMPUTED_VECTORS_SET,    // not in 1.0.1
10516c4d154dca43c662571129af31b27433b919a32Adam Lesinski    ANGLES_REQUESTED_VECTORS_SET,   // not in 1.0.1
10616c4d154dca43c662571129af31b27433b919a32Adam Lesinski    ANGLES_UNKNOWN_VECTORS_SET,
10716c4d154dca43c662571129af31b27433b919a32Adam Lesinski    ANGLES_SET_VECTORS_COMPUTED,
10816c4d154dca43c662571129af31b27433b919a32Adam Lesinski    ANGLES_SET_VECTORS_REQUESTED,
10916c4d154dca43c662571129af31b27433b919a32Adam Lesinski    ANGLES_SET_VECTORS_UNKNOWN
11016c4d154dca43c662571129af31b27433b919a32Adam Lesinski};
11116c4d154dca43c662571129af31b27433b919a32Adam Lesinski
11216c4d154dca43c662571129af31b27433b919a32Adam Lesinskitypedef struct {
11316c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct SL3DLocationItf_ *mItf;
11416c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IObject *mThis;
11516c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLVec3D mLocationCartesian;
11616c4d154dca43c662571129af31b27433b919a32Adam Lesinski    struct {
11716c4d154dca43c662571129af31b27433b919a32Adam Lesinski        SLmillidegree mAzimuth;
11816c4d154dca43c662571129af31b27433b919a32Adam Lesinski        SLmillidegree mElevation;
11916c4d154dca43c662571129af31b27433b919a32Adam Lesinski        SLmillimeter mDistance;
12016c4d154dca43c662571129af31b27433b919a32Adam Lesinski    } mLocationSpherical;
12116c4d154dca43c662571129af31b27433b919a32Adam Lesinski    enum CartesianSphericalActive mLocationActive;
12216c4d154dca43c662571129af31b27433b919a32Adam Lesinski    struct {
12316c4d154dca43c662571129af31b27433b919a32Adam Lesinski        SLmillidegree mHeading;
12416c4d154dca43c662571129af31b27433b919a32Adam Lesinski        SLmillidegree mPitch;
12516c4d154dca43c662571129af31b27433b919a32Adam Lesinski        SLmillidegree mRoll;
12616c4d154dca43c662571129af31b27433b919a32Adam Lesinski    } mOrientationAngles;
12716c4d154dca43c662571129af31b27433b919a32Adam Lesinski    struct {
12816c4d154dca43c662571129af31b27433b919a32Adam Lesinski        SLVec3D mFront;
12916c4d154dca43c662571129af31b27433b919a32Adam Lesinski        SLVec3D mAbove;
13016c4d154dca43c662571129af31b27433b919a32Adam Lesinski        SLVec3D mUp;
13116c4d154dca43c662571129af31b27433b919a32Adam Lesinski    } mOrientationVectors;
13216c4d154dca43c662571129af31b27433b919a32Adam Lesinski    enum AnglesVectorsActive mOrientationActive;
13316c4d154dca43c662571129af31b27433b919a32Adam Lesinski    // Rotations can be slow, so are deferred.
13416c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLmillidegree mTheta;
13516c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLVec3D mAxis;
13616c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLboolean mRotatePending;
13716c4d154dca43c662571129af31b27433b919a32Adam Lesinski} I3DLocation;
13816c4d154dca43c662571129af31b27433b919a32Adam Lesinski
13916c4d154dca43c662571129af31b27433b919a32Adam Lesinskitypedef struct {
14016c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct SL3DMacroscopicItf_ *mItf;
14116c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IObject *mThis;
14216c4d154dca43c662571129af31b27433b919a32Adam Lesinski    struct {
14316c4d154dca43c662571129af31b27433b919a32Adam Lesinski        SLmillimeter mWidth;
14416c4d154dca43c662571129af31b27433b919a32Adam Lesinski        SLmillimeter mHeight;
14516c4d154dca43c662571129af31b27433b919a32Adam Lesinski        SLmillimeter mDepth;
14616c4d154dca43c662571129af31b27433b919a32Adam Lesinski    } mSize;
14716c4d154dca43c662571129af31b27433b919a32Adam Lesinski    struct {
14816c4d154dca43c662571129af31b27433b919a32Adam Lesinski        SLmillimeter mHeading;
14916c4d154dca43c662571129af31b27433b919a32Adam Lesinski        SLmillimeter mPitch;
15016c4d154dca43c662571129af31b27433b919a32Adam Lesinski        SLmillimeter mRoll;
15116c4d154dca43c662571129af31b27433b919a32Adam Lesinski    } mOrientationAngles;
15216c4d154dca43c662571129af31b27433b919a32Adam Lesinski    struct {
15316c4d154dca43c662571129af31b27433b919a32Adam Lesinski        SLVec3D mFront;
15416c4d154dca43c662571129af31b27433b919a32Adam Lesinski        SLVec3D mAbove;
15516c4d154dca43c662571129af31b27433b919a32Adam Lesinski        SLVec3D mUp;
15616c4d154dca43c662571129af31b27433b919a32Adam Lesinski    } mOrientationVectors;
15716c4d154dca43c662571129af31b27433b919a32Adam Lesinski    enum AnglesVectorsActive mOrientationActive;
15816c4d154dca43c662571129af31b27433b919a32Adam Lesinski    // Rotations can be slow, so are deferred.
15916c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLmillidegree mTheta;
16016c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLVec3D mAxis;
16116c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLboolean mRotatePending;
16216c4d154dca43c662571129af31b27433b919a32Adam Lesinski} I3DMacroscopic;
16316c4d154dca43c662571129af31b27433b919a32Adam Lesinski
16416c4d154dca43c662571129af31b27433b919a32Adam Lesinskitypedef struct {
16516c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct SL3DSourceItf_ *mItf;
16616c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IObject *mThis;
16716c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLboolean mHeadRelative;
16816c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLboolean mRolloffMaxDistanceMute;
16916c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLmillimeter mMaxDistance;
17016c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLmillimeter mMinDistance;
17116c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLmillidegree mConeInnerAngle;
17216c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLmillidegree mConeOuterAngle;
173a0c6260705c841f501282e0e337970ca9a00e064Narayan Kamath    SLmillibel mConeOuterLevel;
17416c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLpermille mRolloffFactor;
17516c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLpermille mRoomRolloffFactor;
17616c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint8 mDistanceModel;
17716c4d154dca43c662571129af31b27433b919a32Adam Lesinski} I3DSource;
17816c4d154dca43c662571129af31b27433b919a32Adam Lesinski
17916c4d154dca43c662571129af31b27433b919a32Adam Lesinskitypedef struct {
18016c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct SLAudioDecoderCapabilitiesItf_ *mItf;
18116c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IObject *mThis;
18216c4d154dca43c662571129af31b27433b919a32Adam Lesinski} IAudioDecoderCapabilities;
18316c4d154dca43c662571129af31b27433b919a32Adam Lesinski
18416c4d154dca43c662571129af31b27433b919a32Adam Lesinskitypedef struct {
18516c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct SLAudioEncoderItf_ *mItf;
18616c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IObject *mThis;
18716c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLAudioEncoderSettings mSettings;
18816c4d154dca43c662571129af31b27433b919a32Adam Lesinski} IAudioEncoder;
18916c4d154dca43c662571129af31b27433b919a32Adam Lesinski
19016c4d154dca43c662571129af31b27433b919a32Adam Lesinskitypedef struct {
19116c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct SLAudioEncoderCapabilitiesItf_ *mItf;
19216c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IObject *mThis;
19316c4d154dca43c662571129af31b27433b919a32Adam Lesinski} IAudioEncoderCapabilities;
19416c4d154dca43c662571129af31b27433b919a32Adam Lesinski
19516c4d154dca43c662571129af31b27433b919a32Adam Lesinskitypedef struct {
19616c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct SLAudioIODeviceCapabilitiesItf_ *mItf;
19716c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IObject *mThis;
19816c4d154dca43c662571129af31b27433b919a32Adam Lesinski    slAvailableAudioInputsChangedCallback mAvailableAudioInputsChangedCallback;
19916c4d154dca43c662571129af31b27433b919a32Adam Lesinski    void *mAvailableAudioInputsChangedContext;
200a0c6260705c841f501282e0e337970ca9a00e064Narayan Kamath    slAvailableAudioOutputsChangedCallback mAvailableAudioOutputsChangedCallback;
20116c4d154dca43c662571129af31b27433b919a32Adam Lesinski    void *mAvailableAudioOutputsChangedContext;
20216c4d154dca43c662571129af31b27433b919a32Adam Lesinski    slDefaultDeviceIDMapChangedCallback mDefaultDeviceIDMapChangedCallback;
20316c4d154dca43c662571129af31b27433b919a32Adam Lesinski    void *mDefaultDeviceIDMapChangedContext;
20416c4d154dca43c662571129af31b27433b919a32Adam Lesinski} IAudioIODeviceCapabilities;
20516c4d154dca43c662571129af31b27433b919a32Adam Lesinski
20616c4d154dca43c662571129af31b27433b919a32Adam Lesinskitypedef struct {
20716c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct SLBassBoostItf_ *mItf;
20816c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IObject *mThis;
209de898ff42912bd7ca1bfb099cd439562496765a4Adam Lesinski    SLboolean mEnabled;
210de898ff42912bd7ca1bfb099cd439562496765a4Adam Lesinski    SLpermille mStrength;
211de898ff42912bd7ca1bfb099cd439562496765a4Adam Lesinski#if defined(ANDROID)
212de898ff42912bd7ca1bfb099cd439562496765a4Adam Lesinski    effect_descriptor_t mBassBoostDescriptor;
213de898ff42912bd7ca1bfb099cd439562496765a4Adam Lesinski    android::sp<android::AudioEffect> mBassBoostEffect;
214de898ff42912bd7ca1bfb099cd439562496765a4Adam Lesinski#endif
215de898ff42912bd7ca1bfb099cd439562496765a4Adam Lesinski} IBassBoost;
216de898ff42912bd7ca1bfb099cd439562496765a4Adam Lesinski
217de898ff42912bd7ca1bfb099cd439562496765a4Adam Lesinskitypedef struct BufferQueue_interface {
218de898ff42912bd7ca1bfb099cd439562496765a4Adam Lesinski    const struct SLBufferQueueItf_ *mItf;
21916c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IObject *mThis;
22016c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLBufferQueueState mState;
22116c4d154dca43c662571129af31b27433b919a32Adam Lesinski    slBufferQueueCallback mCallback;
22216c4d154dca43c662571129af31b27433b919a32Adam Lesinski    void *mContext;
223a0c6260705c841f501282e0e337970ca9a00e064Narayan Kamath    // originally SLuint32, but range-checked down to SLuint16
22416c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint16 mNumBuffers;
22516c4d154dca43c662571129af31b27433b919a32Adam Lesinski    /*SLboolean*/ SLuint16 mClearRequested;
22648d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad    BufferHeader *mArray;
22748d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad    BufferHeader *mFront, *mRear;
22848d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad#ifdef ANDROID
22948d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad    SLuint32 mSizeConsumed;
23048d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad#endif
23116c4d154dca43c662571129af31b27433b919a32Adam Lesinski    // saves a malloc in the typical case
23248d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad#define BUFFER_HEADER_TYPICAL 4
23316c4d154dca43c662571129af31b27433b919a32Adam Lesinski    BufferHeader mTypical[BUFFER_HEADER_TYPICAL+1];
2347df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba} IBufferQueue;
2357df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba
2367df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba#define MAX_DEVICE 2    // hard-coded array size for default in/out
2377df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba
23816c4d154dca43c662571129af31b27433b919a32Adam Lesinskitypedef struct {
23916c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct SLDeviceVolumeItf_ *mItf;
24016c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IObject *mThis;
24148d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad    SLint32 mVolume[MAX_DEVICE];
24265a05fd56dbc9fd9c2511a97f49c445a748fb3c5Mårten Kongstad} IDeviceVolume;
24348d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad
24465a05fd56dbc9fd9c2511a97f49c445a748fb3c5Mårten Kongstadtypedef struct {
24548d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad    const struct SLDynamicInterfaceManagementItf_ *mItf;
24665a05fd56dbc9fd9c2511a97f49c445a748fb3c5Mårten Kongstad    IObject *mThis;
24748d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad    slDynamicInterfaceManagementCallback mCallback;
24848d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad    void *mContext;
24948d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad} IDynamicInterfaceManagement;
25048d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad
25148d22323ce39f9aab003dce74456889b6414af55Mårten Kongstadtypedef struct {
25248d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad    const struct SLDynamicSourceItf_ *mItf;
25365a05fd56dbc9fd9c2511a97f49c445a748fb3c5Mårten Kongstad    IObject *mThis;
25448d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad    SLDataSource *mDataSource;
25548d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad} IDynamicSource;
25648d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad
25716c4d154dca43c662571129af31b27433b919a32Adam Lesinski// private
25816c4d154dca43c662571129af31b27433b919a32Adam Lesinski
25916c4d154dca43c662571129af31b27433b919a32Adam Lesinskistruct EnableLevel {
26048d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad    SLboolean mEnable;
26148d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad    SLmillibel mSendLevel;
26248d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad};
263f90f2f8dc36e7243b85e0b6a7fd5a590893c827eAdam Lesinski
26448d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad// indexes into IEffectSend.mEnableLevels
26548d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad
26616c4d154dca43c662571129af31b27433b919a32Adam Lesinski#define AUX_ENVIRONMENTALREVERB 0
26716c4d154dca43c662571129af31b27433b919a32Adam Lesinski#define AUX_PRESETREVERB        1
26848d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad#define AUX_MAX                 2
26916c4d154dca43c662571129af31b27433b919a32Adam Lesinski
27048d22323ce39f9aab003dce74456889b6414af55Mårten Kongstadtypedef struct {
27148d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad    const struct SLEffectSendItf_ *mItf;
27248d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad    IObject *mThis;
27316c4d154dca43c662571129af31b27433b919a32Adam Lesinski    struct EnableLevel mEnableLevels[AUX_MAX];  // wet enable and volume per effect type
27416c4d154dca43c662571129af31b27433b919a32Adam Lesinski} IEffectSend;
27548d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad
27648d22323ce39f9aab003dce74456889b6414af55Mårten Kongstadtypedef struct Engine_interface {
27716c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct SLEngineItf_ *mItf;
27816c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IObject *mThis;
27948d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad    SLboolean mLossOfControlGlobal;
28048d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad#ifdef USE_SDL
28116c4d154dca43c662571129af31b27433b919a32Adam Lesinski    COutputMix *mOutputMix; // SDL pulls PCM from an arbitrary IOutputMixExt
28216c4d154dca43c662571129af31b27433b919a32Adam Lesinski#endif
28348d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad    // Each engine is its own universe.
28448d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad    SLuint32 mInstanceCount;
28516c4d154dca43c662571129af31b27433b919a32Adam Lesinski    unsigned mInstanceMask; // 1 bit per active object
28616c4d154dca43c662571129af31b27433b919a32Adam Lesinski    unsigned mChangedMask;  // objects which have changed since last sync
287560566d2915c03bed338fc532ac7f7aa3620cfdfNarayan Kamath#define MAX_INSTANCE 32     // maximum active objects per engine, see mInstanceMask
28848d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad    IObject *mInstances[MAX_INSTANCE];
28948d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad    SLboolean mShutdown;
29048d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad    SLboolean mShutdownAck;
29148d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad    // SLuint32 mVersion;      // 0xXXYYZZ where XX=major, YY=minor, ZZ=step
29248d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad} IEngine;
29348d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad
29448d22323ce39f9aab003dce74456889b6414af55Mårten Kongstadtypedef struct {
29548d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad    const struct SLEngineCapabilitiesItf_ *mItf;
29648d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad    IObject *mThis;
29748d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad    SLboolean mThreadSafe;
298560566d2915c03bed338fc532ac7f7aa3620cfdfNarayan Kamath    // const
29948d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad    SLuint32 mMaxIndexLED;
30048d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad    SLuint32 mMaxIndexVibra;
30116c4d154dca43c662571129af31b27433b919a32Adam Lesinski} IEngineCapabilities;
30248d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad
3031cbea39fe1740d7d1c3e4aa0e4771a99a56c79efNick Kralevichtypedef struct {
30416c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct SLEnvironmentalReverbItf_ *mItf;
30548d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad    IObject *mThis;
30648d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad    SLEnvironmentalReverbSettings mProperties;
30716c4d154dca43c662571129af31b27433b919a32Adam Lesinski#if defined(ANDROID)
30816c4d154dca43c662571129af31b27433b919a32Adam Lesinski    effect_descriptor_t mEnvironmentalReverbDescriptor;
30916c4d154dca43c662571129af31b27433b919a32Adam Lesinski    android::sp<android::AudioEffect> mEnvironmentalReverbEffect;
31016c4d154dca43c662571129af31b27433b919a32Adam Lesinski#endif
31116c4d154dca43c662571129af31b27433b919a32Adam Lesinski} IEnvironmentalReverb;
31248d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad
31316c4d154dca43c662571129af31b27433b919a32Adam Lesinskistruct EqualizerBand {
31416c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLmilliHertz mMin;
31516c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLmilliHertz mCenter;
31648d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad    SLmilliHertz mMax;
31716c4d154dca43c662571129af31b27433b919a32Adam Lesinski};
318f90f2f8dc36e7243b85e0b6a7fd5a590893c827eAdam Lesinski
31916c4d154dca43c662571129af31b27433b919a32Adam Lesinski#if defined(ANDROID)
32016c4d154dca43c662571129af31b27433b919a32Adam Lesinski#define MAX_EQ_BANDS 0
32148d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad#else
32248d22323ce39f9aab003dce74456889b6414af55Mårten Kongstad#define MAX_EQ_BANDS 4  // compile-time limit, runtime limit may be smaller
32316c4d154dca43c662571129af31b27433b919a32Adam Lesinski#endif
32416c4d154dca43c662571129af31b27433b919a32Adam Lesinski
32516c4d154dca43c662571129af31b27433b919a32Adam Lesinskitypedef struct {
32616c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct SLEqualizerItf_ *mItf;
32716c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IObject *mThis;
32816c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLboolean mEnabled;
32916c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint16 mPreset;
33016c4d154dca43c662571129af31b27433b919a32Adam Lesinski#if 0 < MAX_EQ_BANDS
33116c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLmillibel mLevels[MAX_EQ_BANDS];
33216c4d154dca43c662571129af31b27433b919a32Adam Lesinski#endif
33316c4d154dca43c662571129af31b27433b919a32Adam Lesinski    // const to end of struct
33416c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint16 mNumPresets;
33516c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint16 mNumBands;
336a0c6260705c841f501282e0e337970ca9a00e064Narayan Kamath#if !defined(ANDROID)
33716c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct EqualizerBand *mBands;
33816c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct EqualizerPreset *mPresets;
339a0c6260705c841f501282e0e337970ca9a00e064Narayan Kamath#endif
340a0c6260705c841f501282e0e337970ca9a00e064Narayan Kamath    SLmillibel mBandLevelRangeMin;
34116c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLmillibel mBandLevelRangeMax;
34216c4d154dca43c662571129af31b27433b919a32Adam Lesinski#if defined(ANDROID)
343a0c6260705c841f501282e0e337970ca9a00e064Narayan Kamath    effect_descriptor_t mEqDescriptor;
34416c4d154dca43c662571129af31b27433b919a32Adam Lesinski    android::sp<android::AudioEffect> mEqEffect;
34516c4d154dca43c662571129af31b27433b919a32Adam Lesinski#endif
346a0c6260705c841f501282e0e337970ca9a00e064Narayan Kamath} IEqualizer;
34716c4d154dca43c662571129af31b27433b919a32Adam Lesinski
34816c4d154dca43c662571129af31b27433b919a32Adam Lesinski#define MAX_LED_COUNT 32
34916c4d154dca43c662571129af31b27433b919a32Adam Lesinski
35016c4d154dca43c662571129af31b27433b919a32Adam Lesinskitypedef struct {
35116c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct SLLEDArrayItf_ *mItf;
35216c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IObject *mThis;
35316c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint32 mLightMask;
35416c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLHSL mColors[MAX_LED_COUNT];
35516c4d154dca43c662571129af31b27433b919a32Adam Lesinski    // const
35616c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint8 mCount;
35716c4d154dca43c662571129af31b27433b919a32Adam Lesinski} ILEDArray;
35816c4d154dca43c662571129af31b27433b919a32Adam Lesinski
35916c4d154dca43c662571129af31b27433b919a32Adam Lesinskitypedef struct {
36016c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct SLMetadataExtractionItf_ *mItf;
36116c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IObject *mThis;
36216c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint32 mKeySize;
36316c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const void *mKey;
36416c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint32 mKeyEncoding;
365e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath    const SLchar *mValueLangCountry;
366e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath    SLuint32 mValueEncoding;
367e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath    SLuint8 mFilterMask;
368e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath    int mKeyFilter;
369e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath} IMetadataExtraction;
370e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath
371e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamathtypedef struct {
372e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath    const struct SLMetadataTraversalItf_ *mItf;
373e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath    IObject *mThis;
37416c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint32 mIndex;
37516c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint32 mMode;
37616c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint32 mCount;
37716c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint32 mSize;
37816c4d154dca43c662571129af31b27433b919a32Adam Lesinski} IMetadataTraversal;
37916c4d154dca43c662571129af31b27433b919a32Adam Lesinski
38016c4d154dca43c662571129af31b27433b919a32Adam Lesinskitypedef struct {
38116c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct SLMIDIMessageItf_ *mItf;
382c367d48c55e5a3fa0df14fd62889e4bb6b63cb01Elliott Hughes    IObject *mThis;
383e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath    slMetaEventCallback mMetaEventCallback;
384e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath    void *mMetaEventContext;
385e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath    slMIDIMessageCallback mMessageCallback;
386e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath    void *mMessageContext;
387e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath    SLuint8 mMessageTypes;
388e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath} IMIDIMessage;
389e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath
390e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamathtypedef struct {
391fec5106c8ea5791614385c17bd1bf0ecff9afe9aNarayan Kamath    const struct SLMIDIMuteSoloItf_ *mItf;
392fec5106c8ea5791614385c17bd1bf0ecff9afe9aNarayan Kamath    IObject *mThis;
393fec5106c8ea5791614385c17bd1bf0ecff9afe9aNarayan Kamath    SLuint16 mChannelMuteMask;
394fec5106c8ea5791614385c17bd1bf0ecff9afe9aNarayan Kamath    SLuint16 mChannelSoloMask;
395e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath    SLuint32 mTrackMuteMask;
396e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath    SLuint32 mTrackSoloMask;
397e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath    // const
398e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath    SLuint16 mTrackCount;
399e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath} IMIDIMuteSolo;
400e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath
401e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamathtypedef struct {
402e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath    const struct SLMIDITempoItf_ *mItf;
403e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath    IObject *mThis;
404e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath    SLuint32 mTicksPerQuarterNote;
405e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath    SLuint32 mMicrosecondsPerQuarterNote;
406e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath} IMIDITempo;
407e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath
408e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamathtypedef struct {
409e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath    const struct SLMIDITimeItf_ *mItf;
410e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath    IObject *mThis;
411e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath    SLuint32 mDuration;
412e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath    SLuint32 mPosition;
413e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath    SLuint32 mStartTick;
414e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath    SLuint32 mNumTicks;
415e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath} IMIDITime;
416e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath
417e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamathtypedef struct {
418e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath    const struct SLMuteSoloItf_ *mItf;
419e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath    IObject *mThis;
420e4345dbd2a892f38e62269d94e5ee7002d121bedNarayan Kamath    // fields that were formerly here are now at CAudioPlayer
42116c4d154dca43c662571129af31b27433b919a32Adam Lesinski} IMuteSolo;
42216c4d154dca43c662571129af31b27433b919a32Adam Lesinski
42316c4d154dca43c662571129af31b27433b919a32Adam Lesinski#define MAX_TRACK 32        // see mActiveMask
42416c4d154dca43c662571129af31b27433b919a32Adam Lesinski
42516c4d154dca43c662571129af31b27433b919a32Adam Lesinskitypedef struct {
42616c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct SLOutputMixItf_ *mItf;
42716c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IObject *mThis;
42816c4d154dca43c662571129af31b27433b919a32Adam Lesinski    slMixDeviceChangeCallback mCallback;
42916c4d154dca43c662571129af31b27433b919a32Adam Lesinski    void *mContext;
43016c4d154dca43c662571129af31b27433b919a32Adam Lesinski} IOutputMix;
43116c4d154dca43c662571129af31b27433b919a32Adam Lesinski
43216c4d154dca43c662571129af31b27433b919a32Adam Lesinski#ifdef USE_OUTPUTMIXEXT
43316c4d154dca43c662571129af31b27433b919a32Adam Lesinskitypedef struct {
43416c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct SLOutputMixExtItf_ *mItf;
43516c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IObject *mThis;
43616c4d154dca43c662571129af31b27433b919a32Adam Lesinski    unsigned mActiveMask;   // 1 bit per active track
43716c4d154dca43c662571129af31b27433b919a32Adam Lesinski    Track mTracks[MAX_TRACK];
43816c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLboolean mDestroyRequested;    ///< Mixer to acknowledge application's call to Object::Destroy
43916c4d154dca43c662571129af31b27433b919a32Adam Lesinski} IOutputMixExt;
44016c4d154dca43c662571129af31b27433b919a32Adam Lesinski#endif
44116c4d154dca43c662571129af31b27433b919a32Adam Lesinski
44216c4d154dca43c662571129af31b27433b919a32Adam Lesinskitypedef struct {
44316c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct SLPitchItf_ *mItf;
44416c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IObject *mThis;
44516c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLpermille mPitch;
44616c4d154dca43c662571129af31b27433b919a32Adam Lesinski    // const
44716c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLpermille mMinPitch;
44816c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLpermille mMaxPitch;
44916c4d154dca43c662571129af31b27433b919a32Adam Lesinski} IPitch;
45016c4d154dca43c662571129af31b27433b919a32Adam Lesinski
45191447d88f2bdf9c2bf8d1a53570efef6172fba74Narayan Kamathtypedef struct Play_interface {
45291447d88f2bdf9c2bf8d1a53570efef6172fba74Narayan Kamath    const struct SLPlayItf_ *mItf;
45316c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IObject *mThis;
45416c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint32 mState;
45516c4d154dca43c662571129af31b27433b919a32Adam Lesinski    // next 2 fields are read-only to application
45616c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLmillisecond mDuration;
45716c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLmillisecond mPosition;
45816c4d154dca43c662571129af31b27433b919a32Adam Lesinski    slPlayCallback mCallback;
45916c4d154dca43c662571129af31b27433b919a32Adam Lesinski    void *mContext;
46016c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint32 mEventFlags;
46116c4d154dca43c662571129af31b27433b919a32Adam Lesinski    // the ISeek trick of using a distinct value doesn't work here because it's readable by app
46216c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLmillisecond mMarkerPosition;
46316c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLmillisecond mPositionUpdatePeriod; // Zero means do not do position updates (FIXME ~0)
46416c4d154dca43c662571129af31b27433b919a32Adam Lesinski#ifdef USE_OUTPUTMIXEXT
46516c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint32 mFrameUpdatePeriod;         // mPositionUpdatePeriod in frame units
46616c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLmillisecond mLastSeekPosition;     // Last known accurate position, set at Seek
46716c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint32 mFramesSinceLastSeek;       // Frames mixed since last known accurate position
46816c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint32 mFramesSincePositionUpdate; // Frames mixed since last position update callback
46916c4d154dca43c662571129af31b27433b919a32Adam Lesinski#endif
47016c4d154dca43c662571129af31b27433b919a32Adam Lesinski} IPlay;
47116c4d154dca43c662571129af31b27433b919a32Adam Lesinski
47216c4d154dca43c662571129af31b27433b919a32Adam Lesinskitypedef struct {
47316c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct SLPlaybackRateItf_ *mItf;
47416c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IObject *mThis;
47516c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLpermille mRate;
47616c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint32 mProperties;
47716c4d154dca43c662571129af31b27433b919a32Adam Lesinski    // const
47816c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLpermille mMinRate;
47916c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLpermille mMaxRate;
48016c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLpermille mStepSize;
48116c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint32 mCapabilities;
48216c4d154dca43c662571129af31b27433b919a32Adam Lesinski} IPlaybackRate;
48316c4d154dca43c662571129af31b27433b919a32Adam Lesinski
48416c4d154dca43c662571129af31b27433b919a32Adam Lesinskitypedef struct {
48516c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct SLPrefetchStatusItf_ *mItf;
48616c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IObject *mThis;
48716c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint32 mStatus;
48816c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLpermille mLevel;
48916c4d154dca43c662571129af31b27433b919a32Adam Lesinski    slPrefetchCallback mCallback;
49016c4d154dca43c662571129af31b27433b919a32Adam Lesinski    void *mContext;
49116c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint32 mCallbackEventsMask;
49216c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLpermille mFillUpdatePeriod;
49316c4d154dca43c662571129af31b27433b919a32Adam Lesinski} IPrefetchStatus;
49416c4d154dca43c662571129af31b27433b919a32Adam Lesinski
49516c4d154dca43c662571129af31b27433b919a32Adam Lesinskitypedef struct {
49616c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct SLPresetReverbItf_ *mItf;
49716c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IObject *mThis;
49816c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint16 mPreset;
49916c4d154dca43c662571129af31b27433b919a32Adam Lesinski#if defined(ANDROID)
50016c4d154dca43c662571129af31b27433b919a32Adam Lesinski    effect_descriptor_t mPresetReverbDescriptor;
50116c4d154dca43c662571129af31b27433b919a32Adam Lesinski    android::sp<android::AudioEffect> mPresetReverbEffect;
50216c4d154dca43c662571129af31b27433b919a32Adam Lesinski#endif
50316c4d154dca43c662571129af31b27433b919a32Adam Lesinski} IPresetReverb;
50416c4d154dca43c662571129af31b27433b919a32Adam Lesinski
50516c4d154dca43c662571129af31b27433b919a32Adam Lesinskitypedef struct {
50616c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct SLRatePitchItf_ *mItf;
50716c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IObject *mThis;
50816c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLpermille mRate;
50916c4d154dca43c662571129af31b27433b919a32Adam Lesinski    // const
51016c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLpermille mMinRate;
51116c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLpermille mMaxRate;
51216c4d154dca43c662571129af31b27433b919a32Adam Lesinski} IRatePitch;
51316c4d154dca43c662571129af31b27433b919a32Adam Lesinski
51416c4d154dca43c662571129af31b27433b919a32Adam Lesinskitypedef struct {
51516c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct SLRecordItf_ *mItf;
51616c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IObject *mThis;
51716c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint32 mState;
51816c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLmillisecond mDurationLimit;
51916c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLmillisecond mPosition;
52016c4d154dca43c662571129af31b27433b919a32Adam Lesinski    slRecordCallback mCallback;
52116c4d154dca43c662571129af31b27433b919a32Adam Lesinski    void *mContext;
52216c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint32 mCallbackEventsMask;
52316c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLmillisecond mMarkerPosition;
52416c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLmillisecond mPositionUpdatePeriod;
52516c4d154dca43c662571129af31b27433b919a32Adam Lesinski} IRecord;
526de898ff42912bd7ca1bfb099cd439562496765a4Adam Lesinski
52716c4d154dca43c662571129af31b27433b919a32Adam Lesinskitypedef struct {
52816c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct SLSeekItf_ *mItf;
52916c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IObject *mThis;
53016c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLmillisecond mPos;     // mPos != SL_TIME_UNKNOWN means pending seek request
53116c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLboolean mLoopEnabled;
53216c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLmillisecond mStartPos;
53316c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLmillisecond mEndPos;
53416c4d154dca43c662571129af31b27433b919a32Adam Lesinski} ISeek;
53516c4d154dca43c662571129af31b27433b919a32Adam Lesinski
53616c4d154dca43c662571129af31b27433b919a32Adam Lesinskitypedef struct {
53716c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct SLThreadSyncItf_ *mItf;
53816c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IObject *mThis;
53916c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLboolean mInCriticalSection;
54016c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint32 mWaiting;  // number of threads waiting
54116c4d154dca43c662571129af31b27433b919a32Adam Lesinski    pthread_t mOwner;
54216c4d154dca43c662571129af31b27433b919a32Adam Lesinski} IThreadSync;
54316c4d154dca43c662571129af31b27433b919a32Adam Lesinski
54416c4d154dca43c662571129af31b27433b919a32Adam Lesinskitypedef struct {
54516c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct SLVibraItf_ *mItf;
54616c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IObject *mThis;
547de898ff42912bd7ca1bfb099cd439562496765a4Adam Lesinski    SLboolean mVibrate;
54816c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLmilliHertz mFrequency;
54916c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLpermille mIntensity;
55016c4d154dca43c662571129af31b27433b919a32Adam Lesinski} IVibra;
55116c4d154dca43c662571129af31b27433b919a32Adam Lesinski
55216c4d154dca43c662571129af31b27433b919a32Adam Lesinskitypedef struct {
55316c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct SLVirtualizerItf_ *mItf;
55416c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IObject *mThis;
555a0c6260705c841f501282e0e337970ca9a00e064Narayan Kamath    SLboolean mEnabled;
55616c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLpermille mStrength;
557a0c6260705c841f501282e0e337970ca9a00e064Narayan Kamath#if defined(ANDROID)
55816c4d154dca43c662571129af31b27433b919a32Adam Lesinski    effect_descriptor_t mVirtualizerDescriptor;
55916c4d154dca43c662571129af31b27433b919a32Adam Lesinski    android::sp<android::AudioEffect> mVirtualizerEffect;
56016c4d154dca43c662571129af31b27433b919a32Adam Lesinski#endif
56116c4d154dca43c662571129af31b27433b919a32Adam Lesinski} IVirtualizer;
56216c4d154dca43c662571129af31b27433b919a32Adam Lesinski
56316c4d154dca43c662571129af31b27433b919a32Adam Lesinskitypedef struct {
56416c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct SLVisualizationItf_ *mItf;
56516c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IObject *mThis;
56616c4d154dca43c662571129af31b27433b919a32Adam Lesinski    slVisualizationCallback mCallback;
56716c4d154dca43c662571129af31b27433b919a32Adam Lesinski    void *mContext;
56816c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLmilliHertz mRate;
56916c4d154dca43c662571129af31b27433b919a32Adam Lesinski} IVisualization;
57016c4d154dca43c662571129af31b27433b919a32Adam Lesinski
57116c4d154dca43c662571129af31b27433b919a32Adam Lesinskitypedef struct /*Volume_interface*/ {
57216c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct SLVolumeItf_ *mItf;
57316c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IObject *mThis;
57416c4d154dca43c662571129af31b27433b919a32Adam Lesinski    // Values as specified by the application
57516c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLmillibel mLevel;
57616c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLpermille mStereoPosition;
57716c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint8 /*SLboolean*/ mMute;
57816c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint8 /*SLboolean*/ mEnableStereoPosition;
57916c4d154dca43c662571129af31b27433b919a32Adam Lesinski} IVolume;
58016c4d154dca43c662571129af31b27433b919a32Adam Lesinski
58116c4d154dca43c662571129af31b27433b919a32Adam Lesinskitypedef struct {
58216c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct XAEngineItf_ *mItf;
58316c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IObject *mThis;
58416c4d154dca43c662571129af31b27433b919a32Adam Lesinski} IXAEngine;
58516c4d154dca43c662571129af31b27433b919a32Adam Lesinski
58616c4d154dca43c662571129af31b27433b919a32Adam Lesinskitypedef struct {
58716c4d154dca43c662571129af31b27433b919a32Adam Lesinski    const struct XAStreamInformationItf_ *mItf;
58816c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IObject *mThis;
58916c4d154dca43c662571129af31b27433b919a32Adam Lesinski    xaStreamEventChangeCallback mCallback;
59016c4d154dca43c662571129af31b27433b919a32Adam Lesinski    void *mContext;
59116c4d154dca43c662571129af31b27433b919a32Adam Lesinski#ifdef ANDROID
59216c4d154dca43c662571129af31b27433b919a32Adam Lesinski    android::Vector<StreamInfo> mStreamInfoTable;
59316c4d154dca43c662571129af31b27433b919a32Adam Lesinski#endif
59416c4d154dca43c662571129af31b27433b919a32Adam Lesinski} IStreamInformation;
59516c4d154dca43c662571129af31b27433b919a32Adam Lesinski
59616c4d154dca43c662571129af31b27433b919a32Adam Lesinski/* Class structures */
59716c4d154dca43c662571129af31b27433b919a32Adam Lesinski
59816c4d154dca43c662571129af31b27433b919a32Adam Lesinski/*typedef*/ struct C3DGroup_struct {
59916c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IObject mObject;
60016c4d154dca43c662571129af31b27433b919a32Adam Lesinski#define INTERFACES_3DGroup 6 // see MPH_to_3DGroup in MPH_to.c for list of interfaces
60116c4d154dca43c662571129af31b27433b919a32Adam Lesinski    SLuint8 mInterfaceStates2[INTERFACES_3DGroup - INTERFACES_Default];
60216c4d154dca43c662571129af31b27433b919a32Adam Lesinski    IDynamicInterfaceManagement mDynamicInterfaceManagement;
6037df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba    I3DLocation m3DLocation;
6047df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba    I3DDoppler m3DDoppler;
6057df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba    I3DSource m3DSource;
6067df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba    I3DMacroscopic m3DMacroscopic;
6077df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba    // remaining are per-instance private fields not associated with an interface
6087df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba    unsigned mMemberMask;   // set of member objects
6097df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba} /*C3DGroup*/;
6107df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba
6117df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba#ifdef ANDROID
6127df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba
6137df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba// FIXME Move these into the I... section above
6147df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba
6157df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosibatypedef struct {
6167df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba    const struct SLAndroidEffectItf_ *mItf;
6177df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba    IObject *mThis;
6187df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba    android::KeyedVector<SLuint32, android::AudioEffect* > *mEffects;
6197df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba} IAndroidEffect;
6207df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba
6217df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosibatypedef struct {
6227df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba    const struct SLAndroidEffectCapabilitiesItf_ *mItf;
6237df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba    IObject *mThis;
6247df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba    SLuint32 mNumFx;
6257df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba    effect_descriptor_t* mFxDescriptors;
6267df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba} IAndroidEffectCapabilities;
6277df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba
6287df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosibatypedef struct {
6297df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba    const struct SLAndroidEffectSendItf_ *mItf;
6307df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba    IObject *mThis;
6317df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba    // only one send per interface for now (1 bus)
6327df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba    SLboolean mEnabled;
6337df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba    SLmillibel mSendLevel; //android::KeyedVector<SLuint32, SLmillibel> mSendLevels;
6347df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba} IAndroidEffectSend;
6357df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba
6367df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosibatypedef struct {
6377df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba    const struct SLAndroidConfigurationItf_ *mItf;
6387df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba    IObject *mThis;
6397df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba} IAndroidConfiguration;
6407df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba
6417df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosibatypedef struct {
6427df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba    const struct SLAndroidBufferQueueItf_ *mItf;
6437df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba    IObject *mThis;
6447df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba    SLAndroidBufferQueueState mState;
6457df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba    slAndroidBufferQueueCallback mCallback;
6467df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba    void *mContext;
6477df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba    SLuint16 mNumBuffers;
6487df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba    AndroidBufferType_type mBufferType;
6497df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba    AdvancedBufferHeader *mBufferArray;
6507df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba    AdvancedBufferHeader *mFront, *mRear;
6517df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba} IAndroidBufferQueue;
6527df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba
6537df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba#endif
6547df3625d5bb28d11cce9ac23429f5e3c6ebac030Martin Kosiba