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