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