1 /*
2  * Copyright (C) 2015 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 <media/AudioPolicy.h>
18 
19 #include "TypeConverter.h"
20 
21 namespace android {
22 
23 #define MAKE_STRING_FROM_ENUM(string) { #string, string }
24 #define TERMINATOR { .literal = nullptr }
25 
26 template <>
27 const DeviceCategoryConverter::Table DeviceCategoryConverter::mTable[] = {
28     MAKE_STRING_FROM_ENUM(DEVICE_CATEGORY_HEADSET),
29     MAKE_STRING_FROM_ENUM(DEVICE_CATEGORY_SPEAKER),
30     MAKE_STRING_FROM_ENUM(DEVICE_CATEGORY_EARPIECE),
31     MAKE_STRING_FROM_ENUM(DEVICE_CATEGORY_EXT_MEDIA),
32     MAKE_STRING_FROM_ENUM(DEVICE_CATEGORY_HEARING_AID),
33     TERMINATOR
34 };
35 
36 template <>
37 const MixTypeConverter::Table MixTypeConverter::mTable[] = {
38     MAKE_STRING_FROM_ENUM(MIX_TYPE_INVALID),
39     MAKE_STRING_FROM_ENUM(MIX_TYPE_PLAYERS),
40     MAKE_STRING_FROM_ENUM(MIX_TYPE_RECORDERS),
41     TERMINATOR
42 };
43 
44 template <>
45 const RouteFlagTypeConverter::Table RouteFlagTypeConverter::mTable[] = {
46     MAKE_STRING_FROM_ENUM(MIX_ROUTE_FLAG_RENDER),
47     MAKE_STRING_FROM_ENUM(MIX_ROUTE_FLAG_LOOP_BACK),
48     MAKE_STRING_FROM_ENUM(MIX_ROUTE_FLAG_ALL),
49     TERMINATOR
50 };
51 
52 template <>
53 const RuleTypeConverter::Table RuleTypeConverter::mTable[] = {
54     MAKE_STRING_FROM_ENUM(RULE_EXCLUSION_MASK),
55     MAKE_STRING_FROM_ENUM(RULE_MATCH_ATTRIBUTE_USAGE),
56     MAKE_STRING_FROM_ENUM(RULE_MATCH_ATTRIBUTE_CAPTURE_PRESET),
57     MAKE_STRING_FROM_ENUM(RULE_MATCH_UID),
58     MAKE_STRING_FROM_ENUM(RULE_EXCLUDE_ATTRIBUTE_USAGE),
59     MAKE_STRING_FROM_ENUM(RULE_EXCLUDE_ATTRIBUTE_CAPTURE_PRESET),
60     MAKE_STRING_FROM_ENUM(RULE_EXCLUDE_UID),
61     TERMINATOR
62 };
63 
64 template class TypeConverter<DeviceCategoryTraits>;
65 template class TypeConverter<MixTypeTraits>;
66 template class TypeConverter<RouteFlagTraits>;
67 template class TypeConverter<RuleTraits>;
68 
69 } // namespace android
70