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