1 /*
2 * Copyright (C) 2017 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 <getopt.h>
18
19 #include <media/EffectsFactoryApi.h>
20 #include "EffectsXmlConfigLoader.h"
21 #include "EffectsConfigLoader.h"
22
main(int argc,char * argv[])23 int main(int argc, char* argv[]) {
24 const char* const short_opts = "lx:h";
25 const option long_opts[] = {{"legacy", no_argument, nullptr, 'l'},
26 {"xml", optional_argument, nullptr, 'x'},
27 {"help", no_argument, nullptr, 'h'}};
28
29 const auto opt = getopt_long(argc, argv, short_opts, long_opts, nullptr);
30 switch (opt) {
31 case 'l': { // -l or --legacy
32 printf("Dumping legacy effect config file\n");
33 if (EffectLoadEffectConfig() < 0) {
34 fprintf(stderr, "loadEffectConfig failed, see logcat for detail.\n");
35 return 1;
36 }
37 return EffectDumpEffects(STDOUT_FILENO);
38 }
39 case 'x': { // -x or --xml
40 printf("Dumping effect config file: %s\n", (optarg == NULL) ? "default" : optarg);
41 ssize_t ret = EffectLoadXmlEffectConfig(optarg);
42 if (ret < 0) {
43 fprintf(stderr, "loadXmlEffectConfig failed, see logcat for detail.\n");
44 return 1;
45 }
46 if (ret > 0) {
47 printf("Partially failed to load config. Skipped %zu elements.\n",
48 (size_t)ret);
49 }
50 return EffectDumpEffects(STDOUT_FILENO);
51 }
52 case 'h': // -h or --help
53 default: {
54 printf("Usage: %s\n"
55 "--legacy (or -l): Legacy audio effect config file to load\n"
56 "--xml (or -x) <FILE>: Audio effect config file to load\n"
57 "--help (or -h): Show this help\n",
58 argv[0]);
59 return 0;
60 }
61 }
62 }
63