classes.h revision 0bfed90f3b312f7c8f2b744efcf62f1992661d6c
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 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; // initially UNKNOWN_NUMCHANNELS, then const once it is known, 146 // range 1 <= x <= 8 147 SLuint32 mSampleRateMilliHz;// initially UNKNOWN_SAMPLERATE, then const once it is known 148 // implementation-specific data for this instance 149#ifdef ANDROID 150 enum AndroidObjectType mAndroidObjType; 151 android::AudioRecord *mAudioRecord; //FIXME candidate to be encapsulated in a ARecorder subclass 152 int mRecordSource; //FIXME candidate to be encapsulated in a ARecorder subclass 153#endif 154} /*CAudioRecorder*/; 155 156 157/*typedef*/ struct CEngine_struct { 158 // mandated implicit interfaces 159 IObject mObject; 160#ifdef ANDROID 161#define INTERFACES_Engine 13 // see MPH_to_Engine in MPH_to.c for list of interfaces 162#else 163#define INTERFACES_Engine 12 // see MPH_to_Engine in MPH_to.c for list of interfaces 164#endif 165 SLuint8 mInterfaceStates2[INTERFACES_Engine - INTERFACES_Default]; 166 IDynamicInterfaceManagement mDynamicInterfaceManagement; 167 IEngine mEngine; 168 IEngineCapabilities mEngineCapabilities; 169 IThreadSync mThreadSync; 170 // mandated explicit interfaces 171 IAudioIODeviceCapabilities mAudioIODeviceCapabilities; 172 IAudioDecoderCapabilities mAudioDecoderCapabilities; 173 IAudioEncoderCapabilities mAudioEncoderCapabilities; 174 I3DCommit m3DCommit; 175 // optional interfaces 176 IDeviceVolume mDeviceVolume; 177 // OpenMAX AL mandated implicit interfaces 178 IXAEngine mXAEngine; 179#ifdef ANDROID 180 IAndroidEffectCapabilities mAndroidEffectCapabilities; 181#endif 182 // OpenMAX AL explicit interfaces 183 IVideoDecoderCapabilities mVideoDecoderCapabilities; 184 // remaining are per-instance private fields not associated with an interface 185 ThreadPool mThreadPool; // for asynchronous operations 186 pthread_t mSyncThread; 187#if defined(ANDROID) 188 // FIXME number of presets will only be saved in IEqualizer, preset names will not be stored 189 SLuint32 mEqNumPresets; 190 char** mEqPresetNames; 191#endif 192} /*CEngine*/; 193 194typedef struct { 195 // mandated interfaces 196 IObject mObject; 197#define INTERFACES_LEDDevice 3 // see MPH_to_LEDDevice in MPH_to.c for list of interfaces 198 SLuint8 mInterfaceStates2[INTERFACES_LEDDevice - INTERFACES_Default]; 199 IDynamicInterfaceManagement mDynamicInterfaceManagement; 200 ILEDArray mLEDArray; 201 // remaining are per-instance private fields not associated with an interface 202 SLuint32 mDeviceID; 203} CLEDDevice; 204 205typedef struct { 206 // mandated interfaces 207 IObject mObject; 208#define INTERFACES_Listener 4 // see MPH_to_Listener in MPH_to.c for list of interfaces 209 SLuint8 mInterfaceStates2[INTERFACES_Listener - INTERFACES_Default]; 210 IDynamicInterfaceManagement mDynamicInterfaceManagement; 211 I3DDoppler m3DDoppler; 212 I3DLocation m3DLocation; 213 // remaining are per-instance private fields not associated with an interface 214} CListener; 215 216typedef struct { 217 // mandated interfaces 218 IObject mObject; 219#define INTERFACES_MetadataExtractor 5 // see MPH_to_MetadataExtractor in MPH_to.c for list of 220 // interfaces 221 SLuint8 mInterfaceStates2[INTERFACES_MetadataExtractor - INTERFACES_Default]; 222 IDynamicInterfaceManagement mDynamicInterfaceManagement; 223 IDynamicSource mDynamicSource; 224 IMetadataExtraction mMetadataExtraction; 225 IMetadataTraversal mMetadataTraversal; 226 // remaining are per-instance private fields not associated with an interface 227} CMetadataExtractor; 228 229typedef struct { 230 // mandated interfaces 231 IObject mObject; 232 233#define INTERFACES_MidiPlayer 29 // see MPH_to_MidiPlayer in MPH_to.c for list of interfaces 234 SLuint8 mInterfaceStates2[INTERFACES_MidiPlayer - INTERFACES_Default]; 235 IDynamicInterfaceManagement mDynamicInterfaceManagement; 236 IPlay mPlay; 237 I3DDoppler m3DDoppler; 238 I3DGrouping m3DGrouping; 239 I3DLocation m3DLocation; 240 I3DSource m3DSource; 241 IBufferQueue mBufferQueue; 242 IEffectSend mEffectSend; 243 IMetadataExtraction mMetadataExtraction; 244 IMetadataTraversal mMetadataTraversal; 245 IMIDIMessage mMIDIMessage; 246 IMIDITime mMIDITime; 247 IMIDITempo mMIDITempo; 248 IMIDIMuteSolo mMIDIMuteSolo; 249 IPrefetchStatus mPrefetchStatus; 250 ISeek mSeek; 251 IVolume mVolume; 252 IMuteSolo mMuteSolo; 253 // optional interfaces 254 I3DMacroscopic m3DMacroscopic; 255 IBassBoost mBassBoost; 256 IDynamicSource mDynamicSource; 257 IEnvironmentalReverb mEnvironmentalReverb; 258 IEqualizer mEqualizer; 259 IPitch mPitch; 260 IPresetReverb mPresetReverb; 261 IPlaybackRate mPlaybackRate; 262 IVirtualizer mVirtualizer; 263 IVisualization mVisualization; 264 // remaining are per-instance private fields not associated with an interface 265} CMidiPlayer; 266 267/*typedef*/ struct COutputMix_struct { 268 // mandated interfaces 269 IObject mObject; 270#ifdef ANDROID 271#define INTERFACES_OutputMix 12 // see MPH_to_OutputMix in MPH_to.c for list of interfaces 272#else 273#define INTERFACES_OutputMix 11 // see MPH_to_OutputMix in MPH_to.c for list of interfaces 274#endif 275 SLuint8 mInterfaceStates2[INTERFACES_OutputMix - INTERFACES_Default]; 276 IDynamicInterfaceManagement mDynamicInterfaceManagement; 277 IOutputMix mOutputMix; 278#ifdef USE_OUTPUTMIXEXT 279 IOutputMixExt mOutputMixExt; 280#endif 281 IEnvironmentalReverb mEnvironmentalReverb; 282 IEqualizer mEqualizer; 283 IPresetReverb mPresetReverb; 284 IVirtualizer mVirtualizer; 285 IVolume mVolume; 286 // optional interfaces 287 IBassBoost mBassBoost; 288 IVisualization mVisualization; 289#ifdef ANDROID 290 IAndroidEffect mAndroidEffect; 291#endif 292 // remaining are per-instance private fields not associated with an interface 293} /*COutputMix*/; 294 295typedef struct { 296 // mandated interfaces 297 IObject mObject; 298#define INTERFACES_VibraDevice 3 // see MPH_to_VibraDevice in MPH_to.c for list of interfaces 299 SLuint8 mInterfaceStates2[INTERFACES_VibraDevice - INTERFACES_Default]; 300 IDynamicInterfaceManagement mDynamicInterfaceManagement; 301 IVibra mVibra; 302 // remaining are per-instance private fields not associated with an interface 303 SLuint32 mDeviceID; 304} CVibraDevice; 305 306 307typedef struct CMediaPlayer_struct { 308 IObject mObject; 309#ifdef ANDROID 310#define INTERFACES_MediaPlayer 8 311#else 312#define INTERFACES_MediaPlayer 7 313#endif 314 XAuint8 mInterfaceStates2[INTERFACES_MediaPlayer - INTERFACES_Default]; 315 IDynamicInterfaceManagement mDynamicInterfaceManagement; 316 IDynamicSource mDynamicSource; 317 IPlay mPlay; 318 IStreamInformation mStreamInfo; 319 IVolume mVolume; 320 ISeek mSeek; 321 IPrefetchStatus mPrefetchStatus; 322#ifdef ANDROID 323 IAndroidBufferQueue mAndroidBufferQueue; 324#endif 325 // fields below are per-instance private fields not associated with an interface 326 DataLocatorFormat mDataSource; 327 DataLocatorFormat mBankSource; 328 DataLocatorFormat mAudioSink; 329 DataLocatorFormat mImageVideoSink; 330 DataLocatorFormat mVibraSink; 331 DataLocatorFormat mLEDArraySink; 332 SLuint8 mNumChannels; // initially UNKNOWN_NUMCHANNELS, then const once it is known, 333 // range 1 <= x <= 8 334#ifdef ANDROID 335 android::sp<android::GenericPlayer> mAVPlayer; 336 android::sp<android::CallbackProtector> mCallbackProtector; 337 enum AndroidObjectType mAndroidObjType; 338 /** identifies the initialization and preparation state */ 339 enum AndroidObjectState mAndroidObjState; 340 /** identifies which group of effects ("session") this player belongs to */ 341 int mSessionId; 342 /** identifies the Android stream type playback will occur on */ 343 audio_stream_type_t mStreamType; 344#endif 345} CMediaPlayer; 346