1 /*
2  * Copyright (C) 2011 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 #include <SLES/OpenSLES.h>
18 #include <OMXAL/OpenMAXAL.h>
19 #include "attr.h"
20 #include "handlers.h"
21 
22 #define NULL 0
23 
24 /* The entries in this table are sorted first by object ID, and second
25  * by attribute mask. The holes in the table are deliberate to permit
26  * direct lookup. Don't cross streams!
27  */
28 const AttributeHandler handlerTable[1 + XA_OBJECTID_CAMERADEVICE +
29         (SL_OBJECTID_METADATAEXTRACTOR - SL_OBJECTID_ENGINE) + 1][ATTR_INDEX_MAX] = {
30 
31 // XA IDs map directly to table indices
32 
33     [XA_OBJECTID_MEDIAPLAYER] = {
34         [ATTR_INDEX_GAIN]        = handler_MediaPlayer_gain,
35         [ATTR_INDEX_TRANSPORT]   = handler_MediaPlayer_transport,
36         [ATTR_INDEX_POSITION]    = handler_MediaPlayer_position,
37         [ATTR_INDEX_ABQ_ENQUEUE] = handler_MediaPlayer_abq_enqueue,
38         [ATTR_INDEX_PLAY_STATE]  = handler_MediaPlayer_play_state},
39 
40 // SL IDs need a little arithmetic to make them contiguous with XA IDs
41 #define _(id) ((id) - SL_OBJECTID_ENGINE + XA_OBJECTID_CAMERADEVICE + 1)
42 
43     [_(SL_OBJECTID_AUDIOPLAYER)] = {
44 #ifdef ANDROID
45         [ATTR_INDEX_GAIN]        = handler_AudioPlayer_gain,
46 #endif
47         [ATTR_INDEX_TRANSPORT]   = handler_AudioPlayer_transport,
48         [ATTR_INDEX_POSITION]    = handler_AudioPlayer_position,
49         [ATTR_INDEX_BQ_ENQUEUE]  = handler_AudioPlayer_bq_enqueue,
50         [ATTR_INDEX_ABQ_ENQUEUE] = handler_AudioPlayer_abq_enqueue,
51         [ATTR_INDEX_PLAY_STATE]  = handler_AudioPlayer_play_state},
52 
53     [_(SL_OBJECTID_AUDIORECORDER)] = {
54         [ATTR_INDEX_TRANSPORT]   = handler_AudioRecorder_transport},
55 
56     [_(SL_OBJECTID_MIDIPLAYER)] = {
57         [ATTR_INDEX_GAIN]        = handler_MidiPlayer_gain,
58         [ATTR_INDEX_POSITION]    = handler_MidiPlayer_position},
59 
60     [_(SL_OBJECTID_OUTPUTMIX)] = {
61         [ATTR_INDEX_GAIN]        = handler_OutputMix_gain},
62 
63 };
64