4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jonghyuk Choi <jhchoi.choi@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
27 #include "include/avsys-error.h"
28 #include "include/avsys-debug.h"
30 #include "include/avsys-audio-handle.h"
31 #include "include/avsys-audio-path.h"
32 #include "include/avsys-audio-logical-volume.h"
45 static int usage(int argc, char *argv[]);
46 static int get_options(int argc, char *argv[]);
48 int main(int argc, char *argv[])
50 int operation = OP_NONE;
56 static char *str_errormsg[] = {
57 "Operation is success.",
67 "Handle Rejuvenation Fail",
68 "Vconf Get Value Fail",
72 operation = get_options(argc, argv);
77 fprintf(stderr, "old umask was [%o]\n", old_umask);
78 result = avsys_audio_handle_init();
79 if (AVSYS_FAIL(result)) {
82 fprintf(stderr, "set umask to old value\n");
85 result = avsys_audio_path_ex_init();
86 if (AVSYS_FAIL(result)) {
89 fprintf(stderr, "set umask to old value\n");
92 result = avsys_audio_logical_volume_init();
93 if (AVSYS_FAIL(result)) {
96 fprintf(stderr, "set umask to old value\n");
100 fprintf(stderr, "set umask to old value\n");
104 result = avsys_audio_handle_fini();
105 if (AVSYS_FAIL(result)) {
110 result = avsys_audio_path_ex_fini();
111 if (AVSYS_FAIL(result)) {
117 result = avsys_audio_handle_reset(NULL);
118 if (AVSYS_FAIL(result)) {
123 result = avsys_audio_path_ex_reset(0);
124 if (AVSYS_FAIL(result)) {
130 result = avsys_audio_handle_dump();
131 if (AVSYS_FAIL(result)) {
135 result = avsys_audio_path_ex_dump();
136 if (AVSYS_FAIL(result)) {
141 result = avsys_audio_dump_sync();
142 if (AVSYS_FAIL(result)) {
153 result = avsys_audio_path_ex_set_mute(mute);
154 if (AVSYS_FAIL(result)) {
159 result = avsys_audio_handle_rejuvenation();
160 if (AVSYS_FAIL(result)) {
165 fprintf(stderr, "Unknown operation\n");
170 fprintf(stderr, "%s\n", str_errormsg[result]);
176 static int get_options(int argc, char *argv[])
179 int operation = OP_NONE;
182 return usage(argc, argv);
184 while ((ch = getopt(argc, argv, "iurtdmjhap")) != EOF) {
187 if (operation != OP_NONE)
188 return usage(argc, argv);
192 if (operation != OP_NONE)
193 return usage(argc, argv);
194 operation = OP_UNINIT;
197 if (operation != OP_NONE)
198 return usage(argc, argv);
199 operation = OP_RESET;
202 if (operation != OP_NONE)
203 return usage(argc, argv);
207 if (operation != OP_NONE)
208 return usage(argc, argv);
209 operation = OP_DAEMON;
212 if (operation != OP_NONE)
213 return usage(argc, argv);
214 operation = OP_SHUTDOWN;
217 if (operation != OP_NONE)
218 return usage(argc, argv);
219 operation = OP_REJUVE;
222 return usage(argc, argv);
225 return usage(argc, argv);
230 static int usage(int argc, char *argv[])
232 fprintf(stderr, "Usage : %s option\n", argv[0]);
233 fprintf(stderr, "[OPTIONS]\n");
234 fprintf(stderr, " -i : Initialize audio system\n");
235 fprintf(stderr, " -u : Uninitialize audio system\n");
236 fprintf(stderr, " -r : Reset audio system\n");
237 fprintf(stderr, " -d : Dump audio system\n");
238 fprintf(stderr, " -m : Global mute\n");
239 fprintf(stderr, " -j : Handle rejuvenation\n");