classes.h revision 13837cf3f7be0eb8b1a9552bd99a89f98c987720
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// Class structures 18 19 20/*typedef*/ struct CAudioPlayer_struct { 21 IObject mObject; 22#ifdef ANDROID 23#define INTERFACES_AudioPlayer 30 // see MPH_to_AudioPlayer in MPH_to.c for list of interfaces 24#else 25#define INTERFACES_AudioPlayer 26 // see MPH_to_AudioPlayer in MPH_to.c for list of interfaces 26#endif 27 SLuint8 mInterfaceStates2[INTERFACES_AudioPlayer - INTERFACES_Default]; 28 IDynamicInterfaceManagement mDynamicInterfaceManagement; 29 IPlay mPlay; 30 I3DDoppler m3DDoppler; 31 I3DGrouping m3DGrouping; 32 I3DLocation m3DLocation; 33 I3DSource m3DSource; 34 IBufferQueue mBufferQueue; 35 IEffectSend mEffectSend; 36 IMetadataExtraction mMetadataExtraction; 37 IMetadataTraversal mMetadataTraversal; 38 IPrefetchStatus mPrefetchStatus; 39 IRatePitch mRatePitch; 40 ISeek mSeek; 41 IVolume mVolume; 42 IMuteSolo mMuteSolo; 43#ifdef ANDROID 44 IAndroidEffect mAndroidEffect; 45 IAndroidEffectSend mAndroidEffectSend; 46 IAndroidConfiguration mAndroidConfiguration; 47 IAndroidBufferQueue mAndroidBufferQueue; 48#endif 49 // optional interfaces 50 I3DMacroscopic m3DMacroscopic; 51 IBassBoost mBassBoost; 52 IDynamicSource mDynamicSource; 53 IEnvironmentalReverb mEnvironmentalReverb; 54 IEqualizer mEqualizer; 55 IPitch mPitch; 56 IPresetReverb mPresetReverb; 57 IPlaybackRate mPlaybackRate; 58 IVirtualizer mVirtualizer; 59 IVisualization mVisualization; 60 // remaining are per-instance private fields not associated with an interface 61 DataLocatorFormat mDataSource; 62 DataLocatorFormat mDataSink; 63 // cached data for this instance 64 SLuint8 /*SLboolean*/ mMute; 65 // Formerly at IMuteSolo 66 SLuint8 mMuteMask; // Mask for which channels are muted: bit 0=left, 1=right 67 SLuint8 mSoloMask; // Mask for which channels are soloed: bit 0=left, 1=right 68 SLuint8 mNumChannels; // 0 means unknown, then const once it is known, range 1 <= x <= 8 69 SLuint32 mSampleRateMilliHz;// 0 means unknown, then const once it is known 70 // Formerly at IEffectSend 71 /** 72 * Dry volume modified by effect send interfaces: SLEffectSendItf and SLAndroidEffectSendItf 73 */ 74 SLmillibel mDirectLevel; 75 // implementation-specific data for this instance 76#ifdef USE_OUTPUTMIXEXT 77 Track *mTrack; 78 float mGains[STEREO_CHANNELS]; ///< Computed gain based on volume, mute, solo, stereo position 79 SLboolean mDestroyRequested; ///< Mixer to acknowledge application's call to Object::Destroy 80#endif 81#ifdef USE_SNDFILE 82 struct SndFile mSndFile; 83#endif // USE_SNDFILE 84#ifdef ANDROID 85 android::Mutex *mpLock; 86 enum AndroidObject_type mAndroidObjType; 87 /** identifies the initialization and preparation state */ 88 enum AndroidObject_state mAndroidObjState; 89 /** identifies which group of effects ("session") this player belongs to */ 90 int mSessionId; 91 /** identifies the Android stream type playback will occur on */ 92 int mStreamType; 93 /** plays the PCM data for this player */ 94 android::AudioTrack *mAudioTrack; // FIXME consolidate into one class 95 android::sp<android::SfPlayer> mSfPlayer; // FIXME consolidate into one class 96 android::sp<android::StreamPlayer> mStreamPlayer; // FIXME consolidate into one class 97 android::sp<android::GenericPlayer> mAPlayer; // FIXME consolidate into one class 98 /** aux effect the AudioTrack will be attached to if aux send enabled */ 99 android::sp<android::AudioEffect> mAuxEffect; 100 // FIXME all levels below need to be encapsulated in a field of type AndroidAudioLevels 101 /** send level to aux effect, there's a single aux bus, so there's a single level */ 102 SLmillibel mAuxSendLevel; 103 /** 104 * Amplification (can be attenuation) factor derived for the VolumeLevel 105 */ 106 float mAmplFromVolLevel; 107 /** 108 * Left/right amplification (can be attenuations) factors derived for the StereoPosition 109 */ 110 float mAmplFromStereoPos[STEREO_CHANNELS]; 111 /** 112 * Attenuation factor derived from direct level 113 */ 114 float mAmplFromDirectLevel; 115#endif 116} /*CAudioPlayer*/; 117 118 119/*typedef*/ struct CAudioRecorder_struct { 120 // mandated interfaces 121 IObject mObject; 122#ifdef ANDROID 123#define INTERFACES_AudioRecorder 11 // see MPH_to_AudioRecorder in MPH_to.c for list of interfaces 124#else 125#define INTERFACES_AudioRecorder 9 // see MPH_to_AudioRecorder in MPH_to.c for list of interfaces 126#endif 127 SLuint8 mInterfaceStates2[INTERFACES_AudioRecorder - INTERFACES_Default]; 128 IDynamicInterfaceManagement mDynamicInterfaceManagement; 129 IRecord mRecord; 130 IAudioEncoder mAudioEncoder; 131 // optional interfaces 132 IBassBoost mBassBoost; 133 IDynamicSource mDynamicSource; 134 IEqualizer mEqualizer; 135 IVisualization mVisualization; 136 IVolume mVolume; 137#ifdef ANDROID 138 IBufferQueue mBufferQueue; 139 IAndroidConfiguration mAndroidConfiguration; 140#endif 141 // remaining are per-instance private fields not associated with an interface 142 DataLocatorFormat mDataSource; 143 DataLocatorFormat mDataSink; 144 // cached data for this instance 145 SLuint8 mNumChannels; // 0 means unknown, then const once it is known, range 1 <= x <= 8 146 SLuint32 mSampleRateMilliHz;// 0 means unknown, then const once it is known 147 // implementation-specific data for this instance 148#ifdef ANDROID 149 enum AndroidObject_type mAndroidObjType; 150 android::AudioRecord *mAudioRecord; //FIXME candidate to be encapsulated in a ARecorder subclass 151 int mRecordSource; //FIXME candidate to be encapsulated in a ARecorder subclass 152#endif 153} /*CAudioRecorder*/; 154 155 156/*typedef*/ struct CEngine_struct { 157 // mandated implicit interfaces 158 IObject mObject; 159#ifdef ANDROID 160#define INTERFACES_Engine 12 // see MPH_to_Engine in MPH_to.c for list of interfaces 161#else 162#define INTERFACES_Engine 11 // see MPH_to_Engine in MPH_to.c for list of interfaces 163#endif 164 SLuint8 mInterfaceStates2[INTERFACES_Engine - INTERFACES_Default]; 165 IDynamicInterfaceManagement mDynamicInterfaceManagement; 166 IEngine mEngine; 167 IEngineCapabilities mEngineCapabilities; 168 IThreadSync mThreadSync; 169 // mandated explicit interfaces 170 IAudioIODeviceCapabilities mAudioIODeviceCapabilities; 171 IAudioDecoderCapabilities mAudioDecoderCapabilities; 172 IAudioEncoderCapabilities mAudioEncoderCapabilities; 173 I3DCommit m3DCommit; 174 // optional interfaces 175 IDeviceVolume mDeviceVolume; 176 // OpenMAX AL mandated implicit interfaces 177 IXAEngine mXAEngine; 178#ifdef ANDROID 179 IAndroidEffectCapabilities mAndroidEffectCapabilities; 180#endif 181 // remaining are per-instance private fields not associated with an interface 182 ThreadPool mThreadPool; // for asynchronous operations 183 pthread_t mSyncThread; 184#if defined(ANDROID) 185 // FIXME number of presets will only be saved in IEqualizer, preset names will not be stored 186 SLuint32 mEqNumPresets; 187 char** mEqPresetNames; 188#endif 189} /*CEngine*/; 190 191typedef struct { 192 // mandated interfaces 193 IObject mObject; 194#define INTERFACES_LEDDevice 3 // see MPH_to_LEDDevice in MPH_to.c for list of interfaces 195 SLuint8 mInterfaceStates2[INTERFACES_LEDDevice - INTERFACES_Default]; 196 IDynamicInterfaceManagement mDynamicInterfaceManagement; 197 ILEDArray mLEDArray; 198 // remaining are per-instance private fields not associated with an interface 199 SLuint32 mDeviceID; 200} CLEDDevice; 201 202typedef struct { 203 // mandated interfaces 204 IObject mObject; 205#define INTERFACES_Listener 4 // see MPH_to_Listener in MPH_to.c for list of interfaces 206 SLuint8 mInterfaceStates2[INTERFACES_Listener - INTERFACES_Default]; 207 IDynamicInterfaceManagement mDynamicInterfaceManagement; 208 I3DDoppler m3DDoppler; 209 I3DLocation m3DLocation; 210 // remaining are per-instance private fields not associated with an interface 211} CListener; 212 213typedef struct { 214 // mandated interfaces 215 IObject mObject; 216#define INTERFACES_MetadataExtractor 5 // see MPH_to_MetadataExtractor in MPH_to.c for list of 217 // interfaces 218 SLuint8 mInterfaceStates2[INTERFACES_MetadataExtractor - INTERFACES_Default]; 219 IDynamicInterfaceManagement mDynamicInterfaceManagement; 220 IDynamicSource mDynamicSource; 221 IMetadataExtraction mMetadataExtraction; 222 IMetadataTraversal mMetadataTraversal; 223 // remaining are per-instance private fields not associated with an interface 224} CMetadataExtractor; 225 226typedef struct { 227 // mandated interfaces 228 IObject mObject; 229 230#define INTERFACES_MidiPlayer 29 // see MPH_to_MidiPlayer in MPH_to.c for list of interfaces 231 SLuint8 mInterfaceStates2[INTERFACES_MidiPlayer - INTERFACES_Default]; 232 IDynamicInterfaceManagement mDynamicInterfaceManagement; 233 IPlay mPlay; 234 I3DDoppler m3DDoppler; 235 I3DGrouping m3DGrouping; 236 I3DLocation m3DLocation; 237 I3DSource m3DSource; 238 IBufferQueue mBufferQueue; 239 IEffectSend mEffectSend; 240 IMetadataExtraction mMetadataExtraction; 241 IMetadataTraversal mMetadataTraversal; 242 IMIDIMessage mMIDIMessage; 243 IMIDITime mMIDITime; 244 IMIDITempo mMIDITempo; 245 IMIDIMuteSolo mMIDIMuteSolo; 246 IPrefetchStatus mPrefetchStatus; 247 ISeek mSeek; 248 IVolume mVolume; 249 IMuteSolo mMuteSolo; 250 // optional interfaces 251 I3DMacroscopic m3DMacroscopic; 252 IBassBoost mBassBoost; 253 IDynamicSource mDynamicSource; 254 IEnvironmentalReverb mEnvironmentalReverb; 255 IEqualizer mEqualizer; 256 IPitch mPitch; 257 IPresetReverb mPresetReverb; 258 IPlaybackRate mPlaybackRate; 259 IVirtualizer mVirtualizer; 260 IVisualization mVisualization; 261 // remaining are per-instance private fields not associated with an interface 262} CMidiPlayer; 263 264/*typedef*/ struct COutputMix_struct { 265 // mandated interfaces 266 IObject mObject; 267#ifdef ANDROID 268#define INTERFACES_OutputMix 12 // see MPH_to_OutputMix in MPH_to.c for list of interfaces 269#else 270#define INTERFACES_OutputMix 11 // see MPH_to_OutputMix in MPH_to.c for list of interfaces 271#endif 272 SLuint8 mInterfaceStates2[INTERFACES_OutputMix - INTERFACES_Default]; 273 IDynamicInterfaceManagement mDynamicInterfaceManagement; 274 IOutputMix mOutputMix; 275#ifdef USE_OUTPUTMIXEXT 276 IOutputMixExt mOutputMixExt; 277#endif 278 IEnvironmentalReverb mEnvironmentalReverb; 279 IEqualizer mEqualizer; 280 IPresetReverb mPresetReverb; 281 IVirtualizer mVirtualizer; 282 IVolume mVolume; 283 // optional interfaces 284 IBassBoost mBassBoost; 285 IVisualization mVisualization; 286#ifdef ANDROID 287 IAndroidEffect mAndroidEffect; 288#endif 289 // remaining are per-instance private fields not associated with an interface 290} /*COutputMix*/; 291 292typedef struct { 293 // mandated interfaces 294 IObject mObject; 295#define INTERFACES_VibraDevice 3 // see MPH_to_VibraDevice in MPH_to.c for list of interfaces 296 SLuint8 mInterfaceStates2[INTERFACES_VibraDevice - INTERFACES_Default]; 297 IDynamicInterfaceManagement mDynamicInterfaceManagement; 298 IVibra mVibra; 299 // remaining are per-instance private fields not associated with an interface 300 SLuint32 mDeviceID; 301} CVibraDevice; 302 303 304typedef struct CMediaPlayer_struct { 305 IObject mObject; 306#define INTERFACES_MediaPlayer 4 307 XAuint8 mInterfaceStates2[INTERFACES_MediaPlayer - INTERFACES_Default]; 308 IDynamicInterfaceManagement mDynamicInterfaceManagement; 309 IPlay mPlay; 310 IStreamInformation mStreamInfo; 311#ifdef ANDROID 312 IAndroidBufferQueue mAndroidBufferQueue; 313#endif 314 // ... 315 DataLocatorFormat mDataSource; 316 DataLocatorFormat mBankSource; 317 DataLocatorFormat mAudioSink; 318 DataLocatorFormat mImageVideoSink; 319 DataLocatorFormat mVibraSink; 320 DataLocatorFormat mLEDArraySink; 321 /** 322 * Dry volume modified by effect send interfaces: SLEffectSendItf and SLAndroidEffectSendItf 323 */ 324 SLmillibel mDirectLevel; 325#ifdef ANDROID 326 android::sp<android::AVPlayer> mAVPlayer; 327 enum AndroidObject_type mAndroidObjType; 328 /** identifies the initialization and preparation state */ 329 enum AndroidObject_state mAndroidObjState; 330 /** identifies which group of effects ("session") this player belongs to */ 331 int mSessionId; 332 /** identifies the Android stream type playback will occur on */ 333 int mStreamType; 334 AndroidAudioLevels mAndroidAudioLevels; 335#endif 336} CMediaPlayer; 337