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