2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 #include <sound_manager.h>
22 #include <sound_manager_private.h>
23 #include <sound_manager_internal.h>
28 #define MAX_STRING_LEN 2048
29 #define NOT_AVAIL "N/A";
32 CURRENT_STATUS_MAINMENU,
33 CURRENT_STATUS_GET_MAX_VOLUME,
34 CURRENT_STATUS_SET_VOLUME,
35 CURRENT_STATUS_GET_VOLUME,
36 CURRENT_STATUS_SET_CURRENT_SOUND_TYPE,
37 CURRENT_STATUS_GET_CURRENT_SOUND_TYPE,
38 CURRENT_STATUS_UNSET_CURRENT_SOUND_TYPE,
39 CURRENT_STATUS_SET_VOLUME_CHANGED_CB,
40 CURRENT_STATUS_UNSET_VOLUME_CHANGED_CB,
41 CURRENT_STATUS_SET_SESSION_TYPE,
42 CURRENT_STATUS_GET_SESSION_TYPE,
43 CURRENT_STATUS_SET_MEDIA_SESSION_OPTION,
44 CURRENT_STATUS_GET_MEDIA_SESSION_OPTION,
45 CURRENT_STATUS_SET_MEDIA_SESSION_RESUMPTION_OPTION,
46 CURRENT_STATUS_GET_MEDIA_SESSION_RESUMPTION_OPTION,
47 CURRENT_STATUS_SET_VOIP_SESSION_MODE,
48 CURRENT_STATUS_GET_VOIP_SESSION_MODE,
49 CURRENT_STATUS_SET_CALL_SESSION_MODE,
50 CURRENT_STATUS_GET_CALL_SESSION_MODE,
51 CURRENT_STATUS_SET_SESSION_INTERRUPTED_CB,
52 CURRENT_STATUS_UNSET_SESSION_INTERRUPTED_CB,
53 CURRENT_STATUS_SET_DEVICE_MASK,
54 CURRENT_STATUS_GET_DEVICE_MASK,
55 CURRENT_STATUS_GET_CURRENT_DEVICE_LIST,
56 CURRENT_STATUS_PRINT_DEVICE_LIST,
57 CURRENT_STATUS_GET_DEVICE_LIST,
58 CURRENT_STATUS_FREE_DEVICE_LIST,
59 CURRENT_STATUS_GET_DEVICE_NEXT,
60 CURRENT_STATUS_GET_DEVICE_PREV,
61 CURRENT_STATUS_SET_DEVICE_CONNECTED_CB,
62 CURRENT_STATUS_UNSET_DEVICE_CONNECTED_CB,
63 CURRENT_STATUS_ADD_DEVICE_CONNECTION_CHANGED_CB,
64 CURRENT_STATUS_REMOVE_DEVICE_CONNECTION_CHANGED_CB,
65 CURRENT_STATUS_SET_DEVICE_INFO_CHANGED_CB,
66 CURRENT_STATUS_UNSET_DEVICE_INFO_CHANGED_CB,
67 CURRENT_STATUS_ADD_DEVICE_STATE_CHANGED_CB,
68 CURRENT_STATUS_REMOVE_DEVICE_STATE_CHANGED_CB,
69 CURRENT_STATUS_CREATE_STREAM_INFO,
70 CURRENT_STATUS_ADD_DEVICE_FOR_STREAM_ROUTING,
71 CURRENT_STATUS_REMOVE_DEVICE_FOR_STREAM_ROUTING,
72 CURRENT_STATUS_REMOVE_ALL_DEVICES_FOR_STREAM_ROUTING,
73 CURRENT_STATUS_ADD_DEVICE_ID_FOR_STREAM_ROUTING,
74 CURRENT_STATUS_REMOVE_DEVICE_ID_FOR_STREAM_ROUTING,
75 CURRENT_STATUS_APPLY_STREAM_ROUTING,
76 CURRENT_STATUS_SET_STREAM_ROUTING_OPTION,
77 CURRENT_STATUS_ACQUIRE_FOCUS,
78 CURRENT_STATUS_RELEASE_FOCUS,
79 CURRENT_STATUS_ACQUIRE_FOCUS_ALL,
80 CURRENT_STATUS_RELEASE_FOCUS_ALL,
81 CURRENT_STATUS_GET_ACQUIRED_FOCUS,
82 CURRENT_STATUS_GET_SOUND_TYPE,
83 CURRENT_STATUS_DELIVER_FOCUS,
84 CURRENT_STATUS_DESTROY_STREAM_INFO,
85 CURRENT_STATUS_ADD_FOCUS_WATCH_CB,
86 CURRENT_STATUS_REMOVE_FOCUS_WATCH_CB,
87 CURRENT_STATUS_SET_FOCUS_REACQUISITION,
88 CURRENT_STATUS_GET_FOCUS_REACQUISITION,
89 CURRENT_STATUS_GET_REASON_FOR_P_FOCUS,
90 CURRENT_STATUS_GET_REASON_FOR_R_FOCUS,
91 CURRENT_STATUS_GET_CURRENT_MEDIA_PLAYBACK_DEVICE_TYPE,
92 CURRENT_STATUS_CREATE_VIRTUAL_STREAM,
93 CURRENT_STATUS_START_VIRTUAL_STREAM,
94 CURRENT_STATUS_STOP_VIRTUAL_STREAM,
95 CURRENT_STATUS_DESTROY_VIRTUAL_STREAM,
96 CURRENT_STATUS_SET_FILTER,
97 CURRENT_STATUS_SET_FILTER_PRESET,
98 CURRENT_STATUS_UNSET_FILTER,
99 #ifndef TIZEN_FEATURE_TV_PROD
100 CURRENT_STATUS_GET_MAX_MASTER_VOLUME,
101 CURRENT_STATUS_SET_MASTER_VOLUME,
102 CURRENT_STATUS_GET_MASTER_VOLUME,
107 static int g_menu_state = CURRENT_STATUS_MAINMENU;
110 sound_device_list_h g_device_list = NULL;
111 sound_device_mask_e g_device_mask = SOUND_DEVICE_ALL_MASK;
112 sound_stream_info_h g_stream_info_h = NULL;
113 virtual_sound_stream_h g_vstream_h = NULL;
114 int g_device_conn_cb_id;
115 int g_device_state_cb_id;
117 static const char *g_device_direction_str[] = {"IN", "OUT", "BOTH"};
118 static const char *g_device_state_str[] = {"De-Activated", "Activated"};
120 void focus_callback(sound_stream_info_h stream_info,
121 sound_stream_focus_mask_e focus_mask,
122 sound_stream_focus_state_e focus_state,
123 sound_stream_focus_change_reason_e reason,
125 const char *extra_info,
128 int ret = SOUND_MANAGER_ERROR_NONE;
129 sound_stream_focus_state_e playback_focus_state;
130 sound_stream_focus_state_e recording_focus_state;
132 g_print("\n*** FOCUS callback is called, stream_info(%p) ***\n", stream_info);
134 g_print(" - changed focus: mask(%x), state(%d) (0:released, 1:acquired)\n", focus_mask, focus_state);
135 g_print(" - change_reason(%d), behavior(0x%x), extra_info(%s), user_data(%p)\n", reason, sound_behavior, extra_info, user_data);
137 ret = sound_manager_get_focus_state(stream_info, &playback_focus_state, &recording_focus_state);
139 g_print(" - focus_state : PLAYBACK(%d), RECORDING(%d) (0:released, 1:acquired)\n", playback_focus_state, recording_focus_state);
141 g_print("*** FOCUS callback is ended, stream_info(%p) ****\n\n", stream_info);
146 void focus_watch_callback(int id, sound_stream_focus_mask_e focus_mask, sound_stream_focus_state_e focus_state, sound_stream_focus_change_reason_e reason, const char *extra_info, void *user_data)
148 g_print("\n*** FOCUS WATCH callback is called, id(%d) ***\n", id);
149 g_print(" - changed_focus_mask(%d), changed_focus_state(%d), change_reason(%d), extra_info(%s), user_data(%p)\n",
150 focus_mask, focus_state, reason, extra_info, user_data);
156 g_main_loop_quit(g_loop);
159 void _interpret_main_menu(char *cmd)
161 if (strncmp(cmd, "gx", 3) == 0)
162 g_menu_state = CURRENT_STATUS_GET_MAX_VOLUME;
163 else if (strncmp(cmd, "sv", 3) == 0)
164 g_menu_state = CURRENT_STATUS_SET_VOLUME;
165 else if (strncmp(cmd, "gv", 3) == 0)
166 g_menu_state = CURRENT_STATUS_GET_VOLUME;
167 else if (strncmp(cmd, "st", 3) == 0)
168 g_menu_state = CURRENT_STATUS_SET_CURRENT_SOUND_TYPE;
169 else if (strncmp(cmd, "gt", 3) == 0)
170 g_menu_state = CURRENT_STATUS_GET_CURRENT_SOUND_TYPE;
171 else if (strncmp(cmd, "ut", 3) == 0)
172 g_menu_state = CURRENT_STATUS_UNSET_CURRENT_SOUND_TYPE;
173 else if (strncmp(cmd, "vc", 3) == 0)
174 g_menu_state = CURRENT_STATUS_SET_VOLUME_CHANGED_CB;
175 else if (strncmp(cmd, "uv", 3) == 0)
176 g_menu_state = CURRENT_STATUS_UNSET_VOLUME_CHANGED_CB;
177 else if (strncmp(cmd, "ss", 3) == 0)
178 g_menu_state = CURRENT_STATUS_SET_SESSION_TYPE;
179 else if (strncmp(cmd, "gs", 3) == 0)
180 g_menu_state = CURRENT_STATUS_GET_SESSION_TYPE;
181 else if (strncmp(cmd, "sm", 3) == 0)
182 g_menu_state = CURRENT_STATUS_SET_MEDIA_SESSION_OPTION;
183 else if (strncmp(cmd, "gm", 3) == 0)
184 g_menu_state = CURRENT_STATUS_GET_MEDIA_SESSION_OPTION;
185 else if (strncmp(cmd, "sr", 3) == 0)
186 g_menu_state = CURRENT_STATUS_SET_MEDIA_SESSION_RESUMPTION_OPTION;
187 else if (strncmp(cmd, "gr", 3) == 0)
188 g_menu_state = CURRENT_STATUS_GET_MEDIA_SESSION_RESUMPTION_OPTION;
189 else if (strncmp(cmd, "so", 3) == 0)
190 g_menu_state = CURRENT_STATUS_SET_VOIP_SESSION_MODE;
191 else if (strncmp(cmd, "go", 3) == 0)
192 g_menu_state = CURRENT_STATUS_GET_VOIP_SESSION_MODE;
193 else if (strncmp(cmd, "sl", 3) == 0)
194 g_menu_state = CURRENT_STATUS_SET_CALL_SESSION_MODE;
195 else if (strncmp(cmd, "gc", 3) == 0)
196 g_menu_state = CURRENT_STATUS_GET_CALL_SESSION_MODE;
197 else if (strncmp(cmd, "sc", 3) == 0)
198 g_menu_state = CURRENT_STATUS_SET_SESSION_INTERRUPTED_CB;
199 else if (strncmp(cmd, "us", 3) == 0)
200 g_menu_state = CURRENT_STATUS_UNSET_SESSION_INTERRUPTED_CB;
201 else if (strncmp(cmd, "sk", 3) == 0)
202 g_menu_state = CURRENT_STATUS_SET_DEVICE_MASK;
203 else if (strncmp(cmd, "gk", 3) == 0)
204 g_menu_state = CURRENT_STATUS_GET_DEVICE_MASK;
205 else if (strncmp(cmd, "gcl", 3) == 0)
206 g_menu_state = CURRENT_STATUS_GET_CURRENT_DEVICE_LIST;
207 else if (strncmp(cmd, "gl", 3) == 0)
208 g_menu_state = CURRENT_STATUS_GET_DEVICE_LIST;
209 else if (strncmp(cmd, "pl", 3) == 0)
210 g_menu_state = CURRENT_STATUS_PRINT_DEVICE_LIST;
211 else if (strncmp(cmd, "fl", 3) == 0)
212 g_menu_state = CURRENT_STATUS_FREE_DEVICE_LIST;
213 else if (strncmp(cmd, "gn", 3) == 0)
214 g_menu_state = CURRENT_STATUS_GET_DEVICE_NEXT;
215 else if (strncmp(cmd, "gp", 3) == 0)
216 g_menu_state = CURRENT_STATUS_GET_DEVICE_PREV;
217 else if (strncmp(cmd, "sd", 3) == 0)
218 g_menu_state = CURRENT_STATUS_SET_DEVICE_CONNECTED_CB;
219 else if (strncmp(cmd, "ud", 3) == 0)
220 g_menu_state = CURRENT_STATUS_UNSET_DEVICE_CONNECTED_CB;
221 else if (strncmp(cmd, "adcc", 4) == 0)
222 g_menu_state = CURRENT_STATUS_ADD_DEVICE_CONNECTION_CHANGED_CB;
223 else if (strncmp(cmd, "rdcc", 4) == 0)
224 g_menu_state = CURRENT_STATUS_REMOVE_DEVICE_CONNECTION_CHANGED_CB;
225 else if (strncmp(cmd, "si", 3) == 0)
226 g_menu_state = CURRENT_STATUS_SET_DEVICE_INFO_CHANGED_CB;
227 else if (strncmp(cmd, "ui", 3) == 0)
228 g_menu_state = CURRENT_STATUS_UNSET_DEVICE_INFO_CHANGED_CB;
229 else if (strncmp(cmd, "adsc", 4) == 0)
230 g_menu_state = CURRENT_STATUS_ADD_DEVICE_STATE_CHANGED_CB;
231 else if (strncmp(cmd, "rdsc", 4) == 0)
232 g_menu_state = CURRENT_STATUS_REMOVE_DEVICE_STATE_CHANGED_CB;
233 else if (strncmp(cmd, "csi", 3) == 0)
234 g_menu_state = CURRENT_STATUS_CREATE_STREAM_INFO;
235 else if (strncmp(cmd, "ads", 3) == 0)
236 g_menu_state = CURRENT_STATUS_ADD_DEVICE_FOR_STREAM_ROUTING;
237 else if (strncmp(cmd, "rds", 3) == 0)
238 g_menu_state = CURRENT_STATUS_REMOVE_DEVICE_FOR_STREAM_ROUTING;
239 else if (strncmp(cmd, "rad", 3) == 0)
240 g_menu_state = CURRENT_STATUS_REMOVE_ALL_DEVICES_FOR_STREAM_ROUTING;
241 else if (strncmp(cmd, "adi", 3) == 0)
242 g_menu_state = CURRENT_STATUS_ADD_DEVICE_ID_FOR_STREAM_ROUTING;
243 else if (strncmp(cmd, "rdi", 3) == 0)
244 g_menu_state = CURRENT_STATUS_REMOVE_DEVICE_ID_FOR_STREAM_ROUTING;
245 else if (strncmp(cmd, "aps", 3) == 0)
246 g_menu_state = CURRENT_STATUS_APPLY_STREAM_ROUTING;
247 else if (strncmp(cmd, "sso", 3) == 0)
248 g_menu_state = CURRENT_STATUS_SET_STREAM_ROUTING_OPTION;
249 else if (strncmp(cmd, "afc", 3) == 0)
250 g_menu_state = CURRENT_STATUS_ACQUIRE_FOCUS;
251 else if (strncmp(cmd, "rfc", 3) == 0)
252 g_menu_state = CURRENT_STATUS_RELEASE_FOCUS;
253 else if (strncmp(cmd, "afa", 3) == 0)
254 g_menu_state = CURRENT_STATUS_ACQUIRE_FOCUS_ALL;
255 else if (strncmp(cmd, "rfa", 3) == 0)
256 g_menu_state = CURRENT_STATUS_RELEASE_FOCUS_ALL;
257 else if (strncmp(cmd, "gfs", 3) == 0)
258 g_menu_state = CURRENT_STATUS_GET_ACQUIRED_FOCUS;
259 else if (strncmp(cmd, "gst", 3) == 0)
260 g_menu_state = CURRENT_STATUS_GET_SOUND_TYPE;
261 else if (strncmp(cmd, "dfc", 3) == 0)
262 g_menu_state = CURRENT_STATUS_DELIVER_FOCUS;
263 else if (strncmp(cmd, "afw", 3) == 0)
264 g_menu_state = CURRENT_STATUS_ADD_FOCUS_WATCH_CB;
265 else if (strncmp(cmd, "rfw", 3) == 0)
266 g_menu_state = CURRENT_STATUS_REMOVE_FOCUS_WATCH_CB;
267 else if (strncmp(cmd, "sfr", 3) == 0)
268 g_menu_state = CURRENT_STATUS_SET_FOCUS_REACQUISITION;
269 else if (strncmp(cmd, "gfr", 3) == 0)
270 g_menu_state = CURRENT_STATUS_GET_FOCUS_REACQUISITION;
271 else if (strncmp(cmd, "grp", 3) == 0)
272 g_menu_state = CURRENT_STATUS_GET_REASON_FOR_P_FOCUS;
273 else if (strncmp(cmd, "grr", 3) == 0)
274 g_menu_state = CURRENT_STATUS_GET_REASON_FOR_R_FOCUS;
275 else if (strncmp(cmd, "gmp", 3) == 0)
276 g_menu_state = CURRENT_STATUS_GET_CURRENT_MEDIA_PLAYBACK_DEVICE_TYPE;
277 else if (strncmp(cmd, "dsi", 3) == 0)
278 g_menu_state = CURRENT_STATUS_DESTROY_STREAM_INFO;
279 else if (strncmp(cmd, "vcr", 3) == 0)
280 g_menu_state = CURRENT_STATUS_CREATE_VIRTUAL_STREAM;
281 else if (strncmp(cmd, "vsr", 3) == 0)
282 g_menu_state = CURRENT_STATUS_START_VIRTUAL_STREAM;
283 else if (strncmp(cmd, "vst", 3) == 0)
284 g_menu_state = CURRENT_STATUS_STOP_VIRTUAL_STREAM;
285 else if (strncmp(cmd, "vdt", 3) == 0)
286 g_menu_state = CURRENT_STATUS_DESTROY_VIRTUAL_STREAM;
287 else if (strncmp(cmd, "sft", 3) == 0)
288 g_menu_state = CURRENT_STATUS_SET_FILTER;
289 else if (strncmp(cmd, "sfp", 3) == 0)
290 g_menu_state = CURRENT_STATUS_SET_FILTER_PRESET;
291 else if (strncmp(cmd, "uft", 3) == 0)
292 g_menu_state = CURRENT_STATUS_UNSET_FILTER;
293 #ifndef TIZEN_FEATURE_TV_PROD
294 else if (strncmp(cmd, "mgx", 3) == 0)
295 g_menu_state = CURRENT_STATUS_GET_MAX_MASTER_VOLUME;
296 else if (strncmp(cmd, "msv", 3) == 0)
297 g_menu_state = CURRENT_STATUS_SET_MASTER_VOLUME;
298 else if (strncmp(cmd, "mgv", 3) == 0)
299 g_menu_state = CURRENT_STATUS_GET_MASTER_VOLUME;
301 else if (strncmp(cmd, "q", 3) == 0) {
302 g_print("closing the test suite\n");
305 g_print("unknown menu \n");
308 void display_sub_basic()
311 g_print("=========================================================================================\n");
312 g_print(" Sound Manager Test (press q to quit) \n");
313 g_print("-----------------------------------------------------------------------------------------\n");
314 g_print(" VOLUME MODULE \n");
315 g_print("-----------------------------------------------------------------------------------------\n");
316 g_print("gx. Get Max Volume \t");
317 g_print("gv. Get Volume \t");
318 g_print("sv. Set Volume \n");
319 g_print("st. Set Current Sound Type \t");
320 g_print("gt. Get Current Sound Type \t");
321 g_print("ut. Unset Current Sound Type \n");
322 g_print("vc. Set Volume Changed CB \t");
323 g_print("uv. Unset Volume Changed CB \n");
324 #ifndef TIZEN_FEATURE_TV_PROD
325 g_print("mgx. *Get Max Master Volume \t");
326 g_print("mgv. *Get Master Volume \t");
327 g_print("msv. *Set Master Volume \n");
329 g_print("-----------------------------------------------------------------------------------------\n");
330 g_print(" SESSION MODULE \n");
331 g_print("-----------------------------------------------------------------------------------------\n");
332 g_print("ss. Set Session Type\t\t");
333 g_print("gs. Get Session Type\n");
334 g_print("sm. Set Media Session Option \t");
335 g_print("gm. Get Media Session Option \n");
336 g_print("sr. Set Media Session Resumption Option \t");
337 g_print("gr. Get Media Session Resumption Option \n");
338 g_print("so. Set Voip Session Mode \t");
339 g_print("go. Get Voip Session Mode \n");
340 g_print("sc. Set Session Interruped CB \t");
341 g_print("us. Unset Session Interrupted CB \n");
342 g_print("-----------------------------------------------------------------------------------------\n");
343 g_print(" DEVICE MODULE \n");
344 g_print("-----------------------------------------------------------------------------------------\n");
345 g_print("sk. Set Devices Mask(default ALL)\t");
346 g_print("gk. Get Devices Mask\n");
347 g_print("gcl. Get Devices List\t");
348 g_print("pl. Print Devices List\t");
349 g_print("gl. Get Devices List\t");
350 g_print("fl. Free Devices List\n");
351 g_print("gn. Get Next Device\t\t");
352 g_print("gp. Get Prev Device\n");
353 g_print("sd. Set Device Connenected CB\t\t");
354 g_print("ud. Unset Device Connenected CB\n");
355 g_print("si. Set Device Information Changed CB\t");
356 g_print("ui. Unset Device Information Changed CB\n");
357 g_print("adcc. Add Device Connenection Changed CB\t\t");
358 g_print("rdcc. Remove Device Connenection Changed CB\n");
359 g_print("adsc. Add Device State Changed CB\t\t");
360 g_print("rdsc. Remove Device State Changed CB\n");
361 g_print("-----------------------------------------------------------------------------------------\n");
362 g_print(" STREAM POLICY MODULE \n");
363 g_print("-----------------------------------------------------------------------------------------\n");
364 g_print("csi. Create Stream Info\t");
365 g_print("dsi. Destroy Stream Info\n");
366 g_print("gst. Get Sound Type\n");
367 g_print("ads. Add Device for Stream Routing\t");
368 g_print("rds. Remove Device for Stream Routing\n");
369 g_print("adi. *Add Device ID for Stream Routing\t");
370 g_print("rdi. *Remove Device ID for Stream Routing\n");
371 g_print("aps. Apply devices for Stream Routing\t");
372 g_print("rad. Remove all devices for Stream Routing\n");
373 g_print("afc. Acquire Focus\t");
374 g_print("rfc. Release Focus\t");
375 g_print("gfs. Get Focus State\n");
376 g_print("afa. Acquire Focus All\t");
377 g_print("rfa. Release Focus All\t");
378 g_print("dfc. Deliver Focus\n");
379 g_print("afw. Add Focus State Watch CB\t");
380 g_print("rfw. Remove Focus State Watch CB\n");
381 g_print("sfr. Set Focus Reacquisition\t");
382 g_print("gfr. Get Focus Reacquisition\n");
383 g_print("grp. Get Reason for Current Acquired Playback Focus\t");
384 g_print("grr. Get Reason for Current Acquired Recording Focus\n");
385 g_print("gmp. Get Current Media Playback Routing Path\n");
386 g_print("sso. *Set option for stream routing\n");
387 g_print("vcr. *Create VStream\t");
388 g_print("vsr. *Start VStream\t");
389 g_print("vst. *Stop VStream\t");
390 g_print("vdt. *Destroy VStream\n");
391 g_print("sft. *Set Filter\t");
392 g_print("sfp. *Set Filter Preset\t");
393 g_print("uft. *Unset Filter\n");
394 g_print(" * is for internal usage.\n");
395 g_print("=========================================================================================\n");
398 static void displaymenu()
401 if (g_menu_state == CURRENT_STATUS_MAINMENU) {
404 } else if (g_menu_state == CURRENT_STATUS_GET_MAX_VOLUME)
405 g_print("*** input sound type(0:SYSTEM 1:NOTIFICATION 2:ALARM 3:RINGTONE 4:MEDIA 5:CALL 6:VOIP 7:VOICE)\n");
406 else if (g_menu_state == CURRENT_STATUS_SET_VOLUME) {
408 g_print("*** input sound type and desired volume level(0:SYSTEM 1:NOTIFICATION 2:ALARM 3:RINGTONE 4:MEDIA 5:CALL 6:VOIP 7:VOICE, (0~max volum).\n");
410 } else if (g_menu_state == CURRENT_STATUS_GET_VOLUME)
411 g_print("*** input sound type(0:SYSTEM 1:NOTIFICATION 2:ALARM 3:RINGTONE 4:MEDIA 5:CALL 6:VOIP 7:VOICE)\n");
412 else if (g_menu_state == CURRENT_STATUS_SET_CURRENT_SOUND_TYPE)
413 g_print("*** input sound type.(0:SYSTEM 1:NOTIFICATION 2:ALARM 3:RINGTONE 4:MEDIA 5:CALL 6:VOIP 7:VOICE)\n");
414 else if (g_menu_state == CURRENT_STATUS_GET_CURRENT_SOUND_TYPE)
415 g_print("*** press enter to get current sound type\n");
416 else if (g_menu_state == CURRENT_STATUS_UNSET_CURRENT_SOUND_TYPE)
417 g_print("*** press enter to unset current sound type\n");
418 else if (g_menu_state == CURRENT_STATUS_SET_VOLUME_CHANGED_CB)
419 g_print("*** press enter to set volume changed cb\n");
420 else if (g_menu_state == CURRENT_STATUS_UNSET_VOLUME_CHANGED_CB)
421 g_print("*** press enter to unset volume changed cb\n");
422 else if (g_menu_state == CURRENT_STATUS_SET_SESSION_TYPE)
423 g_print("*** input session type(0:MEDIA, 1:ALARM, 2:NOTIFICATION, 3:EMERGENCY, 4:VOIP)\n");
424 else if (g_menu_state == CURRENT_STATUS_GET_SESSION_TYPE)
425 g_print("*** press enter to get session type\n");
426 else if (g_menu_state == CURRENT_STATUS_SET_MEDIA_SESSION_OPTION) {
428 g_print("*** input starting option, and ongoing(for starting(0:MIX WITH OTHERS, 1:PAUSE OTHERS), for ongoing(0:INTERRUPTABLE, 1:UNINTERRUPABLE)\n");
430 } else if (g_menu_state == CURRENT_STATUS_GET_MEDIA_SESSION_OPTION)
431 g_print("*** press enter to get media session option\n");
432 else if (g_menu_state == CURRENT_STATUS_SET_MEDIA_SESSION_RESUMPTION_OPTION)
433 g_print("*** input media session resumption option(0:BY SYSTEM, 1:OR MEDIA PAUSE)\n");
434 else if (g_menu_state == CURRENT_STATUS_GET_MEDIA_SESSION_RESUMPTION_OPTION)
435 g_print("*** press enter to get media session resumption option\n");
436 else if (g_menu_state == CURRENT_STATUS_SET_VOIP_SESSION_MODE)
437 g_print("*** input voip session mode (0:RINGTONE, 1:VOICE with RCV, 2:VOICE with SPK, 3:VOICE with AudioJack, 4:VOICE with BT)\n");
438 else if (g_menu_state == CURRENT_STATUS_GET_VOIP_SESSION_MODE)
439 g_print("*** press enter to get voip session mode\n");
440 else if (g_menu_state == CURRENT_STATUS_SET_CALL_SESSION_MODE)
441 g_print("*** input call session mode (0:RINGTONE, 1:VOICE with RCV, 2:VOICE with SPK, 3:VOICE with AudioJack, 4:VOICE with BT)\n");
442 else if (g_menu_state == CURRENT_STATUS_GET_CALL_SESSION_MODE)
443 g_print("*** press enter to get call session mode\n");
444 else if (g_menu_state == CURRENT_STATUS_SET_SESSION_INTERRUPTED_CB)
445 g_print("*** press enter to set session interrupted cb\n");
446 else if (g_menu_state == CURRENT_STATUS_UNSET_SESSION_INTERRUPTED_CB)
447 g_print("*** press enter to unset session interrupted cb\n");
448 else if (g_menu_state == CURRENT_STATUS_SET_DEVICE_MASK)
449 g_print("*** input device mask (0:ALL, 1:INTERNAL, 2:EXTERNAL, 3:INPUT, 4:OUTPUT, 5:BOTH, 6:ACTIVATED, 7:DEACTIVATED, b:back to the menu\n");
450 else if (g_menu_state == CURRENT_STATUS_GET_DEVICE_MASK)
451 g_print("*** press enter to get device mask\n");
452 else if (g_menu_state == CURRENT_STATUS_GET_CURRENT_DEVICE_LIST)
453 g_print("*** press enter to get current device list\n");
454 else if (g_menu_state == CURRENT_STATUS_GET_DEVICE_LIST)
455 g_print("*** press enter to get device list\n");
456 else if (g_menu_state == CURRENT_STATUS_PRINT_DEVICE_LIST)
457 g_print("*** press enter to print device list\n");
458 else if (g_menu_state == CURRENT_STATUS_FREE_DEVICE_LIST)
459 g_print("*** press enter to free device list\n");
460 else if (g_menu_state == CURRENT_STATUS_GET_DEVICE_NEXT)
461 g_print("*** press enter to get next device from the list\n");
462 else if (g_menu_state == CURRENT_STATUS_GET_DEVICE_PREV)
463 g_print("*** press enter to get previous device from the list\n");
464 else if (g_menu_state == CURRENT_STATUS_SET_DEVICE_CONNECTED_CB)
465 g_print("*** press enter to set device connected cb\n");
466 else if (g_menu_state == CURRENT_STATUS_UNSET_DEVICE_CONNECTED_CB)
467 g_print("*** press enter to unset device connected cb\n");
468 else if (g_menu_state == CURRENT_STATUS_ADD_DEVICE_CONNECTION_CHANGED_CB)
469 g_print("*** press enter to add device connected cb\n");
470 else if (g_menu_state == CURRENT_STATUS_REMOVE_DEVICE_CONNECTION_CHANGED_CB)
471 g_print("*** press enter to remove device connected cb\n");
472 else if (g_menu_state == CURRENT_STATUS_SET_DEVICE_INFO_CHANGED_CB)
473 g_print("*** press enter to set device information changed cb\n");
474 else if (g_menu_state == CURRENT_STATUS_UNSET_DEVICE_INFO_CHANGED_CB)
475 g_print("*** press enter to unset device information changed cb\n");
476 else if (g_menu_state == CURRENT_STATUS_ADD_DEVICE_STATE_CHANGED_CB)
477 g_print("*** press enter to add device state changed cb\n");
478 else if (g_menu_state == CURRENT_STATUS_REMOVE_DEVICE_STATE_CHANGED_CB)
479 g_print("*** press enter to remove device state changed cb\n");
480 else if (g_menu_state == CURRENT_STATUS_CREATE_STREAM_INFO)
481 g_print("*** input stream type to create stream information\n(0:media, 1:system, 2:alarm, 3:notification, 4:emergency, 5:ringtone-call, 6:voice-call, 7:voip, 8:media-ext-only, 9:loopback, 10:solo, 11:radio)\n");
482 else if (g_menu_state == CURRENT_STATUS_ADD_DEVICE_FOR_STREAM_ROUTING)
483 g_print("*** input device type to add (0:built-in mic, 1:built-in spk, 2:built-in rcv, 3:audio-jack, 4:bt-a2dp, 5:bt-sco 6:usb)\n");
484 else if (g_menu_state == CURRENT_STATUS_REMOVE_DEVICE_FOR_STREAM_ROUTING)
485 g_print("*** input device type to remove (0:built-in mic, 1:built-in spk, 2:built-in rcv, 3:audio-jack, 4:bt-a2dp, 5:bt-sco 6:usb)\n");
486 else if (g_menu_state == CURRENT_STATUS_REMOVE_ALL_DEVICES_FOR_STREAM_ROUTING)
487 g_print("*** press enter to remove all devices in stream info\n");
488 else if (g_menu_state == CURRENT_STATUS_ADD_DEVICE_ID_FOR_STREAM_ROUTING)
489 g_print("*** input device type to add (0:built-in mic, 1:built-in spk, 2:built-in rcv, 3:audio-jack, 4:bt-a2dp, 5:bt-sco 6:usb)\n");
490 else if (g_menu_state == CURRENT_STATUS_REMOVE_DEVICE_ID_FOR_STREAM_ROUTING)
491 g_print("*** input device type to remove (0:built-in mic, 1:built-in spk, 2:built-in rcv, 3:audio-jack, 4:bt-a2dp, 5:bt-sco 6:usb)\n");
492 else if (g_menu_state == CURRENT_STATUS_APPLY_STREAM_ROUTING)
493 g_print("*** press enter to apply devices for stream routing\n");
494 else if (g_menu_state == CURRENT_STATUS_SET_STREAM_ROUTING_OPTION)
495 g_print("*** input option(name/value) for routing (0:option_1/0, 1:option_1/1, 2:option_2/0, 3:option_2:1)\n");
496 else if (g_menu_state == CURRENT_STATUS_ACQUIRE_FOCUS)
497 g_print("*** input focus type to acquire (0:playback, 1:recording, 2:both, 3:both+noResume, 4:both+fading)\n");
498 else if (g_menu_state == CURRENT_STATUS_RELEASE_FOCUS)
499 g_print("*** input focus type to release (0:playback, 1:recording, 2:both, 3:both+noResume, 4:both+fading)\n");
500 else if (g_menu_state == CURRENT_STATUS_ACQUIRE_FOCUS_ALL)
501 g_print("*** input behavior for acquire all (0:without behavior, 1:with noResume, 2:with fading)\n");
502 else if (g_menu_state == CURRENT_STATUS_RELEASE_FOCUS_ALL)
503 g_print("*** input behavior for release all (0:without behavior, 1:with noResume, 2:with fading)\n");
504 else if (g_menu_state == CURRENT_STATUS_DELIVER_FOCUS)
505 g_print("*** input focus type to deliver (0:playback, 1:recording, 2:both)\n");
506 else if (g_menu_state == CURRENT_STATUS_GET_ACQUIRED_FOCUS)
507 g_print("*** press enter to get focus state\n");
508 else if (g_menu_state == CURRENT_STATUS_GET_SOUND_TYPE)
509 g_print("*** press enter to get sound type\n");
510 else if (g_menu_state == CURRENT_STATUS_DESTROY_STREAM_INFO)
511 g_print("*** press enter to destroy stream information\n");
512 else if (g_menu_state == CURRENT_STATUS_ADD_FOCUS_WATCH_CB)
513 g_print("*** input focus type to watch for (0:playback, 1:recording, 2:both)\n");
514 else if (g_menu_state == CURRENT_STATUS_REMOVE_FOCUS_WATCH_CB)
515 g_print("*** input focus watch callback id to remove\n");
516 else if (g_menu_state == CURRENT_STATUS_SET_FOCUS_REACQUISITION)
517 g_print("*** input focus reacquisition property (1:enable, 2:disable)\n");
518 else if (g_menu_state == CURRENT_STATUS_GET_FOCUS_REACQUISITION)
519 g_print("*** press enter to get focus reacquisition property\n");
520 else if (g_menu_state == CURRENT_STATUS_GET_REASON_FOR_P_FOCUS)
521 g_print("*** press enter to get reason for current playback focus\n");
522 else if (g_menu_state == CURRENT_STATUS_GET_REASON_FOR_R_FOCUS)
523 g_print("*** press enter to get reason for current recording focus\n");
524 else if (g_menu_state == CURRENT_STATUS_GET_CURRENT_MEDIA_PLAYBACK_DEVICE_TYPE)
525 g_print("*** press enter to get current_media_playback_device type\n");
526 else if (g_menu_state == CURRENT_STATUS_CREATE_VIRTUAL_STREAM)
527 g_print("*** press enter to create virtual stream\n");
528 else if (g_menu_state == CURRENT_STATUS_START_VIRTUAL_STREAM)
529 g_print("*** press enter to start virtual stream\n");
530 else if (g_menu_state == CURRENT_STATUS_STOP_VIRTUAL_STREAM)
531 g_print("*** press enter to stop virtual stream\n");
532 else if (g_menu_state == CURRENT_STATUS_DESTROY_VIRTUAL_STREAM)
533 g_print("*** press enter to destroy virtual stream\n");
534 else if (g_menu_state == CURRENT_STATUS_SET_FILTER)
535 g_print("*** input filter type of media stream (0:LOW_PASS 1:HIGH_PASS 2:DELAY 3:SOUNDALIVE)\n");
536 else if (g_menu_state == CURRENT_STATUS_SET_FILTER_PRESET)
537 g_print("*** input filter preset of media stream (LOW_PASS(1:none 2:240hz 3:480hz), HIGH_PASS(3:none 4:240hz 5:480hz) DELAY(6:none 7:1sec 8:2sec) SOUNDALIVE(9:normal 10:concert_hall))\n");
538 else if (g_menu_state == CURRENT_STATUS_UNSET_FILTER)
539 g_print("*** press enter to unset filter of media stream\n");
540 #ifndef TIZEN_FEATURE_TV_PROD
541 else if (g_menu_state == CURRENT_STATUS_GET_MAX_MASTER_VOLUME)
542 g_print("*** press enter to get max master volume level\n");
543 else if (g_menu_state == CURRENT_STATUS_SET_MASTER_VOLUME)
544 g_print("*** input master volume level\n");
545 else if (g_menu_state == CURRENT_STATUS_GET_MASTER_VOLUME)
546 g_print("*** press enter to get master volume level\n");
549 g_print("*** unknown status.\n");
555 gboolean timeout_menu_display(void* data)
561 int convert_sound_type(sound_type_e *type, char *cmd)
563 int sound_type_n = atoi(cmd);
564 if (SOUND_TYPE_SYSTEM > sound_type_n || sound_type_n > SOUND_TYPE_VOICE) {
565 g_print("not supported sound type(%d)\n", sound_type_n);
568 switch (sound_type_n) {
570 *type = SOUND_TYPE_SYSTEM;
573 *type = SOUND_TYPE_NOTIFICATION;
576 *type = SOUND_TYPE_ALARM;
579 *type = SOUND_TYPE_RINGTONE;
582 *type = SOUND_TYPE_MEDIA;
585 *type = SOUND_TYPE_CALL;
588 *type = SOUND_TYPE_VOIP;
591 *type = SOUND_TYPE_VOICE;
598 int convert_session_type(sound_session_type_e *type, char *cmd)
600 int session_type_n = atoi(cmd);
601 if (SOUND_SESSION_TYPE_MEDIA > session_type_n || session_type_n > SOUND_SESSION_TYPE_VOIP) {
602 g_print("not supported session type(%d)\n", session_type_n);
605 switch (session_type_n) {
607 *type = SOUND_SESSION_TYPE_MEDIA;
610 *type = SOUND_SESSION_TYPE_ALARM;
613 *type = SOUND_SESSION_TYPE_NOTIFICATION;
616 *type = SOUND_SESSION_TYPE_EMERGENCY;
619 *type = SOUND_SESSION_TYPE_VOIP;
626 void _set_volume_changed_cb(sound_type_e type, unsigned int volume, void *user_data)
628 g_print("***the volume has changed. the volume of this sound type(%d) is : %d \n", type, volume);
631 void _set_session_interrupted_cb(sound_session_interrupted_code_e code, void *user_data)
633 g_print("***your session has been interrupted by (%d)\n", code);
636 /* If failed to get some property, just give some default value */
637 void _get_device_props_simple(sound_device_h device, int *id, char **type, char **name,
638 const char **direc, const char **state, int *vendor_id, int *product_id)
641 sound_device_type_e _type;
642 sound_device_io_direction_e _direc;
643 sound_device_state_e _state;
649 if ((ret = sound_manager_get_device_type(device, &_type)))
650 g_print("failed to get device type, ret[0x%x]\n", ret);
652 _convert_device_type_enum_to_str(_type, type);
654 if ((ret = sound_manager_get_device_id(device, id)))
655 g_print("failed to get device id, ret[0x%x]\n", ret);
657 if (_type == SOUND_DEVICE_BLUETOOTH_MEDIA || _type == SOUND_DEVICE_BLUETOOTH_VOICE || _type == SOUND_DEVICE_USB_AUDIO) {
658 if ((ret = sound_manager_get_device_name(device, name))) {
659 g_print("failed to get device name, ret[0x%x]\n", ret);
662 if (_type == SOUND_DEVICE_USB_AUDIO) {
663 if ((ret = sound_manager_get_device_vendor_id(device, vendor_id)))
664 g_print("failed to get device vendor id, ret[0x%x]\n", ret);
665 if ((ret = sound_manager_get_device_product_id(device, product_id)))
666 g_print("failed to get device product id, ret[0x%x]\n", ret);
672 if ((ret = sound_manager_get_device_io_direction(device, &_direc))) {
673 g_print("failed to get device io direction, ret[0x%x]\n", ret);
676 *direc = g_device_direction_str[_direc];
679 if ((ret = sound_manager_get_device_state(device, &_state))) {
680 g_print("failed to get device state, ret[0x%x]\n", ret);
683 *state = g_device_state_str[_state];
687 void _set_device_connected_cb(sound_device_h device, bool is_connected, void *user_data)
693 const char *direc, *state;
695 _get_device_props_simple(device, &id, &type, &name, &direc, &state, &vendor_id, &product_id);
697 g_print("[ Device #%d %s %s ] %s\n", id, type, name, is_connected ? "Connected" : "Disconnected");
698 g_print(" Direc[ %-4s ] State[ %-12s ] VendorID[ %04x ], ProductID[ %04x ]\n", direc, state, vendor_id, product_id);
701 void _set_device_info_changed_cb(sound_device_h device, sound_device_changed_info_e changed_info, void *user_data)
708 const char *direc, *state;
709 const char *changed_info_str[] = {"State", "Direction", "Avail-Mode"};
711 _get_device_props_simple(device, &id, &type, &name, &direc, &state, &vendor_id, &product_id);
713 g_print("[Device #%d %s %s] %s changed\n", id, type, name, changed_info_str[changed_info]);
714 g_print(" Direc[ %-4s ] State[ %-12s ] VendorID[ %04x ], ProductID[ %04x ]\n", direc, state, vendor_id, product_id);
717 void _device_state_changed_cb(sound_device_h device, sound_device_state_e state, void *user_data)
723 const char *direc, *_state;
725 _get_device_props_simple(device, &id, &type, &name, &direc, &_state, &vendor_id, &product_id);
727 g_print("[Device #%d %s %s] state changed\n", id, type, name);
728 g_print(" Direc[ %-4s ] State(%d)[ %-12s ] VendorID[ %04x ], ProductID[ %04x ]\n", direc, state, _state, vendor_id, product_id);
731 void reset_menu_state(void)
733 g_menu_state = CURRENT_STATUS_MAINMENU;
736 static void interpret(char *cmd)
738 switch (g_menu_state) {
739 case CURRENT_STATUS_MAINMENU:
740 _interpret_main_menu(cmd);
742 case CURRENT_STATUS_GET_MAX_VOLUME: {
745 if (convert_sound_type(&type, cmd) == 1) {
746 if (sound_manager_get_max_volume(type, &max) != SOUND_MANAGER_ERROR_NONE)
747 g_print("failt to get max volume\n");
749 g_print("the max volume of this type(%d) is %d\n", type, max);
754 case CURRENT_STATUS_SET_VOLUME: {
756 static sound_type_e type;
760 if (convert_sound_type(&type, cmd) == 1)
767 if (sound_manager_set_volume(type, volume) != SOUND_MANAGER_ERROR_NONE)
768 g_print("fail to set volume(%d) check sound type(%d)'s available volume level\n", volume, type);
770 g_print("set volume success : sound type(%d), volume(%d)\n", type, volume);
779 case CURRENT_STATUS_GET_VOLUME: {
782 if (convert_sound_type(&type, cmd) == 1) {
783 if (sound_manager_get_volume(type, &volume) != SOUND_MANAGER_ERROR_NONE)
784 g_print("fail to get volume\n");
786 g_print("current volume of this type(%d) is : %d\n", type, volume);
791 case CURRENT_STATUS_SET_CURRENT_SOUND_TYPE: {
793 if (convert_sound_type(&type, cmd) == 1) {
794 if (sound_manager_set_current_sound_type(type) != SOUND_MANAGER_ERROR_NONE)
795 g_print("fail to set sound type(%d)\n", type);
797 g_print("success to set sound type(%d)\n", type);
802 case CURRENT_STATUS_GET_CURRENT_SOUND_TYPE: {
804 if (sound_manager_get_current_sound_type(&type) != SOUND_MANAGER_ERROR_NONE)
805 g_print("fail to get current sound type\n");
807 g_print("current sound type is (%d)\n", type);
811 case CURRENT_STATUS_UNSET_CURRENT_SOUND_TYPE: {
812 if (sound_manager_unset_current_sound_type() != SOUND_MANAGER_ERROR_NONE)
813 g_print("fail to unset current sound type\n");
815 g_print("success to unset current sound type\n");
819 case CURRENT_STATUS_SET_VOLUME_CHANGED_CB: {
820 if (sound_manager_set_volume_changed_cb(_set_volume_changed_cb, NULL) != SOUND_MANAGER_ERROR_NONE)
821 g_print("fail to set volume changed cb\n");
823 g_print("success to set volume changed cb\n");
827 case CURRENT_STATUS_UNSET_VOLUME_CHANGED_CB: {
828 if (sound_manager_unset_volume_changed_cb() != SOUND_MANAGER_ERROR_NONE)
829 g_print("fail to unset volume changed cb\n");
831 g_print("success to unset volume changed cb\n");
835 case CURRENT_STATUS_SET_SESSION_TYPE: {
836 sound_session_type_e type;
837 if (convert_session_type(&type, cmd) == 1) {
838 if (sound_manager_set_session_type(type) != SOUND_MANAGER_ERROR_NONE)
839 g_print("fail to set session type\n");
841 g_print("success to set session type(%d)\n", type);
846 case CURRENT_STATUS_GET_SESSION_TYPE: {
847 sound_session_type_e type;
848 if (sound_manager_get_session_type(&type) != SOUND_MANAGER_ERROR_NONE)
849 g_print("fail to get session type\n");
851 g_print("current session type is : %d (0:MEDIA, 1:ALARM, 2:NOTIFICATION, 3:EMERGENCY, 4:VOIP, 5:CALL)\n", type);
855 case CURRENT_STATUS_SET_MEDIA_SESSION_OPTION: {
856 sound_session_type_e type = SOUND_SESSION_TYPE_MEDIA;
857 static sound_session_option_for_starting_e option_s;
858 static sound_session_option_for_during_play_e option_d;
860 if (sound_manager_set_session_type(type) != SOUND_MANAGER_ERROR_NONE) {
861 g_print("fail to set media session type\n");
866 option_s = (sound_session_option_for_starting_e)atoi(cmd);
867 if (SOUND_SESSION_OPTION_PAUSE_OTHERS_WHEN_START < option_s)
868 g_print("not supported option type\n");
873 option_d = (sound_session_option_for_during_play_e)atoi(cmd);
874 if (SOUND_SESSION_OPTION_UNINTERRUPTIBLE_DURING_PLAY < option_d)
875 g_print("not supported option type\n");
877 if (sound_manager_set_media_session_option(option_s, option_d) != SOUND_MANAGER_ERROR_NONE)
878 g_print("fail to set media session option\n");
880 g_print("success to set media session option\n");
891 case CURRENT_STATUS_GET_MEDIA_SESSION_OPTION: {
892 sound_session_type_e type = SOUND_SESSION_TYPE_MEDIA;
893 sound_session_option_for_starting_e option_s;
894 sound_session_option_for_during_play_e option_d;
895 if (sound_manager_set_session_type(type) != SOUND_MANAGER_ERROR_NONE)
896 g_print("fail to set media session type\n");
898 if (sound_manager_get_media_session_option(&option_s, &option_d) != SOUND_MANAGER_ERROR_NONE)
899 g_print("fail to get media session option\n");
901 g_print("current media session options are (%d) for starting, (%d) for ongoing\n", option_s, option_d);
906 case CURRENT_STATUS_SET_MEDIA_SESSION_RESUMPTION_OPTION: {
907 sound_session_type_e type = SOUND_SESSION_TYPE_MEDIA;
908 sound_session_option_for_resumption_e option_r;
909 if (sound_manager_set_session_type(type) != SOUND_MANAGER_ERROR_NONE)
910 g_print("fail to set media session type\n");
912 option_r = (sound_session_option_for_resumption_e)atoi(cmd);
913 if (SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM_OR_MEDIA_PAUSED < option_r)
914 g_print("not supported option type\n");
916 if (sound_manager_set_media_session_resumption_option(option_r) != SOUND_MANAGER_ERROR_NONE)
917 g_print("fail to set media session resumption option\n");
919 g_print("succese to set media session resumption option\n");
925 case CURRENT_STATUS_GET_MEDIA_SESSION_RESUMPTION_OPTION: {
926 sound_session_type_e type = SOUND_SESSION_TYPE_MEDIA;
927 sound_session_option_for_resumption_e option_r;
928 if (sound_manager_set_session_type(type) != SOUND_MANAGER_ERROR_NONE)
929 g_print("fail to set media session type\n");
931 if (sound_manager_get_media_session_resumption_option(&option_r) != SOUND_MANAGER_ERROR_NONE)
932 g_print("fail to get media session resumption option\n");
934 g_print("current media session resumption option is : %d\n", option_r);
939 case CURRENT_STATUS_SET_VOIP_SESSION_MODE: {
940 int ret = SOUND_MANAGER_ERROR_NONE;
941 sound_session_voip_mode_e mode;
942 mode = (sound_session_voip_mode_e)atoi(cmd);
943 ret = sound_manager_set_voip_session_mode(mode);
945 g_print("failed to set voip session mode(%d), ret[0x%x]\n", mode, ret);
947 g_print("success to set voip session mode\n");
951 case CURRENT_STATUS_GET_VOIP_SESSION_MODE: {
952 int ret = SOUND_MANAGER_ERROR_NONE;
953 sound_session_voip_mode_e mode;
954 ret = sound_manager_get_voip_session_mode(&mode);
956 g_print("fail to get voip session mode, ret[0x%x]\n", ret);
958 g_print("success to get voip session mode, mode[%d]\n", mode);
962 case CURRENT_STATUS_SET_SESSION_INTERRUPTED_CB: {
963 if (sound_manager_set_session_interrupted_cb(_set_session_interrupted_cb, NULL) != SOUND_MANAGER_ERROR_NONE)
964 g_print("fail to set interrupted changed cb\n");
966 g_print("success to set interrupted changed cb\n");
970 case CURRENT_STATUS_UNSET_SESSION_INTERRUPTED_CB: {
971 if (sound_manager_unset_session_interrupted_cb() != 0)
972 g_print("fail to unset interrupted changed cb\n");
974 g_print("success to unset interrupted changed cb\n");
978 case CURRENT_STATUS_SET_DEVICE_MASK: {
979 if (strncmp(cmd, "0", 1) == 0) {
980 g_device_mask = SOUND_DEVICE_ALL_MASK;
982 } else if (strncmp(cmd, "1", 1) == 0) {
983 if (g_device_mask == SOUND_DEVICE_ALL_MASK)
984 g_device_mask = SOUND_DEVICE_TYPE_INTERNAL_MASK;
986 g_device_mask |= SOUND_DEVICE_TYPE_INTERNAL_MASK;
987 g_print("add TYPE_INTERNAL MASK\n");
988 } else if (strncmp(cmd, "2", 1) == 0) {
989 if (g_device_mask == SOUND_DEVICE_ALL_MASK)
990 g_device_mask = SOUND_DEVICE_TYPE_EXTERNAL_MASK;
992 g_device_mask |= SOUND_DEVICE_TYPE_EXTERNAL_MASK;
993 g_print("add TYPE_EXTERNAL MASK\n");
994 } else if (strncmp(cmd, "3", 1) == 0) {
995 if (g_device_mask == SOUND_DEVICE_ALL_MASK)
996 g_device_mask = SOUND_DEVICE_IO_DIRECTION_IN_MASK;
998 g_device_mask |= SOUND_DEVICE_IO_DIRECTION_IN_MASK;
999 g_print("add IO_DIRECTION_IN MASK\n");
1000 } else if (strncmp(cmd, "4", 1) == 0) {
1001 if (g_device_mask == SOUND_DEVICE_ALL_MASK)
1002 g_device_mask = SOUND_DEVICE_IO_DIRECTION_OUT_MASK;
1004 g_device_mask |= SOUND_DEVICE_IO_DIRECTION_OUT_MASK;
1005 g_print("add IO_DIRECTION_OUT MASK\n");
1006 } else if (strncmp(cmd, "5", 1) == 0) {
1007 if (g_device_mask == SOUND_DEVICE_ALL_MASK)
1008 g_device_mask = SOUND_DEVICE_IO_DIRECTION_BOTH_MASK;
1010 g_device_mask |= SOUND_DEVICE_IO_DIRECTION_BOTH_MASK;
1011 g_print("add IO_DIRECTION_BOTH MASK\n");
1012 } else if (strncmp(cmd, "6", 1) == 0) {
1013 if (g_device_mask == SOUND_DEVICE_ALL_MASK)
1014 g_device_mask = SOUND_DEVICE_STATE_ACTIVATED_MASK;
1016 g_device_mask |= SOUND_DEVICE_STATE_ACTIVATED_MASK;
1017 g_print("add STATE_ACTIVATED MASK\n");
1018 } else if (strncmp(cmd, "7", 1) == 0) {
1019 if (g_device_mask == SOUND_DEVICE_ALL_MASK)
1020 g_device_mask = SOUND_DEVICE_STATE_DEACTIVATED_MASK;
1022 g_device_mask |= SOUND_DEVICE_STATE_DEACTIVATED_MASK;
1023 g_print("add STATE_DEACTIVATED MASK\n");
1024 } else if (strncmp(cmd, "b", 1) == 0) {
1025 g_print("device mask[0x%x]\n", g_device_mask);
1028 g_print("invalid selection, please select again..\n");
1032 case CURRENT_STATUS_GET_DEVICE_MASK: {
1033 g_print("current device mask[0x%x]\n", g_device_mask);
1037 case CURRENT_STATUS_GET_CURRENT_DEVICE_LIST: {
1038 int ret = SOUND_MANAGER_ERROR_NONE;
1039 if (!(ret = sound_manager_get_current_device_list(g_device_mask, &g_device_list)))
1040 g_print("success to get current device list\n");
1042 g_print("fail to get current device list, ret[0x%x]\n", ret);
1046 case CURRENT_STATUS_GET_DEVICE_LIST: {
1047 int ret = SOUND_MANAGER_ERROR_NONE;
1048 if (!(ret = sound_manager_get_device_list(g_device_mask, &g_device_list)))
1049 g_print("success to get device list\n");
1051 g_print("fail to get device list, ret[0x%x]\n", ret);
1055 case CURRENT_STATUS_PRINT_DEVICE_LIST: {
1056 sound_device_list_h device_list;
1057 sound_device_h device;
1058 int ret = SOUND_MANAGER_ERROR_NONE;
1061 int product_id = -1;
1066 if (!(ret = sound_manager_get_device_list(g_device_mask, &device_list))) {
1067 g_print("success to get current device list\n");
1068 while (!sound_manager_get_next_device(device_list, &device)) {
1069 _get_device_props_simple(device, &id, &type, &name, &direc, &state, &vendor_id, &product_id);
1070 g_print("[ Device #%d %s %s ]\n", id, type, name);
1071 g_print(" Direc[ %-4s ] State[ %-12s ] VendorID[ %04x ], ProductID[ %04x ]\n", direc, state, vendor_id, product_id);
1074 g_print("fail to get current device list, ret[0x%x]\n", ret);
1079 case CURRENT_STATUS_FREE_DEVICE_LIST: {
1080 int ret = SOUND_MANAGER_ERROR_NONE;
1081 if (!(ret = sound_manager_free_device_list(g_device_list))) {
1082 g_print("success to free device list\n");
1083 g_device_list = NULL;
1084 g_print("device list freed\n");
1086 g_print("fail to free device list, ret[0x%x]\n", ret);
1091 case CURRENT_STATUS_GET_DEVICE_NEXT: {
1092 sound_device_h device;
1093 sound_device_type_e type;
1094 sound_device_io_direction_e io_direction;
1095 sound_device_state_e state;
1098 int ret = SOUND_MANAGER_ERROR_NONE;
1099 if (!(ret = sound_manager_get_next_device(g_device_list, &device))) {
1100 g_print("success to get next device\n");
1101 if ((ret = sound_manager_get_device_type(device, &type)))
1102 g_print("failed to get device type, ret[0x%x]\n", ret);
1103 if ((ret = sound_manager_get_device_io_direction(device, &io_direction)))
1104 g_print("failed to get device io direction, ret[0x%x]\n", ret);
1105 if ((ret = sound_manager_get_device_id(device, &id)))
1106 g_print("failed to get device id, ret[0x%x]\n", ret);
1107 if ((ret = sound_manager_get_device_name(device, &name)))
1108 g_print("failed to get device name, ret[0x%x]\n", ret);
1109 if ((ret = sound_manager_get_device_state(device, &state)))
1110 g_print("failed to get device state, ret[0x%x]\n", ret);
1112 g_print("-- NEXT device type[%d], io_direction[%d], id[%d], name[%s], state[%d]\n", type, io_direction, id, name, state);
1114 g_print("failed to get next device, ret[0x%x]\n", ret);
1119 case CURRENT_STATUS_GET_DEVICE_PREV: {
1120 sound_device_h device;
1121 sound_device_type_e type;
1122 sound_device_io_direction_e io_direction;
1123 sound_device_state_e state;
1126 int ret = SOUND_MANAGER_ERROR_NONE;
1127 if (!(ret = sound_manager_get_prev_device(g_device_list, &device))) {
1128 g_print("success to get previous device\n");
1129 if ((ret = sound_manager_get_device_type(device, &type)))
1130 g_print("failed to get device type, ret[0x%x]\n", ret);
1131 if ((ret = sound_manager_get_device_io_direction(device, &io_direction)))
1132 g_print("failed to get device io direction, ret[0x%x]\n", ret);
1133 if ((ret = sound_manager_get_device_id(device, &id)))
1134 g_print("failed to get device id, ret[0x%x]\n", ret);
1135 if ((ret = sound_manager_get_device_name(device, &name)))
1136 g_print("failed to get device name, ret[0x%x]\n", ret);
1137 if ((ret = sound_manager_get_device_state(device, &state)))
1138 g_print("failed to get device state, ret[0x%x]\n", ret);
1140 g_print("-- PREV device type[%d], io_direction[%d], id[%d], name[%s], state[%d]\n", type, io_direction, id, name, state);
1142 g_print("failed to get previous device, ret[0x%x]\n", ret);
1147 case CURRENT_STATUS_SET_DEVICE_CONNECTED_CB: {
1148 if (sound_manager_set_device_connected_cb(g_device_mask, _set_device_connected_cb, NULL))
1149 g_print("fail to set device connected cb\n");
1151 g_print("success to set device connected cb\n");
1155 case CURRENT_STATUS_UNSET_DEVICE_CONNECTED_CB: {
1156 if (sound_manager_unset_device_connected_cb())
1157 g_print("fail to unset device connected cb\n");
1159 g_print("success to unset device connected cb\n");
1163 case CURRENT_STATUS_ADD_DEVICE_CONNECTION_CHANGED_CB: {
1164 if (sound_manager_add_device_connection_changed_cb(g_device_mask, _set_device_connected_cb, NULL, &g_device_conn_cb_id))
1165 g_print("fail to add device connection changed cb\n");
1167 g_print("success to add device connection changed cb\n");
1171 case CURRENT_STATUS_REMOVE_DEVICE_CONNECTION_CHANGED_CB: {
1172 if (sound_manager_remove_device_connection_changed_cb(g_device_conn_cb_id))
1173 g_print("fail to remove device connection changed cb\n");
1175 g_print("success to remove device connection changed cb\n");
1179 case CURRENT_STATUS_SET_DEVICE_INFO_CHANGED_CB: {
1180 if (sound_manager_set_device_information_changed_cb(g_device_mask, _set_device_info_changed_cb, NULL))
1181 g_print("fail to set device information changed cb\n");
1183 g_print("success to set device information changed cb\n");
1187 case CURRENT_STATUS_UNSET_DEVICE_INFO_CHANGED_CB: {
1188 if (sound_manager_unset_device_information_changed_cb())
1189 g_print("fail to unset device information changed cb\n");
1191 g_print("success to unset device information changed cb\n");
1195 case CURRENT_STATUS_ADD_DEVICE_STATE_CHANGED_CB: {
1196 if (sound_manager_add_device_state_changed_cb(g_device_mask, _device_state_changed_cb, NULL, &g_device_state_cb_id))
1197 g_print("fail to add device state changed cb\n");
1199 g_print("success to add device state changed cb\n");
1203 case CURRENT_STATUS_REMOVE_DEVICE_STATE_CHANGED_CB: {
1204 if (sound_manager_remove_device_state_changed_cb(g_device_state_cb_id))
1205 g_print("fail to remove device state changed cb\n");
1207 g_print("success to remove device state changed cb\n");
1211 case CURRENT_STATUS_CREATE_STREAM_INFO: {
1212 int ret = SOUND_MANAGER_ERROR_NONE;
1213 int stream_type = 0;
1214 sound_stream_type_e type = SOUND_STREAM_TYPE_MEDIA;
1215 if (g_stream_info_h) {
1216 g_print("fail to create stream information, g_stream_info_h(%p) is already set\n", g_stream_info_h);
1220 stream_type = atoi(cmd);
1221 switch (stream_type) {
1223 type = SOUND_STREAM_TYPE_MEDIA;
1225 case 1: /* system */
1226 type = SOUND_STREAM_TYPE_SYSTEM;
1229 type = SOUND_STREAM_TYPE_ALARM;
1231 case 3: /* notification */
1232 type = SOUND_STREAM_TYPE_NOTIFICATION;
1234 case 4: /* emergency */
1235 type = SOUND_STREAM_TYPE_EMERGENCY;
1237 case 5: /* ringtone for call*/
1238 type = SOUND_STREAM_TYPE_RINGTONE_CALL;
1240 case 6: /* voice call */
1241 type = SOUND_STREAM_TYPE_VOICE_CALL;
1244 type = SOUND_STREAM_TYPE_VOIP;
1246 case 8: /* media only for external devices */
1247 type = SOUND_STREAM_TYPE_MEDIA_EXTERNAL_ONLY;
1249 case 9: /* loopback */
1250 type = SOUND_STREAM_TYPE_LOOPBACK;
1253 type = SOUND_STREAM_TYPE_SOLO;
1255 case 11: /* radio */
1256 type = SOUND_STREAM_TYPE_RADIO;
1259 type = SOUND_STREAM_TYPE_MEDIA;
1262 if (type == (int)SOUND_STREAM_TYPE_RINGTONE_CALL ||
1263 type == (int)SOUND_STREAM_TYPE_VOICE_CALL ||
1264 type == (int)SOUND_STREAM_TYPE_RADIO ||
1265 type == (int)SOUND_STREAM_TYPE_LOOPBACK)
1266 ret = sound_manager_create_stream_information_internal(type, focus_callback, NULL, &g_stream_info_h);
1267 else if (type == (int)SOUND_STREAM_TYPE_SOLO)
1268 ret = sound_manager_create_stream_information_internal(type, NULL, NULL, &g_stream_info_h);
1270 ret = sound_manager_create_stream_information(type, focus_callback, NULL, &g_stream_info_h);
1273 g_print("fail to sound_manager_create_stream_information(), ret(0x%x)\n", ret);
1278 case CURRENT_STATUS_ADD_DEVICE_FOR_STREAM_ROUTING: {
1279 int ret = SOUND_MANAGER_ERROR_NONE;
1280 int device_type = 0;
1281 sound_device_h device = NULL;
1282 sound_device_type_e selected_type = SOUND_DEVICE_BUILTIN_SPEAKER;
1283 sound_device_type_e type = SOUND_DEVICE_BUILTIN_SPEAKER;
1284 bool need_to_go = false;
1286 device_type = atoi(cmd);
1287 switch (device_type) {
1288 case 0: /* built-in mic */
1289 selected_type = SOUND_DEVICE_BUILTIN_MIC;
1291 case 1: /* built-in spk */
1292 selected_type = SOUND_DEVICE_BUILTIN_SPEAKER;
1294 case 2: /* built-in rcv */
1295 selected_type = SOUND_DEVICE_BUILTIN_RECEIVER;
1297 case 3: /* audio-jack */
1298 selected_type = SOUND_DEVICE_AUDIO_JACK;
1300 case 4: /* bt a2dp */
1301 selected_type = SOUND_DEVICE_BLUETOOTH_MEDIA;
1303 case 5: /* bt sco */
1304 selected_type = SOUND_DEVICE_BLUETOOTH_VOICE;
1307 selected_type = SOUND_DEVICE_USB_AUDIO;
1310 g_print("invalid argument, device_type(%d) is not valid for this feature\n", device_type);
1314 if (!(ret = sound_manager_get_device_list(SOUND_DEVICE_ALL_MASK, &g_device_list))) {
1315 g_print("success to get current device list\n");
1316 while (!sound_manager_get_next_device(g_device_list, &device)) {
1317 if ((ret = sound_manager_get_device_type(device, &type))) {
1318 g_print("fail to get type of device, ret(0x%x)\n", ret);
1322 if (selected_type == type) {
1328 ret = sound_manager_add_device_for_stream_routing(g_stream_info_h, device);
1330 g_print("failed to sound_manager_add_device_for_stream_routing(), ret(0x%x)\n", ret);
1332 g_print("the device is not available now\n");
1335 if (!(ret = sound_manager_free_device_list(g_device_list))) {
1336 g_print("success to free device list\n");
1337 g_device_list = NULL;
1339 g_print("fail to free device list, ret[0x%x]\n", ret);
1342 g_print("fail to get current device list, ret(0x%x)\n", ret);
1347 case CURRENT_STATUS_REMOVE_DEVICE_FOR_STREAM_ROUTING: {
1348 int ret = SOUND_MANAGER_ERROR_NONE;
1349 int device_type = 0;
1350 sound_device_h device = NULL;
1351 sound_device_type_e selected_type = SOUND_DEVICE_BUILTIN_SPEAKER;
1352 sound_device_type_e type = SOUND_DEVICE_BUILTIN_SPEAKER;
1353 bool need_to_go = false;
1355 device_type = atoi(cmd);
1356 switch (device_type) {
1357 case 0: /* built-in mic */
1358 selected_type = SOUND_DEVICE_BUILTIN_MIC;
1360 case 1: /* built-in spk */
1361 selected_type = SOUND_DEVICE_BUILTIN_SPEAKER;
1363 case 2: /* built-in rcv */
1364 selected_type = SOUND_DEVICE_BUILTIN_RECEIVER;
1366 case 3: /* audio-jack */
1367 selected_type = SOUND_DEVICE_AUDIO_JACK;
1369 case 4: /* bt a2dp */
1370 selected_type = SOUND_DEVICE_BLUETOOTH_MEDIA;
1372 case 5: /* bt sco */
1373 selected_type = SOUND_DEVICE_BLUETOOTH_VOICE;
1376 selected_type = SOUND_DEVICE_USB_AUDIO;
1379 g_print("invalid argument, device_type(%d) is not valid for this feature\n", device_type);
1383 if (!(ret = sound_manager_get_device_list(SOUND_DEVICE_ALL_MASK, &g_device_list))) {
1384 g_print("success to get current device list\n");
1385 while (!sound_manager_get_next_device(g_device_list, &device)) {
1386 if ((ret = sound_manager_get_device_type(device, &type))) {
1387 g_print("fail to get type of device, ret(0x%x)\n", ret);
1391 if (selected_type == type) {
1397 ret = sound_manager_remove_device_for_stream_routing(g_stream_info_h, device);
1399 g_print("failed to sound_manager_remove_device_for_stream_routing(), ret(0x%x)\n", ret);
1401 g_print("the device is not available now\n");
1404 g_print("fail to get current device list, ret(0x%x)\n", ret);
1408 if (!(ret = sound_manager_free_device_list(g_device_list))) {
1409 g_print("success to free device list\n");
1410 g_device_list = NULL;
1412 g_print("fail to free device list, ret[0x%x]\n", ret);
1417 case CURRENT_STATUS_REMOVE_ALL_DEVICES_FOR_STREAM_ROUTING: {
1418 int ret = SOUND_MANAGER_ERROR_NONE;
1420 if ((ret = sound_manager_remove_all_devices_for_stream_routing(g_stream_info_h)))
1421 g_print("fail to remove all devices for stream routing, ret[0x%x]\n", ret);
1426 case CURRENT_STATUS_ADD_DEVICE_ID_FOR_STREAM_ROUTING: {
1427 int ret = SOUND_MANAGER_ERROR_NONE;
1428 int device_type = 0;
1429 sound_device_h device = NULL;
1430 sound_device_type_e selected_type = SOUND_DEVICE_BUILTIN_SPEAKER;
1431 sound_device_type_e type = SOUND_DEVICE_BUILTIN_SPEAKER;
1432 bool need_to_go = false;
1435 device_type = atoi(cmd);
1436 switch (device_type) {
1437 case 0: /* built-in mic */
1438 selected_type = SOUND_DEVICE_BUILTIN_MIC;
1440 case 1: /* built-in spk */
1441 selected_type = SOUND_DEVICE_BUILTIN_SPEAKER;
1443 case 2: /* built-in rcv */
1444 selected_type = SOUND_DEVICE_BUILTIN_RECEIVER;
1446 case 3: /* audio-jack */
1447 selected_type = SOUND_DEVICE_AUDIO_JACK;
1449 case 4: /* bt a2dp */
1450 selected_type = SOUND_DEVICE_BLUETOOTH_MEDIA;
1452 case 5: /* bt sco */
1453 selected_type = SOUND_DEVICE_BLUETOOTH_VOICE;
1456 selected_type = SOUND_DEVICE_USB_AUDIO;
1459 g_print("invalid argument, device_type(%d) is not valid for this feature\n", device_type);
1463 if (!(ret = sound_manager_get_device_list(SOUND_DEVICE_ALL_MASK, &g_device_list))) {
1464 g_print("success to get current device list\n");
1465 while (!sound_manager_get_next_device(g_device_list, &device)) {
1466 if ((ret = sound_manager_get_device_type(device, &type))) {
1467 g_print("fail to get type of device, ret(0x%x)\n", ret);
1471 if (selected_type == type) {
1472 if ((ret = sound_manager_get_device_id(device, &device_id))) {
1473 g_print("fail to get device id, ret(0x%x)\n", ret);
1482 ret = sound_manager_add_device_id_for_stream_routing(g_stream_info_h, device_id);
1484 g_print("failed to sound_manager_add_device_id_for_stream_routing(), ret(0x%x)\n", ret);
1486 g_print("the device is not available now\n");
1489 if (!(ret = sound_manager_free_device_list(g_device_list))) {
1490 g_print("success to free device list\n");
1491 g_device_list = NULL;
1493 g_print("fail to free device list, ret[0x%x]\n", ret);
1496 g_print("fail to get current device list, ret(0x%x)\n", ret);
1501 case CURRENT_STATUS_REMOVE_DEVICE_ID_FOR_STREAM_ROUTING: {
1502 int ret = SOUND_MANAGER_ERROR_NONE;
1503 int device_type = 0;
1504 sound_device_h device = NULL;
1505 sound_device_type_e selected_type = SOUND_DEVICE_BUILTIN_SPEAKER;
1506 sound_device_type_e type = SOUND_DEVICE_BUILTIN_SPEAKER;
1507 bool need_to_go = false;
1510 device_type = atoi(cmd);
1511 switch (device_type) {
1512 case 0: /* built-in mic */
1513 selected_type = SOUND_DEVICE_BUILTIN_MIC;
1515 case 1: /* built-in spk */
1516 selected_type = SOUND_DEVICE_BUILTIN_SPEAKER;
1518 case 2: /* built-in rcv */
1519 selected_type = SOUND_DEVICE_BUILTIN_RECEIVER;
1521 case 3: /* audio-jack */
1522 selected_type = SOUND_DEVICE_AUDIO_JACK;
1524 case 4: /* bt a2dp */
1525 selected_type = SOUND_DEVICE_BLUETOOTH_MEDIA;
1527 case 5: /* bt sco */
1528 selected_type = SOUND_DEVICE_BLUETOOTH_VOICE;
1531 selected_type = SOUND_DEVICE_USB_AUDIO;
1534 g_print("invalid argument, device_type(%d) is not valid for this feature\n", device_type);
1538 if (!(ret = sound_manager_get_device_list(SOUND_DEVICE_ALL_MASK, &g_device_list))) {
1539 g_print("success to get current device list\n");
1540 while (!sound_manager_get_next_device(g_device_list, &device)) {
1541 if ((ret = sound_manager_get_device_type(device, &type))) {
1542 g_print("fail to get type of device, ret(0x%x)\n", ret);
1546 if (selected_type == type) {
1547 if ((ret = sound_manager_get_device_id(device, &device_id))) {
1548 g_print("fail to get device id, ret(0x%x)\n", ret);
1557 ret = sound_manager_remove_device_id_for_stream_routing(g_stream_info_h, device_id);
1559 g_print("failed to sound_manager_remove_device_id_for_stream_routing(), ret(0x%x)\n", ret);
1561 g_print("the device is not available now\n");
1564 g_print("fail to get current device list, ret(0x%x)\n", ret);
1568 if (!(ret = sound_manager_free_device_list(g_device_list))) {
1569 g_print("success to free device list\n");
1570 g_device_list = NULL;
1572 g_print("fail to free device list, ret[0x%x]\n", ret);
1577 case CURRENT_STATUS_APPLY_STREAM_ROUTING: {
1578 int ret = SOUND_MANAGER_ERROR_NONE;
1579 ret = sound_manager_apply_stream_routing(g_stream_info_h);
1581 g_print("failed to sound_manager_apply_stream_routing(), ret(0x%x)\n", ret);
1586 case CURRENT_STATUS_SET_STREAM_ROUTING_OPTION: {
1587 int ret = SOUND_MANAGER_ERROR_NONE;
1592 selection = atoi(cmd);
1593 switch (selection) {
1611 g_print("invalid argument, try again..\n");
1615 ret = sound_manager_set_stream_routing_option(g_stream_info_h, name, value);
1617 g_print("failed to sound_manager_set_stream_routing_option(), ret(0x%x)\n", ret);
1622 case CURRENT_STATUS_ACQUIRE_FOCUS: {
1623 int ret = SOUND_MANAGER_ERROR_NONE;
1625 sound_stream_focus_mask_e focus_mask;
1626 int behavior = SOUND_BEHAVIOR_NONE;
1628 focus_type = atoi(cmd);
1629 switch (focus_type) {
1630 case 0: /* playback */
1631 focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK;
1633 case 1: /* recording */
1634 focus_mask = SOUND_STREAM_FOCUS_FOR_RECORDING;
1637 focus_mask = SOUND_STREAM_FOCUS_FOR_BOTH;
1639 case 3: /* both + no-resumption */
1640 focus_mask = SOUND_STREAM_FOCUS_FOR_BOTH;
1641 behavior = SOUND_BEHAVIOR_NO_RESUME;
1643 case 4: /* both + fading */
1644 focus_mask = SOUND_STREAM_FOCUS_FOR_BOTH;
1645 behavior = SOUND_BEHAVIOR_FADING;
1648 g_print("invalid selection(%d), keep going with PLAYBACK focus..\n", focus_type);
1649 focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK;
1652 ret = sound_manager_acquire_focus(g_stream_info_h, focus_mask,
1654 "sound_manager_test(acquire_focus)");
1656 g_print("fail to sound_manager_acquire_focus(), ret(0x%x)\n", ret);
1661 case CURRENT_STATUS_RELEASE_FOCUS: {
1662 int ret = SOUND_MANAGER_ERROR_NONE;
1664 sound_stream_focus_mask_e focus_mask;
1665 int behavior = SOUND_BEHAVIOR_NONE;
1667 focus_type = atoi(cmd);
1668 switch (focus_type) {
1669 case 0: /* playback */
1670 focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK;
1672 case 1: /* recording */
1673 focus_mask = SOUND_STREAM_FOCUS_FOR_RECORDING;
1676 focus_mask = SOUND_STREAM_FOCUS_FOR_BOTH;
1678 case 3: /* both + no-resumption */
1679 focus_mask = SOUND_STREAM_FOCUS_FOR_BOTH;
1680 behavior = SOUND_BEHAVIOR_NO_RESUME;
1682 case 4: /* both + fading */
1683 focus_mask = SOUND_STREAM_FOCUS_FOR_BOTH;
1684 behavior = SOUND_BEHAVIOR_FADING;
1687 g_print("invalid selection(%d), keep going with PLAYBACK focus..\n", focus_type);
1688 focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK;
1691 ret = sound_manager_release_focus(g_stream_info_h, focus_mask,
1693 "sound_manager_test(release_focus)");
1695 g_print("fail to sound_manager_release_focus(), ret(0x%x)\n", ret);
1700 case CURRENT_STATUS_ACQUIRE_FOCUS_ALL: {
1701 int ret = SOUND_MANAGER_ERROR_NONE;
1702 int behavior = atoi(cmd);
1705 case 0: /* without behavior */
1706 behavior = SOUND_BEHAVIOR_NONE;
1708 case 1: /* no-resumption */
1709 behavior = SOUND_BEHAVIOR_NO_RESUME;
1711 case 2: /* fading */
1712 behavior = SOUND_BEHAVIOR_FADING;
1715 g_print("invalid selection(%d), keep going without behavior..\n", behavior);
1716 behavior = SOUND_BEHAVIOR_NONE;
1719 ret = sound_manager_acquire_focus_all(g_stream_info_h, behavior, "sound_manager_test(acquire_focus_all)");
1721 g_print("fail to sound_manager_acquire_focus_all(), ret(0x%x)\n", ret);
1726 case CURRENT_STATUS_RELEASE_FOCUS_ALL: {
1727 int ret = SOUND_MANAGER_ERROR_NONE;
1728 int behavior = atoi(cmd);
1731 case 0: /* without behavior */
1732 behavior = SOUND_BEHAVIOR_NONE;
1734 case 1: /* no-resumption */
1735 behavior = SOUND_BEHAVIOR_NO_RESUME;
1737 case 2: /* fading */
1738 behavior = SOUND_BEHAVIOR_FADING;
1741 g_print("invalid selection(%d), keep going without behavior..\n", behavior);
1742 behavior = SOUND_BEHAVIOR_NONE;
1745 ret = sound_manager_release_focus_all(g_stream_info_h, behavior, "sound_manager_test(release_focus_all)");
1747 g_print("fail to sound_manager_release_focus_all(), ret(0x%x)\n", ret);
1752 case CURRENT_STATUS_DELIVER_FOCUS: {
1753 int ret = SOUND_MANAGER_ERROR_NONE;
1754 sound_stream_focus_mask_e focus_mask;
1755 sound_stream_info_h stream_info_h = NULL;
1756 int focus_type = atoi(cmd);
1758 ret = sound_manager_create_stream_information(SOUND_STREAM_TYPE_MEDIA, focus_callback, NULL, &stream_info_h);
1760 g_print("fail to sound_manager_create_stream_information(), ret(0x%x)\n", ret);
1765 switch (focus_type) {
1766 case 0: /* playback */
1767 focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK;
1769 case 1: /* recording */
1770 focus_mask = SOUND_STREAM_FOCUS_FOR_RECORDING;
1773 focus_mask = SOUND_STREAM_FOCUS_FOR_BOTH;
1776 g_print("invalid selection(%d), keep going with PLAYBACK focus..\n", focus_type);
1777 focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK;
1780 ret = sound_manager_deliver_focus(g_stream_info_h, stream_info_h, focus_mask);
1782 g_print("fail to sound_manager_deliver_focus(), ret(0x%x)\n", ret);
1784 sound_manager_destroy_stream_information(stream_info_h);
1789 case CURRENT_STATUS_GET_ACQUIRED_FOCUS: {
1790 sound_stream_focus_state_e for_playback;
1791 sound_stream_focus_state_e for_recording;
1792 int ret = SOUND_MANAGER_ERROR_NONE;
1793 if (g_stream_info_h) {
1794 ret = sound_manager_get_focus_state(g_stream_info_h, &for_playback, &for_recording);
1796 g_print("fail to sound_manager_get_focus_state(), ret(0x%x)\n", ret);
1798 g_print("focus_state(playback:%d, capture:%d)\n", for_playback, for_recording);
1801 g_print("please create stream info. first\n");
1806 case CURRENT_STATUS_GET_SOUND_TYPE: {
1807 int ret = SOUND_MANAGER_ERROR_NONE;
1808 sound_type_e sound_type;
1809 if (g_stream_info_h) {
1810 ret = sound_manager_get_sound_type(g_stream_info_h, &sound_type);
1812 g_print("fail to sound_manager_get_sound_type(), ret(0x%x)\n", ret);
1814 g_print("sound_type(%d)\n", sound_type);
1817 g_print("please create stream info. first\n");
1822 case CURRENT_STATUS_DESTROY_STREAM_INFO: {
1823 int ret = SOUND_MANAGER_ERROR_NONE;
1824 ret = sound_manager_destroy_stream_information(g_stream_info_h);
1826 g_print("fail to sound_manager_destroy_stream_information(), ret(0x%x)\n", ret);
1828 g_stream_info_h = NULL;
1833 case CURRENT_STATUS_ADD_FOCUS_WATCH_CB: {
1834 int ret = SOUND_MANAGER_ERROR_NONE;
1836 sound_stream_focus_mask_e focus_mask;
1839 focus_type = atoi(cmd);
1840 switch (focus_type) {
1841 case 0: /* playback */
1842 focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK;
1844 case 1: /* recording */
1845 focus_mask = SOUND_STREAM_FOCUS_FOR_RECORDING;
1848 focus_mask = SOUND_STREAM_FOCUS_FOR_BOTH;
1851 focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK;
1854 ret = sound_manager_add_focus_state_watch_cb(focus_mask, focus_watch_callback, NULL, &id);
1856 g_print("fail to sound_manager_add_focus_state_watch_cb(), ret(0x%x)\n", ret);
1858 g_print("id: %d\n", id);
1863 case CURRENT_STATUS_REMOVE_FOCUS_WATCH_CB: {
1864 int ret = SOUND_MANAGER_ERROR_NONE;
1868 ret = sound_manager_remove_focus_state_watch_cb(id);
1870 g_print("fail to sound_manager_remove_focus_state_watch_cb(%d), ret(0x%x)\n", id, ret);
1874 case CURRENT_STATUS_SET_FOCUS_REACQUISITION: {
1875 int ret = SOUND_MANAGER_ERROR_NONE;
1878 switch (atoi(cmd)) {
1879 case 1: /* enable */
1882 case 2: /* disable */
1889 ret = sound_manager_set_focus_reacquisition(g_stream_info_h, enable);
1891 g_print("fail to sound_manager_set_focus_reacquisition, ret(0x%x)\n", ret);
1895 case CURRENT_STATUS_GET_FOCUS_REACQUISITION: {
1896 int ret = SOUND_MANAGER_ERROR_NONE;
1899 ret = sound_manager_get_focus_reacquisition(g_stream_info_h, &enabled);
1901 g_print("fail to sound_manager_get_focus_reacquisition, ret(0x%x)\n", ret);
1903 g_print("auto focus reacquisition is enabled\n");
1905 g_print("auto focus reacquisition is disabled\n");
1909 case CURRENT_STATUS_GET_REASON_FOR_P_FOCUS: {
1910 int ret = SOUND_MANAGER_ERROR_NONE;
1911 char *extra_info = NULL;
1912 sound_stream_focus_change_reason_e reason;
1915 ret = sound_manager_get_current_playback_focus(&reason, &sound_behavior, &extra_info);
1917 g_print("fail to sound_manager_get_current_playback_focus, ret(0x%x)\n", ret);
1919 g_print("reason(%d), sound_behavior(0x%x, 0x0:none 0x1:no_resume 0x2:fading), extra_info(%s)\n", reason, sound_behavior, extra_info);
1925 case CURRENT_STATUS_GET_REASON_FOR_R_FOCUS: {
1926 int ret = SOUND_MANAGER_ERROR_NONE;
1927 char *extra_info = NULL;
1928 sound_stream_focus_change_reason_e reason;
1931 ret = sound_manager_get_current_recording_focus(&reason, &sound_behavior, &extra_info);
1933 g_print("fail to sound_manager_get_current_recording_focus, ret(0x%x)\n", ret);
1935 g_print("reason(%d), sound_behavior(0x%x, 0x0:none 0x1:no_resume 0x2:fading), extra_info(%s)\n", reason, sound_behavior, extra_info);
1941 case CURRENT_STATUS_GET_CURRENT_MEDIA_PLAYBACK_DEVICE_TYPE: {
1942 int ret = SOUND_MANAGER_ERROR_NONE;
1943 sound_device_type_e device_type;
1945 ret = sound_manager_get_current_media_playback_device_type(&device_type);
1947 g_print("fail to sound_manager_get_current_media_playback_device_type, ret(0x%x)\n", ret);
1949 g_print("device_type(%d)\n", device_type);
1954 case CURRENT_STATUS_CREATE_VIRTUAL_STREAM: {
1955 int ret = SOUND_MANAGER_ERROR_NONE;
1956 if (!g_stream_info_h || g_vstream_h) {
1957 g_print("fail to create virtual stream, g_stream_info_h(%p)/g_vstream_h(%p)\n", g_stream_info_h, g_vstream_h);
1961 ret = sound_manager_create_virtual_stream(g_stream_info_h, &g_vstream_h);
1963 g_print("fail to sound_manager_create_virtual_stream(), ret(0x%x)\n", ret);
1965 g_print("success to sound_manager_create_virtual_stream(), ret(0x%x)\n", ret);
1970 case CURRENT_STATUS_START_VIRTUAL_STREAM: {
1971 int ret = SOUND_MANAGER_ERROR_NONE;
1973 ret = sound_manager_start_virtual_stream(g_vstream_h);
1975 g_print("fail to sound_manager_start_virtual_stream(), ret(0x%x)\n", ret);
1977 g_print("success to sound_manager_start_virtual_stream(), ret(0x%x)\n", ret);
1982 case CURRENT_STATUS_STOP_VIRTUAL_STREAM: {
1983 int ret = SOUND_MANAGER_ERROR_NONE;
1985 ret = sound_manager_stop_virtual_stream(g_vstream_h);
1987 g_print("fail to sound_manager_stop_virtual_stream(), ret(0x%x)\n", ret);
1989 g_print("success to sound_manager_stop_virtual_stream(), ret(0x%x)\n", ret);
1994 case CURRENT_STATUS_DESTROY_VIRTUAL_STREAM: {
1995 int ret = SOUND_MANAGER_ERROR_NONE;
1997 ret = sound_manager_destroy_virtual_stream(g_vstream_h);
1999 g_print("fail to sound_manager_destroy_virtual_stream(), ret(0x%x)\n", ret);
2001 g_print("success to sound_manager_destroy_virtual_stream(), ret(0x%x)\n", ret);
2007 case CURRENT_STATUS_SET_FILTER: {
2008 int ret = SOUND_MANAGER_ERROR_NONE;
2009 sound_filter_e filter;
2010 int selection = atoi(cmd);
2011 switch (selection) {
2012 case 0: /* low pass filter */
2013 filter = SOUND_FILTER_LOW_PASS;
2015 case 1: /* high pass filter */
2016 filter = SOUND_FILTER_HIGH_PASS;
2019 filter = SOUND_FILTER_DELAY;
2021 case 3: /* soundAlive */
2022 filter = SOUND_FILTER_SOUNDALIVE;
2025 filter = SOUND_FILTER_DELAY;
2026 g_print("invalid selection(%d), keep going with filter(%d)\n", selection, filter);
2030 ret = sound_manager_set_filter(SOUND_STREAM_TYPE_MEDIA, filter);
2032 g_print("fail to sound_manager_set_filter(), ret(0x%x)\n", ret);
2034 g_print("success to sound_manager_set_filter(), ret(0x%x)\n", ret);
2039 case CURRENT_STATUS_SET_FILTER_PRESET: {
2040 int ret = SOUND_MANAGER_ERROR_NONE;
2041 sound_filter_e filter;
2042 sound_filter_preset_e preset;
2043 int selection = atoi(cmd);
2045 switch (selection) {
2046 case 0: /* low pass under none */
2047 filter = SOUND_FILTER_LOW_PASS;
2048 preset = SOUND_FILTER_PRESET_LOW_PASS_NONE;
2050 case 1: /* low pass under 240hz */
2051 filter = SOUND_FILTER_LOW_PASS;
2052 preset = SOUND_FILTER_PRESET_LOW_PASS_UNDER_240HZ;
2054 case 2: /* low pass under 480hz */
2055 filter = SOUND_FILTER_LOW_PASS;
2056 preset = SOUND_FILTER_PRESET_LOW_PASS_UNDER_480HZ;
2058 case 3: /* high pass over none */
2059 filter = SOUND_FILTER_HIGH_PASS;
2060 preset = SOUND_FILTER_PRESET_HIGH_PASS_NONE;
2062 case 4: /* high pass over 240hz */
2063 filter = SOUND_FILTER_HIGH_PASS;
2064 preset = SOUND_FILTER_PRESET_HIGH_PASS_OVER_240HZ;
2066 case 5: /* high pass over 480hz */
2067 filter = SOUND_FILTER_HIGH_PASS;
2068 preset = SOUND_FILTER_PRESET_HIGH_PASS_OVER_480HZ;
2070 case 6: /* delay none */
2071 filter = SOUND_FILTER_DELAY;
2072 preset = SOUND_FILTER_PRESET_DELAY_NONE;
2074 case 7: /* delay 1 sec */
2075 filter = SOUND_FILTER_DELAY;
2076 preset = SOUND_FILTER_PRESET_DELAY_1SEC;
2078 case 8: /* delay 2 sec */
2079 filter = SOUND_FILTER_DELAY;
2080 preset = SOUND_FILTER_PRESET_DELAY_2SEC;
2082 case 9: /* soundAlive concert normal */
2083 filter = SOUND_FILTER_SOUNDALIVE;
2084 preset = SOUND_FILTER_PRESET_SOUNDALIVE_NORMAL;
2086 case 10: /* soundAlive concert hall */
2087 filter = SOUND_FILTER_SOUNDALIVE;
2088 preset = SOUND_FILTER_PRESET_SOUNDALIVE_CONCERT_HALL;
2091 filter = SOUND_FILTER_DELAY;
2092 preset = SOUND_FILTER_PRESET_DELAY_NONE;
2093 g_print("invalid selection(%d), keep going with filter(%d), preset(%d)\n", selection, filter, preset);
2097 ret = sound_manager_set_filter_preset(SOUND_STREAM_TYPE_MEDIA, filter, preset);
2099 g_print("fail to sound_manager_set_filter_preset(), ret(0x%x)\n", ret);
2101 g_print("success to sound_manager_set_filter_preset(), ret(0x%x)\n", ret);
2106 case CURRENT_STATUS_UNSET_FILTER: {
2107 int ret = SOUND_MANAGER_ERROR_NONE;
2108 ret = sound_manager_unset_filter(SOUND_STREAM_TYPE_MEDIA);
2110 g_print("fail to sound_manager_unset_filter(), ret(0x%x)\n", ret);
2112 g_print("success to sound_manager_unset_filter(), ret(0x%x)\n", ret);
2116 #ifndef TIZEN_FEATURE_TV_PROD
2117 case CURRENT_STATUS_GET_MAX_MASTER_VOLUME: {
2119 if (sound_manager_get_max_master_volume(&max_level) != SOUND_MANAGER_ERROR_NONE)
2120 g_print("failed to get max master volume\n");
2122 g_print("the max level of master volume is %d\n", max_level);
2127 case CURRENT_STATUS_SET_MASTER_VOLUME: {
2130 if (sound_manager_set_master_volume(level) != SOUND_MANAGER_ERROR_NONE)
2131 g_print("failed to set master volume(%d)\n", level);
2133 g_print("set master volume success : level(%d)\n", level);
2138 case CURRENT_STATUS_GET_MASTER_VOLUME: {
2140 if (sound_manager_get_master_volume(&level) != SOUND_MANAGER_ERROR_NONE)
2141 g_print("failed to get master volume\n");
2143 g_print("current master volume is : %d\n", level);
2150 g_timeout_add(100, timeout_menu_display, 0);
2153 gboolean input(GIOChannel *channel)
2155 gchar buf[MAX_STRING_LEN];
2157 GError *error = NULL;
2159 g_io_channel_read_chars(channel, buf, MAX_STRING_LEN - 1, &read, &error);
2167 /* it will be removed when session features are deprecated. */
2168 void signal_callback(mm_sound_signal_name_t signal, int value, void *user_data)
2170 g_print("*** signal callback is called: signal(%d), value(%d), user_data(%p)\n", signal, value, user_data);
2173 int main(int argc, char *argv[])
2175 unsigned int subscribe_id = 0;
2176 int ret = MM_ERROR_NONE;
2177 GIOChannel *stdin_channel;
2178 stdin_channel = g_io_channel_unix_new(0);
2179 g_io_channel_set_flags(stdin_channel, G_IO_FLAG_NONBLOCK, NULL);
2180 g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc)input, NULL);
2181 g_loop = g_main_loop_new(NULL, 1);
2183 /* subscribe a signal for convering session-focus */
2184 /* it will be removed when session features are deprecated. */
2185 if ((ret = mm_sound_subscribe_signal(MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, &subscribe_id, signal_callback, NULL)))
2186 g_print("failed to subscribe signal, ret(0x%x)\n", ret);
2189 g_main_loop_run(g_loop);
2191 /* it will be removed when session features are deprecated. */
2193 mm_sound_unsubscribe_signal(subscribe_id);