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