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