IID_to_MPH.c revision 37dc2fccf3f122b79ebd554de209d0a3c94ae161
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// This file is automagically generated by hashgen, do not edit
18
19/** \file IID_to_MPH.c Interface ID to MPH mapping */
20
21#include "SLES/OpenSLES.h"
22#include "MPH.h"
23#include <assert.h>
24#include <string.h>
25
26extern const struct SLInterfaceID_ SL_IID_array[MPH_MAX];
27
28/** \brief Map SLInterfaceID to its minimal perfect hash (MPH), or -1 if unknown */
29
30int IID_to_MPH(const SLInterfaceID iid)
31{
32#define MAX_HASH_VALUE 139
33  static const unsigned char asso_values[] =
34    {
35        5, 140, 140,   7, 140, 140,  27, 140,  17,  17,
36      140,  22, 140, 140, 140,  51, 140, 140, 140, 140,
37      140, 140,   2, 140, 140,  46, 140, 140, 140, 140,
38      140,  17,  20, 140, 140, 140, 140, 140, 140, 140,
39      140, 140,  51,  20,  46, 140,  31, 140, 140, 140,
40      140, 140, 140,  36, 140,   2, 140, 140,   2, 140,
41      140,  61, 140,   2,  55, 140, 140, 140, 140,  16,
42      140,  26, 140, 140, 140, 140, 140, 140, 140, 140,
43       21, 140, 140, 140, 140, 140,  26, 140, 140, 140,
44       11, 140, 140, 140, 140, 140,  40,  21, 140,  60,
45      140, 140, 140, 140, 140, 140,  16, 140, 140, 140,
46      140, 140,   1, 140, 140, 140, 140, 140, 140, 140,
47      140,  11,  55,   6, 140, 140, 140,   6,  45, 140,
48      140,   1, 140, 140, 140, 140, 140,   1, 140, 140,
49      140,   1, 140, 140, 140, 140, 140, 140, 140, 140,
50      140,  60, 140, 140, 140, 140, 140, 140, 140, 140,
51       10, 140, 140, 140, 140, 140, 140, 140, 140, 140,
52       50, 140, 140, 140,  45, 140, 140, 140,  60, 140,
53       45, 140, 140, 140, 140,  55, 140, 140, 140, 140,
54      140, 140,  15, 140,  35, 140,  45,   5, 140,  50,
55      140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
56      140, 140,  40, 140, 140,  50, 140, 140, 140, 140,
57      140,  25, 140, 140,  15,  40, 140, 140,  10, 140,
58      140, 140, 140, 140, 140,  10,   0, 140, 140,  15,
59       30, 140, 140, 140, 140, 140,  55, 140, 140, 140,
60      140, 140, 140, 140,   0, 140
61    };
62    static const signed char hash_to_MPH[] = {
63        -1,
64        -1,
65        -1,
66        -1,
67        -1,
68        -1,
69        -1,
70        -1,
71        -1,
72        -1,
73        -1,
74        -1,
75        -1,
76        -1,
77        -1,
78        -1,
79        -1,
80        -1,
81        -1,
82        -1,
83        -1,
84        -1,
85        -1,
86        -1,
87        MPH_NULL,
88        -1,
89        -1,
90        -1,
91        -1,
92        MPH_OUTPUTMIXEXT,
93        MPH_3DSOURCE,
94        MPH_VIRTUALIZER,
95        -1,
96        -1,
97        MPH_DYNAMICSOURCE,
98        MPH_ENGINECAPABILITIES,
99        MPH_AUDIODECODERCAPABILITIES,
100        -1,
101        -1,
102        MPH_RECORD,
103        MPH_ANDROIDCONFIGURATION,
104        MPH_XASTREAMINFORMATION,
105        -1,
106        -1,
107        MPH_VISUALIZATION,
108        MPH_ANDROIDEFFECTSEND,
109        MPH_MIDITEMPO,
110        -1,
111        -1,
112        MPH_3DGROUPING,
113        MPH_MUTESOLO,
114        MPH_EQUALIZER,
115        -1,
116        -1,
117        MPH_PLAY,
118        MPH_EFFECTSEND,
119        MPH_VOLUME,
120        -1,
121        -1,
122        MPH_BUFFERQUEUE,
123        MPH_3DMACROSCOPIC,
124        MPH_XAVOLUME,
125        -1,
126        -1,
127        MPH_3DLOCATION,
128        MPH_ENGINE,
129        MPH_VIBRA,
130        -1,
131        -1,
132        MPH_MIDIMESSAGE,
133        MPH_ANDROIDBUFFERQUEUE,
134        MPH_BASSBOOST,
135        -1,
136        -1,
137        MPH_SEEK,
138        MPH_OBJECT,
139        MPH_MIDIMUTESOLO,
140        -1,
141        -1,
142        MPH_PITCH,
143        MPH_ANDROIDEFFECTCAPABILITIES,
144        -1,
145        -1,
146        -1,
147        MPH_METADATATRAVERSAL,
148        MPH_RATEPITCH,
149        -1,
150        -1,
151        -1,
152        MPH_ENVIRONMENTALREVERB,
153        MPH_PRESETREVERB,
154        -1,
155        -1,
156        -1,
157        MPH_XAPLAY,
158        MPH_XAENGINE,
159        -1,
160        -1,
161        -1,
162        MPH_AUDIOIODEVICECAPABILITIES,
163        MPH_MIDITIME,
164        -1,
165        -1,
166        -1,
167        MPH_DEVICEVOLUME,
168        MPH_3DCOMMIT,
169        -1,
170        -1,
171        -1,
172        MPH_ANDROIDEFFECT,
173        MPH_PLAYBACKRATE,
174        -1,
175        -1,
176        -1,
177        MPH_3DDOPPLER,
178        MPH_LED,
179        -1,
180        -1,
181        -1,
182        MPH_METADATAEXTRACTION,
183        MPH_PREFETCHSTATUS,
184        -1,
185        -1,
186        -1,
187        MPH_OUTPUTMIX,
188        MPH_ANDROIDSIMPLEBUFFERQUEUE,
189        -1,
190        -1,
191        -1,
192        MPH_AUDIOENCODER,
193        MPH_AUDIOENCODERCAPABILITIES,
194        -1,
195        -1,
196        -1,
197        MPH_THREADSYNC,
198        -1,
199        -1,
200        -1,
201        -1,
202        MPH_DYNAMICINTERFACEMANAGEMENT
203    };
204    if (&SL_IID_array[0] <= iid && &SL_IID_array[MPH_MAX] > iid)
205        return iid - &SL_IID_array[0];
206    if (NULL != iid) {
207        static const unsigned len = sizeof(struct SLInterfaceID_);
208        unsigned key = len +
209            asso_values[((unsigned char *)iid)[3]] + asso_values[((unsigned char *)iid)[0]];
210        if (key <= MAX_HASH_VALUE) {
211            int MPH = hash_to_MPH[key];
212            if (MPH >= 0) {
213                assert(MPH < MPH_MAX);
214                SLInterfaceID trial = &SL_IID_array[MPH];
215                if (!memcmp(iid, trial, sizeof(struct SLInterfaceID_)))
216                    return MPH;
217            }
218        }
219    }
220    return -1;
221}
222