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