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