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 /* Classes vs. interfaces */
18 
19 #include "sles_allinclusive.h"
20 
21 
22 #if USE_PROFILES & USE_PROFILES_GAME
23 
24 // 3DGroup class
25 
26 static const struct iid_vtable _3DGroup_interfaces[INTERFACES_3DGroup] = {
27     {MPH_OBJECT, INTERFACE_IMPLICIT_PREREALIZE, offsetof(C3DGroup, mObject)},
28     {MPH_DYNAMICINTERFACEMANAGEMENT, INTERFACE_IMPLICIT,
29         offsetof(C3DGroup, mDynamicInterfaceManagement)},
30     {MPH_3DLOCATION, INTERFACE_IMPLICIT, offsetof(C3DGroup, m3DLocation)},
31     {MPH_3DDOPPLER, INTERFACE_DYNAMIC_GAME, offsetof(C3DGroup, m3DDoppler)},
32     {MPH_3DSOURCE, INTERFACE_EXPLICIT_GAME, offsetof(C3DGroup, m3DSource)},
33     {MPH_3DMACROSCOPIC, INTERFACE_OPTIONAL, offsetof(C3DGroup, m3DMacroscopic)},
34 };
35 
36 static const ClassTable C3DGroup_class = {
37     _3DGroup_interfaces,
38     INTERFACES_3DGroup,
39     MPH_to_3DGroup,
40     "3DGroup",
41     sizeof(C3DGroup),
42     SL_OBJECTID_3DGROUP,
43     0,      // OpenMAX AL object ID
44     NULL,
45     NULL,
46     NULL,
47     C3DGroup_PreDestroy
48 };
49 
50 #endif
51 
52 
53 // AudioPlayer class
54 
55 static const struct iid_vtable AudioPlayer_interfaces[INTERFACES_AudioPlayer] = {
56     {MPH_OBJECT, INTERFACE_IMPLICIT_PREREALIZE, offsetof(CAudioPlayer, mObject)},
57     {MPH_DYNAMICINTERFACEMANAGEMENT, INTERFACE_IMPLICIT,
58         offsetof(CAudioPlayer, mDynamicInterfaceManagement)},
59     {MPH_PLAY, INTERFACE_IMPLICIT, offsetof(CAudioPlayer, mPlay)},
60     {MPH_3DDOPPLER, INTERFACE_DYNAMIC_GAME, offsetof(CAudioPlayer, m3DDoppler)},
61     {MPH_3DGROUPING, INTERFACE_EXPLICIT_GAME, offsetof(CAudioPlayer, m3DGrouping)},
62     {MPH_3DLOCATION, INTERFACE_EXPLICIT_GAME, offsetof(CAudioPlayer, m3DLocation)},
63     {MPH_3DSOURCE, INTERFACE_EXPLICIT_GAME, offsetof(CAudioPlayer, m3DSource)},
64     {MPH_BUFFERQUEUE, INTERFACE_EXPLICIT, offsetof(CAudioPlayer, mBufferQueue)},
65     {MPH_EFFECTSEND, INTERFACE_EXPLICIT, offsetof(CAudioPlayer, mEffectSend)},
66     {MPH_MUTESOLO, INTERFACE_EXPLICIT, offsetof(CAudioPlayer, mMuteSolo)},
67     {MPH_METADATAEXTRACTION, INTERFACE_DYNAMIC,
68         offsetof(CAudioPlayer, mMetadataExtraction)},
69     {MPH_METADATATRAVERSAL, INTERFACE_DYNAMIC_GAME_MUSIC,
70         offsetof(CAudioPlayer, mMetadataTraversal)},
71     {MPH_PREFETCHSTATUS, INTERFACE_EXPLICIT, offsetof(CAudioPlayer, mPrefetchStatus)},
72     {MPH_RATEPITCH, INTERFACE_DYNAMIC_GAME, offsetof(CAudioPlayer, mRatePitch)},
73     {MPH_SEEK, INTERFACE_EXPLICIT, offsetof(CAudioPlayer, mSeek)},
74     // The base Volume interface is explicit, but portions are only for Game and Music profiles
75     {MPH_VOLUME, INTERFACE_EXPLICIT, offsetof(CAudioPlayer, mVolume)},
76     {MPH_3DMACROSCOPIC, INTERFACE_OPTIONAL, offsetof(CAudioPlayer, m3DMacroscopic)},
77     {MPH_BASSBOOST, INTERFACE_DYNAMIC, offsetof(CAudioPlayer, mBassBoost)},
78     {MPH_DYNAMICSOURCE, INTERFACE_OPTIONAL, offsetof(CAudioPlayer, mDynamicSource)},
79     {MPH_ENVIRONMENTALREVERB, INTERFACE_DYNAMIC,
80         offsetof(CAudioPlayer, mEnvironmentalReverb)},
81     {MPH_EQUALIZER, INTERFACE_DYNAMIC, offsetof(CAudioPlayer, mEqualizer)},
82     {MPH_PITCH, INTERFACE_DYNAMIC_OPTIONAL, offsetof(CAudioPlayer, mPitch)},
83     {MPH_PRESETREVERB, INTERFACE_DYNAMIC, offsetof(CAudioPlayer, mPresetReverb)},
84     {MPH_PLAYBACKRATE, INTERFACE_DYNAMIC, offsetof(CAudioPlayer, mPlaybackRate)},
85     {MPH_VIRTUALIZER, INTERFACE_DYNAMIC, offsetof(CAudioPlayer, mVirtualizer)},
86     {MPH_VISUALIZATION, INTERFACE_OPTIONAL, offsetof(CAudioPlayer, mVisualization)},
87 #ifdef ANDROID
88     {MPH_ANDROIDEFFECT, INTERFACE_EXPLICIT, offsetof(CAudioPlayer, mAndroidEffect)},
89     {MPH_ANDROIDEFFECTSEND, INTERFACE_EXPLICIT, offsetof(CAudioPlayer, mAndroidEffectSend)},
90     {MPH_ANDROIDCONFIGURATION, INTERFACE_EXPLICIT_PREREALIZE,
91             offsetof(CAudioPlayer, mAndroidConfiguration)},
92     {MPH_ANDROIDBUFFERQUEUESOURCE, INTERFACE_EXPLICIT, offsetof(CAudioPlayer, mAndroidBufferQueue)},
93 #endif
94 };
95 
96 static const ClassTable CAudioPlayer_class = {
97     AudioPlayer_interfaces,
98     INTERFACES_AudioPlayer,
99     MPH_to_AudioPlayer,
100     "AudioPlayer",
101     sizeof(CAudioPlayer),
102     SL_OBJECTID_AUDIOPLAYER,
103     0,      // OpenMAX AL object ID
104     CAudioPlayer_Realize,
105     CAudioPlayer_Resume,
106     CAudioPlayer_Destroy,
107     CAudioPlayer_PreDestroy
108 };
109 
110 
111 #if (USE_PROFILES & USE_PROFILES_OPTIONAL) || defined(ANDROID)
112 
113 // AudioRecorder class
114 
115 static const struct iid_vtable AudioRecorder_interfaces[INTERFACES_AudioRecorder] = {
116     {MPH_OBJECT, INTERFACE_IMPLICIT_PREREALIZE, offsetof(CAudioRecorder, mObject)},
117     {MPH_DYNAMICINTERFACEMANAGEMENT, INTERFACE_IMPLICIT,
118         offsetof(CAudioRecorder, mDynamicInterfaceManagement)},
119     {MPH_RECORD, INTERFACE_IMPLICIT, offsetof(CAudioRecorder, mRecord)},
120     {MPH_AUDIOENCODER, INTERFACE_EXPLICIT, offsetof(CAudioRecorder, mAudioEncoder)},
121     {MPH_BASSBOOST, INTERFACE_DYNAMIC_OPTIONAL, offsetof(CAudioRecorder, mBassBoost)},
122     {MPH_DYNAMICSOURCE, INTERFACE_OPTIONAL, offsetof(CAudioRecorder, mDynamicSource)},
123     {MPH_EQUALIZER, INTERFACE_DYNAMIC_OPTIONAL, offsetof(CAudioRecorder, mEqualizer)},
124     {MPH_VISUALIZATION, INTERFACE_OPTIONAL, offsetof(CAudioRecorder, mVisualization)},
125     {MPH_VOLUME, INTERFACE_OPTIONAL, offsetof(CAudioRecorder, mVolume)},
126 #ifdef ANDROID
127     {MPH_ANDROIDSIMPLEBUFFERQUEUE, INTERFACE_EXPLICIT, offsetof(CAudioRecorder, mBufferQueue)},
128     {MPH_ANDROIDCONFIGURATION, INTERFACE_EXPLICIT_PREREALIZE,
129             offsetof(CAudioRecorder, mAndroidConfiguration)},
130     {MPH_ANDROIDACOUSTICECHOCANCELLATION, INTERFACE_OPTIONAL, offsetof(CAudioRecorder,
131                                                               mAcousticEchoCancellation)},
132     {MPH_ANDROIDAUTOMATICGAINCONTROL, INTERFACE_OPTIONAL, offsetof(CAudioRecorder,
133                                                                    mAutomaticGainControl)},
134     {MPH_ANDROIDNOISESUPPRESSION, INTERFACE_OPTIONAL, offsetof(CAudioRecorder, mNoiseSuppression)},
135 #endif
136 };
137 
138 static const ClassTable CAudioRecorder_class = {
139     AudioRecorder_interfaces,
140     INTERFACES_AudioRecorder,
141     MPH_to_AudioRecorder,
142     "AudioRecorder",
143     sizeof(CAudioRecorder),
144     SL_OBJECTID_AUDIORECORDER,
145     0,      // OpenMAX AL object ID
146     CAudioRecorder_Realize,
147     CAudioRecorder_Resume,
148     CAudioRecorder_Destroy,
149     CAudioRecorder_PreDestroy
150 };
151 
152 #endif
153 
154 
155 // Engine class
156 
157 static const struct iid_vtable Engine_interfaces[INTERFACES_Engine] = {
158     {MPH_OBJECT, INTERFACE_IMPLICIT_PREREALIZE, offsetof(CEngine, mObject)},
159     {MPH_DYNAMICINTERFACEMANAGEMENT, INTERFACE_IMPLICIT,
160         offsetof(CEngine, mDynamicInterfaceManagement)},
161     {MPH_ENGINE, INTERFACE_IMPLICIT, offsetof(CEngine, mEngine)},
162     {MPH_ENGINECAPABILITIES, INTERFACE_IMPLICIT_BASE, offsetof(CEngine, mEngineCapabilities)},
163     {MPH_THREADSYNC, INTERFACE_IMPLICIT_BASE, offsetof(CEngine, mThreadSync)},
164     {MPH_AUDIOIODEVICECAPABILITIES, INTERFACE_IMPLICIT_BASE,
165         offsetof(CEngine, mAudioIODeviceCapabilities)},
166     {MPH_AUDIODECODERCAPABILITIES, INTERFACE_EXPLICIT_BASE,
167         offsetof(CEngine, mAudioDecoderCapabilities)},
168     {MPH_AUDIOENCODERCAPABILITIES, INTERFACE_EXPLICIT_BASE,
169         offsetof(CEngine, mAudioEncoderCapabilities)},
170     {MPH_3DCOMMIT, INTERFACE_EXPLICIT_GAME, offsetof(CEngine, m3DCommit)},
171     {MPH_DEVICEVOLUME, INTERFACE_OPTIONAL, offsetof(CEngine, mDeviceVolume)},
172     {MPH_XAENGINE, INTERFACE_IMPLICIT, offsetof(CEngine, mXAEngine)},
173 #ifdef ANDROID
174     {MPH_ANDROIDEFFECTCAPABILITIES, INTERFACE_EXPLICIT,
175         offsetof(CEngine, mAndroidEffectCapabilities)},
176 #endif
177     {MPH_XAVIDEODECODERCAPABILITIES, INTERFACE_EXPLICIT,
178         offsetof(CEngine, mVideoDecoderCapabilities)},
179 };
180 
181 static const ClassTable CEngine_class = {
182     Engine_interfaces,
183     INTERFACES_Engine,
184     MPH_to_Engine,
185     "Engine",
186     sizeof(CEngine),
187     SL_OBJECTID_ENGINE,
188     XA_OBJECTID_ENGINE,
189     CEngine_Realize,
190     CEngine_Resume,
191     CEngine_Destroy,
192     CEngine_PreDestroy
193 };
194 
195 
196 #if USE_PROFILES & USE_PROFILES_OPTIONAL
197 
198 // LEDDevice class
199 
200 static const struct iid_vtable LEDDevice_interfaces[INTERFACES_LEDDevice] = {
201     {MPH_OBJECT, INTERFACE_IMPLICIT_PREREALIZE, offsetof(CLEDDevice, mObject)},
202     {MPH_DYNAMICINTERFACEMANAGEMENT, INTERFACE_IMPLICIT,
203         offsetof(CLEDDevice, mDynamicInterfaceManagement)},
204     {MPH_LED, INTERFACE_IMPLICIT, offsetof(CLEDDevice, mLEDArray)},
205 };
206 
207 static const ClassTable CLEDDevice_class = {
208     LEDDevice_interfaces,
209     INTERFACES_LEDDevice,
210     MPH_to_LEDDevice,
211     "LEDDevice",
212     sizeof(CLEDDevice),
213     SL_OBJECTID_LEDDEVICE,
214     XA_OBJECTID_LEDDEVICE,
215     NULL,
216     NULL,
217     NULL,
218     NULL
219 };
220 
221 #endif
222 
223 
224 #if USE_PROFILES & USE_PROFILES_GAME
225 
226 // Listener class
227 
228 static const struct iid_vtable Listener_interfaces[INTERFACES_Listener] = {
229     {MPH_OBJECT, INTERFACE_IMPLICIT_PREREALIZE, offsetof(CListener, mObject)},
230     {MPH_DYNAMICINTERFACEMANAGEMENT, INTERFACE_IMPLICIT,
231         offsetof(CListener, mDynamicInterfaceManagement)},
232     {MPH_3DDOPPLER, INTERFACE_DYNAMIC_GAME, offsetof(CListener, m3DDoppler)},
233     {MPH_3DLOCATION, INTERFACE_EXPLICIT_GAME, offsetof(CListener, m3DLocation)},
234 };
235 
236 static const ClassTable CListener_class = {
237     Listener_interfaces,
238     INTERFACES_Listener,
239     MPH_to_Listener,
240     "Listener",
241     sizeof(CListener),
242     SL_OBJECTID_LISTENER,
243     0,      // OpenMAX AL object ID
244     NULL,
245     NULL,
246     NULL,
247     NULL
248 };
249 
250 #endif
251 
252 
253 #if USE_PROFILES & (USE_PROFILES_GAME | USE_PROFILES_MUSIC)
254 
255 // MetadataExtractor class
256 
257 static const struct iid_vtable MetadataExtractor_interfaces[INTERFACES_MetadataExtractor] = {
258     {MPH_OBJECT, INTERFACE_IMPLICIT_PREREALIZE, offsetof(CMetadataExtractor, mObject)},
259     {MPH_DYNAMICINTERFACEMANAGEMENT, INTERFACE_IMPLICIT,
260         offsetof(CMetadataExtractor, mDynamicInterfaceManagement)},
261     {MPH_DYNAMICSOURCE, INTERFACE_IMPLICIT, offsetof(CMetadataExtractor, mDynamicSource)},
262     {MPH_METADATAEXTRACTION, INTERFACE_IMPLICIT, offsetof(CMetadataExtractor, mMetadataExtraction)},
263     {MPH_METADATATRAVERSAL, INTERFACE_IMPLICIT, offsetof(CMetadataExtractor, mMetadataTraversal)},
264 };
265 
266 static const ClassTable CMetadataExtractor_class = {
267     MetadataExtractor_interfaces,
268     INTERFACES_MetadataExtractor,
269     MPH_to_MetadataExtractor,
270     "MetadataExtractor",
271     sizeof(CMetadataExtractor),
272     SL_OBJECTID_METADATAEXTRACTOR,
273     XA_OBJECTID_METADATAEXTRACTOR,
274     NULL,
275     NULL,
276     NULL,
277     NULL
278 };
279 
280 #endif
281 
282 
283 #if USE_PROFILES & USE_PROFILES_GAME
284 
285 // MidiPlayer class
286 
287 static const struct iid_vtable MidiPlayer_interfaces[INTERFACES_MidiPlayer] = {
288     {MPH_OBJECT, INTERFACE_IMPLICIT_PREREALIZE, offsetof(CMidiPlayer, mObject)},
289     {MPH_DYNAMICINTERFACEMANAGEMENT, INTERFACE_IMPLICIT,
290         offsetof(CMidiPlayer, mDynamicInterfaceManagement)},
291     {MPH_PLAY, INTERFACE_IMPLICIT, offsetof(CMidiPlayer, mPlay)},
292     {MPH_3DDOPPLER, INTERFACE_DYNAMIC_GAME, offsetof(C3DGroup, m3DDoppler)},
293     {MPH_3DGROUPING, INTERFACE_EXPLICIT_GAME, offsetof(CMidiPlayer, m3DGrouping)},
294     {MPH_3DLOCATION, INTERFACE_EXPLICIT_GAME, offsetof(CMidiPlayer, m3DLocation)},
295     {MPH_3DSOURCE, INTERFACE_EXPLICIT_GAME, offsetof(CMidiPlayer, m3DSource)},
296     {MPH_BUFFERQUEUE, INTERFACE_EXPLICIT_GAME, offsetof(CMidiPlayer, mBufferQueue)},
297     {MPH_EFFECTSEND, INTERFACE_EXPLICIT_GAME, offsetof(CMidiPlayer, mEffectSend)},
298     {MPH_MUTESOLO, INTERFACE_EXPLICIT_GAME, offsetof(CMidiPlayer, mMuteSolo)},
299     {MPH_METADATAEXTRACTION, INTERFACE_DYNAMIC_GAME, offsetof(CMidiPlayer, mMetadataExtraction)},
300     {MPH_METADATATRAVERSAL, INTERFACE_DYNAMIC_GAME, offsetof(CMidiPlayer, mMetadataTraversal)},
301     {MPH_MIDIMESSAGE, INTERFACE_EXPLICIT_GAME_PHONE, offsetof(CMidiPlayer, mMIDIMessage)},
302     {MPH_MIDITIME, INTERFACE_EXPLICIT_GAME_PHONE, offsetof(CMidiPlayer, mMIDITime)},
303     {MPH_MIDITEMPO, INTERFACE_EXPLICIT_GAME_PHONE, offsetof(CMidiPlayer, mMIDITempo)},
304     {MPH_MIDIMUTESOLO, INTERFACE_EXPLICIT_GAME, offsetof(CMidiPlayer, mMIDIMuteSolo)},
305     {MPH_PREFETCHSTATUS, INTERFACE_EXPLICIT_GAME_PHONE, offsetof(CMidiPlayer, mPrefetchStatus)},
306     {MPH_SEEK, INTERFACE_EXPLICIT_GAME_PHONE, offsetof(CMidiPlayer, mSeek)},
307     {MPH_VOLUME, INTERFACE_EXPLICIT_GAME_PHONE, offsetof(CMidiPlayer, mVolume)},
308     {MPH_3DMACROSCOPIC, INTERFACE_OPTIONAL, offsetof(CMidiPlayer, m3DMacroscopic)},
309     {MPH_BASSBOOST, INTERFACE_DYNAMIC_OPTIONAL, offsetof(CMidiPlayer, mBassBoost)},
310     {MPH_DYNAMICSOURCE, INTERFACE_OPTIONAL, offsetof(CMidiPlayer, mDynamicSource)},
311     {MPH_ENVIRONMENTALREVERB, INTERFACE_DYNAMIC_OPTIONAL,
312         offsetof(CMidiPlayer, mEnvironmentalReverb)},
313     {MPH_EQUALIZER, INTERFACE_DYNAMIC_OPTIONAL, offsetof(CMidiPlayer, mEqualizer)},
314     {MPH_PITCH, INTERFACE_DYNAMIC_OPTIONAL, offsetof(CMidiPlayer, mPitch)},
315     {MPH_PRESETREVERB, INTERFACE_DYNAMIC_OPTIONAL, offsetof(CMidiPlayer, mPresetReverb)},
316     {MPH_PLAYBACKRATE, INTERFACE_DYNAMIC_OPTIONAL, offsetof(CMidiPlayer, mPlaybackRate)},
317     {MPH_VIRTUALIZER, INTERFACE_DYNAMIC_OPTIONAL, offsetof(CMidiPlayer, mVirtualizer)},
318     {MPH_VISUALIZATION, INTERFACE_OPTIONAL, offsetof(CMidiPlayer, mVisualization)},
319 };
320 
321 static const ClassTable CMidiPlayer_class = {
322     MidiPlayer_interfaces,
323     INTERFACES_MidiPlayer,
324     MPH_to_MidiPlayer,
325     "MidiPlayer",
326     sizeof(CMidiPlayer),
327     SL_OBJECTID_MIDIPLAYER,
328     0,      // OpenMAX AL object ID
329     NULL,
330     NULL,
331     NULL,
332     NULL
333 };
334 
335 #endif
336 
337 
338 // OutputMix class
339 
340 static const struct iid_vtable OutputMix_interfaces[INTERFACES_OutputMix] = {
341     {MPH_OBJECT, INTERFACE_IMPLICIT_PREREALIZE, offsetof(COutputMix, mObject)},
342     {MPH_DYNAMICINTERFACEMANAGEMENT, INTERFACE_IMPLICIT,
343         offsetof(COutputMix, mDynamicInterfaceManagement)},
344     {MPH_OUTPUTMIX, INTERFACE_IMPLICIT, offsetof(COutputMix, mOutputMix)},
345 #ifdef USE_OUTPUTMIXEXT
346     {MPH_OUTPUTMIXEXT, INTERFACE_UNAVAILABLE, offsetof(COutputMix, mOutputMixExt)},
347 #else
348     {MPH_OUTPUTMIXEXT, INTERFACE_UNAVAILABLE, 0},
349 #endif
350     {MPH_ENVIRONMENTALREVERB, INTERFACE_DYNAMIC,
351         offsetof(COutputMix, mEnvironmentalReverb)},
352     {MPH_EQUALIZER, INTERFACE_DYNAMIC, offsetof(COutputMix, mEqualizer)},
353     {MPH_PRESETREVERB, INTERFACE_DYNAMIC, offsetof(COutputMix, mPresetReverb)},
354     {MPH_VIRTUALIZER, INTERFACE_DYNAMIC, offsetof(COutputMix, mVirtualizer)},
355     // The overall Volume interface is explicit optional,
356     // but portions of Volume are mandated only in Game and Music profiles
357     {MPH_VOLUME, INTERFACE_OPTIONAL, offsetof(COutputMix, mVolume)},
358     {MPH_BASSBOOST, INTERFACE_DYNAMIC, offsetof(COutputMix, mBassBoost)},
359     {MPH_VISUALIZATION, INTERFACE_OPTIONAL, offsetof(COutputMix, mVisualization)},
360 #ifdef ANDROID
361     {MPH_ANDROIDEFFECT, INTERFACE_EXPLICIT, offsetof(COutputMix, mAndroidEffect)},
362 #endif
363 };
364 
365 static const ClassTable COutputMix_class = {
366     OutputMix_interfaces,
367     INTERFACES_OutputMix,
368     MPH_to_OutputMix,
369     "OutputMix",
370     sizeof(COutputMix),
371     SL_OBJECTID_OUTPUTMIX,
372     XA_OBJECTID_OUTPUTMIX,
373     COutputMix_Realize,
374     COutputMix_Resume,
375     COutputMix_Destroy,
376     COutputMix_PreDestroy
377 };
378 
379 
380 #if USE_PROFILES & USE_PROFILES_OPTIONAL
381 
382 // Vibra class
383 
384 static const struct iid_vtable VibraDevice_interfaces[INTERFACES_VibraDevice] = {
385     {MPH_OBJECT, INTERFACE_IMPLICIT_PREREALIZE, offsetof(CVibraDevice, mObject)},
386     {MPH_DYNAMICINTERFACEMANAGEMENT, INTERFACE_IMPLICIT,
387         offsetof(CVibraDevice, mDynamicInterfaceManagement)},
388     {MPH_VIBRA, INTERFACE_IMPLICIT, offsetof(CVibraDevice, mVibra)},
389 };
390 
391 static const ClassTable CVibraDevice_class = {
392     VibraDevice_interfaces,
393     INTERFACES_VibraDevice,
394     MPH_to_Vibra,
395     "VibraDevice",
396     sizeof(CVibraDevice),
397     SL_OBJECTID_VIBRADEVICE,
398     XA_OBJECTID_VIBRADEVICE,
399     NULL,
400     NULL,
401     NULL,
402     NULL
403 };
404 
405 #endif
406 
407 
408 // Media player class
409 
410 static const struct iid_vtable MediaPlayer_interfaces[INTERFACES_MediaPlayer] = {
411     {MPH_XAOBJECT, INTERFACE_IMPLICIT_PREREALIZE, offsetof(CMediaPlayer, mObject)},
412     {MPH_XADYNAMICINTERFACEMANAGEMENT, INTERFACE_IMPLICIT,
413         offsetof(CMediaPlayer, mDynamicInterfaceManagement)},
414     {MPH_XAPLAY, INTERFACE_IMPLICIT, offsetof(CMediaPlayer, mPlay)},
415     {MPH_XASTREAMINFORMATION, INTERFACE_EXPLICIT, offsetof(CMediaPlayer, mStreamInfo)},
416     {MPH_XAVOLUME, INTERFACE_IMPLICIT, offsetof(CMediaPlayer, mVolume)},
417     {MPH_XASEEK, INTERFACE_EXPLICIT, offsetof(CMediaPlayer, mSeek)},
418     {MPH_XAPREFETCHSTATUS, INTERFACE_EXPLICIT, offsetof(CMediaPlayer, mPrefetchStatus)},
419 #ifdef ANDROID
420     {MPH_ANDROIDBUFFERQUEUESOURCE, INTERFACE_EXPLICIT, offsetof(CMediaPlayer, mAndroidBufferQueue)},
421 #endif
422 };
423 
424 static const ClassTable CMediaPlayer_class = {
425     MediaPlayer_interfaces,
426     INTERFACES_MediaPlayer,
427     MPH_to_MediaPlayer,
428     "MediaPlayer",
429     sizeof(CMediaPlayer),
430     0,      // OpenSL ES object ID
431     XA_OBJECTID_MEDIAPLAYER,
432     CMediaPlayer_Realize,
433     CMediaPlayer_Resume,
434     CMediaPlayer_Destroy,
435     CMediaPlayer_PreDestroy
436 };
437 
438 
439 static const ClassTable * const slClasses[] = {
440     // Do not change order of these entries; they are in numerical order
441     &CEngine_class,
442 #if USE_PROFILES & USE_PROFILES_OPTIONAL
443     &CLEDDevice_class,
444     &CVibraDevice_class,
445 #else
446     NULL,
447     NULL,
448 #endif
449     &CAudioPlayer_class,
450 #if (USE_PROFILES & USE_PROFILES_OPTIONAL) || defined(ANDROID)
451     &CAudioRecorder_class,
452 #else
453     NULL,
454 #endif
455 #if USE_PROFILES & (USE_PROFILES_GAME | USE_PROFILES_PHONE)
456     &CMidiPlayer_class,
457 #else
458     NULL,
459 #endif
460 #if USE_PROFILES & USE_PROFILES_GAME
461     &CListener_class,
462     &C3DGroup_class,
463 #else
464     NULL,
465     NULL,
466 #endif
467     &COutputMix_class,
468 #if USE_PROFILES & (USE_PROFILES_GAME | USE_PROFILES_MUSIC)
469     &CMetadataExtractor_class
470 #else
471     NULL
472 #endif
473 };
474 
475 
476 static const ClassTable * const xaClasses[] = {
477     &CEngine_class,
478 #if USE_PROFILES & USE_PROFILES_OPTIONAL
479     &CLEDDevice_class,
480     &CVibraDevice_class,
481 #else
482     NULL,
483     NULL,
484 #endif
485     &CMediaPlayer_class,
486 #if 1
487     NULL,
488     NULL,
489 #else
490     &CMediaRecorder_class,
491     &CRadioDevice_class,
492 #endif
493     &COutputMix_class,
494 #if USE_PROFILES & (USE_PROFILES_GAME | USE_PROFILES_MUSIC)
495     &CMetadataExtractor_class,
496 #else
497     NULL,
498 #endif
499 #if 1
500     NULL
501 #else
502     &CCameraDevice_class
503 #endif
504 };
505 
506 
507 /* \brief Map SL_OBJECTID to class or NULL if object ID not supported */
508 
objectIDtoClass(SLuint32 objectID)509 LI_API const ClassTable *objectIDtoClass(SLuint32 objectID)
510 {
511     // object ID is the engine and always present
512     assert(NULL != slClasses[0]);
513     SLuint32 slObjectID0 = slClasses[0]->mSLObjectID;
514     if ((slObjectID0 <= objectID) && ((slObjectID0 + sizeof(slClasses)/sizeof(slClasses[0])) >
515             objectID)) {
516         return slClasses[objectID - slObjectID0];
517     }
518     assert(NULL != xaClasses[0]);
519     SLuint32 xaObjectID0 = xaClasses[0]->mXAObjectID;
520     if ((xaObjectID0 <= objectID) && ((xaObjectID0 + sizeof(xaClasses)/sizeof(xaClasses[0])) >
521             objectID)) {
522         return xaClasses[objectID - xaObjectID0];
523     }
524     return NULL;
525 }
526