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";
33 CURRENT_STATUS_MAINMENU,
34 CURRENT_STATUS_GET_MAX_VOLUME,
35 CURRENT_STATUS_SET_VOLUME,
36 CURRENT_STATUS_GET_VOLUME,
37 CURRENT_STATUS_GET_CURRENT_SOUND_TYPE,
38 CURRENT_STATUS_SET_MUTE,
39 CURRENT_STATUS_GET_MUTE,
40 CURRENT_STATUS_ADD_VOLUME_CHANGED_CB,
41 CURRENT_STATUS_REMOVE_VOLUME_CHANGED_CB,
42 CURRENT_STATUS_SET_DEVICE_MASK,
43 CURRENT_STATUS_GET_DEVICE_MASK,
44 CURRENT_STATUS_PRINT_DEVICE_LIST,
45 CURRENT_STATUS_GET_DEVICE_LIST,
46 CURRENT_STATUS_FREE_DEVICE_LIST,
47 CURRENT_STATUS_GET_DEVICE_NEXT,
48 CURRENT_STATUS_GET_DEVICE_PREV,
49 CURRENT_STATUS_GET_DEVICE_STATE_BY_ID,
50 CURRENT_STATUS_GET_SUPPORTED_SAMPLE_FORMATS,
51 CURRENT_STATUS_SET_SAMPLE_FORMAT,
52 CURRENT_STATUS_GET_SAMPLE_FORMAT,
53 CURRENT_STATUS_GET_SUPPORTED_SAMPLE_RATES,
54 CURRENT_STATUS_SET_SAMPLE_RATE,
55 CURRENT_STATUS_GET_SAMPLE_RATE,
56 CURRENT_STATUS_SET_AVOID_RESAMPLING,
57 CURRENT_STATUS_GET_AVOID_RESAMPLING,
58 CURRENT_STATUS_SET_MEDIA_STREAM_ONLY,
59 CURRENT_STATUS_GET_MEDIA_STREAM_ONLY,
60 CURRENT_STATUS_ADD_DEVICE_CONNECTION_CHANGED_CB,
61 CURRENT_STATUS_REMOVE_DEVICE_CONNECTION_CHANGED_CB,
62 CURRENT_STATUS_ADD_DEVICE_RUNNING_CHANGED_CB,
63 CURRENT_STATUS_REMOVE_DEVICE_RUNNING_CHANGED_CB,
64 CURRENT_STATUS_CREATE_STREAM_INFO,
65 CURRENT_STATUS_ADD_DEVICE_FOR_STREAM_ROUTING,
66 CURRENT_STATUS_REMOVE_DEVICE_FOR_STREAM_ROUTING,
67 CURRENT_STATUS_REMOVE_ALL_DEVICES_FOR_STREAM_ROUTING,
68 CURRENT_STATUS_ADD_DEVICE_ID_FOR_STREAM_ROUTING,
69 CURRENT_STATUS_REMOVE_DEVICE_ID_FOR_STREAM_ROUTING,
70 CURRENT_STATUS_APPLY_STREAM_ROUTING,
71 CURRENT_STATUS_SET_STREAM_ROUTING_OPTION,
72 CURRENT_STATUS_ACQUIRE_FOCUS,
73 CURRENT_STATUS_RELEASE_FOCUS,
74 CURRENT_STATUS_ACQUIRE_FOCUS_ALL,
75 CURRENT_STATUS_RELEASE_FOCUS_ALL,
76 CURRENT_STATUS_GET_ACQUIRED_FOCUS,
77 CURRENT_STATUS_GET_SOUND_TYPE,
78 CURRENT_STATUS_DELIVER_FOCUS,
79 CURRENT_STATUS_DESTROY_STREAM_INFO,
80 CURRENT_STATUS_ADD_FOCUS_WATCH_CB,
81 CURRENT_STATUS_REMOVE_FOCUS_WATCH_CB,
82 CURRENT_STATUS_SET_FOCUS_REACQUISITION,
83 CURRENT_STATUS_GET_FOCUS_REACQUISITION,
84 CURRENT_STATUS_GET_REASON_FOR_P_FOCUS,
85 CURRENT_STATUS_GET_REASON_FOR_R_FOCUS,
86 CURRENT_STATUS_GET_CURRENT_MEDIA_PLAYBACK_DEVICE_TYPE,
87 CURRENT_STATUS_CREATE_VIRTUAL_STREAM,
88 CURRENT_STATUS_START_VIRTUAL_STREAM,
89 CURRENT_STATUS_STOP_VIRTUAL_STREAM,
90 CURRENT_STATUS_DESTROY_VIRTUAL_STREAM,
91 CURRENT_STATUS_SET_VIRTUAL_STREAM_VOLUME,
92 CURRENT_STATUS_SET_FILTER,
93 CURRENT_STATUS_SET_FILTER_PRESET,
94 CURRENT_STATUS_UNSET_FILTER,
95 CURRENT_STATUS_IS_STREAM_ON_DEVICE_BY_ID,
96 #ifndef TIZEN_FEATURE_TV_PROD
97 CURRENT_STATUS_GET_MAX_MASTER_VOLUME,
98 CURRENT_STATUS_SET_MASTER_VOLUME,
99 CURRENT_STATUS_GET_MASTER_VOLUME,
100 CURRENT_STATUS_SET_ACM_MASTER_MODE,
102 CURRENT_STATUS_CREATE_STREAM_DUCKING,
103 CURRENT_STATUS_DESTROY_STREAM_DUCKING,
104 CURRENT_STATUS_ACTIVATE_DUCKING,
105 CURRENT_STATUS_DEACTIVATE_DUCKING,
106 CURRENT_STATUS_GET_DUCKING_STATE,
110 static int g_menu_state = CURRENT_STATUS_MAINMENU;
113 sound_device_list_h g_device_list = NULL;
114 sound_device_h g_device = NULL;
115 sound_device_mask_e g_device_mask = SOUND_DEVICE_ALL_MASK;
116 sound_stream_info_h g_stream_info_h = NULL;
117 virtual_sound_stream_h g_vstream_h = NULL;
118 sound_stream_ducking_h g_stream_ducking_h = NULL;
120 int g_device_conn_cb_id;
121 int g_device_state_cb_id;
122 int g_device_running_cb_id;
124 static const char *g_device_direction_str[] = {"IN", "OUT", "BOTH"};
125 static const char *g_device_state_str[] = {"De-Activated", "Activated"};
127 void focus_callback(sound_stream_info_h stream_info,
128 sound_stream_focus_mask_e focus_mask,
129 sound_stream_focus_state_e focus_state,
130 sound_stream_focus_change_reason_e reason,
132 const char *extra_info,
135 int ret = SOUND_MANAGER_ERROR_NONE;
136 sound_stream_focus_state_e playback_focus_state;
137 sound_stream_focus_state_e recording_focus_state;
139 g_print("\n*** FOCUS callback is called, stream_info(%p) ***\n", stream_info);
141 g_print(" - changed focus: mask(%x), state(%d) (0:released, 1:acquired)\n", focus_mask, focus_state);
142 g_print(" - change_reason(%d), behavior(0x%x), extra_info(%s), user_data(%p)\n", reason, sound_behavior, extra_info, user_data);
144 ret = sound_manager_get_focus_state(stream_info, &playback_focus_state, &recording_focus_state);
146 g_print(" - focus_state : PLAYBACK(%d), RECORDING(%d) (0:released, 1:acquired)\n", playback_focus_state, recording_focus_state);
148 g_print("*** FOCUS callback is ended, stream_info(%p) ****\n\n", stream_info);
150 #if 0 /* test for complicated scenario */
151 if (focus_state == SOUND_STREAM_FOCUS_STATE_RELEASED && recording_focus_state == SOUND_STREAM_FOCUS_STATE_ACQUIRED) {
152 g_print("### try to acquire playback focus now..\n");
153 ret = sound_manager_acquire_focus(stream_info, SOUND_STREAM_FOCUS_FOR_PLAYBACK, SOUND_BEHAVIOR_NONE, "in callback thread");
155 g_print("failed to acquire focus..ret:0x%x\n", ret);
156 g_print("### try to release recording focus now..\n");
157 ret = sound_manager_release_focus(stream_info, SOUND_STREAM_FOCUS_FOR_RECORDING, SOUND_BEHAVIOR_NONE, "in callback thread");
159 g_print("failed to release focus..ret:0x%x\n", ret);
162 if (focus_state == SOUND_STREAM_FOCUS_STATE_ACQUIRED && playback_focus_state == SOUND_STREAM_FOCUS_STATE_ACQUIRED) {
163 g_print("### try to release playback focus now..\n");
164 ret = sound_manager_release_focus(stream_info, SOUND_STREAM_FOCUS_FOR_PLAYBACK, SOUND_BEHAVIOR_NONE, "in callback thread");
166 g_print("failed to release focus..ret:0x%x\n", ret);
167 g_print("### try to acquire recording focus now..\n");
168 ret = sound_manager_acquire_focus(stream_info, SOUND_STREAM_FOCUS_FOR_RECORDING, SOUND_BEHAVIOR_NONE, "in callback thread");
170 g_print("failed to acquire focus..ret:0x%x\n", ret);
177 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)
179 g_print("\n*** FOCUS WATCH callback is called, id(%d) ***\n", id);
180 g_print(" - changed_focus_mask(%d), changed_focus_state(%d), change_reason(%d), extra_info(%s), user_data(%p)\n",
181 focus_mask, focus_state, reason, extra_info, user_data);
186 void ducking_state_changed_cb(sound_stream_ducking_h stream_ducking, bool is_ducked, void *user_data)
188 g_print("stream_ducking %p, is_ducked %u\n", stream_ducking, is_ducked);
195 g_main_loop_quit(g_loop);
198 void _interpret_main_menu(char *cmd)
200 if (strncmp(cmd, "gx", MAX_CMD_LEN) == 0)
201 g_menu_state = CURRENT_STATUS_GET_MAX_VOLUME;
202 else if (strncmp(cmd, "sv", MAX_CMD_LEN) == 0)
203 g_menu_state = CURRENT_STATUS_SET_VOLUME;
204 else if (strncmp(cmd, "gv", MAX_CMD_LEN) == 0)
205 g_menu_state = CURRENT_STATUS_GET_VOLUME;
206 else if (strncmp(cmd, "gt", MAX_CMD_LEN) == 0)
207 g_menu_state = CURRENT_STATUS_GET_CURRENT_SOUND_TYPE;
208 else if (strncmp(cmd, "av", MAX_CMD_LEN) == 0)
209 g_menu_state = CURRENT_STATUS_ADD_VOLUME_CHANGED_CB;
210 else if (strncmp(cmd, "rv", MAX_CMD_LEN) == 0)
211 g_menu_state = CURRENT_STATUS_REMOVE_VOLUME_CHANGED_CB;
212 else if (strncmp(cmd, "sm", MAX_CMD_LEN) == 0)
213 g_menu_state = CURRENT_STATUS_SET_MUTE;
214 else if (strncmp(cmd, "gm", MAX_CMD_LEN) == 0)
215 g_menu_state = CURRENT_STATUS_GET_MUTE;
216 else if (strncmp(cmd, "sk", MAX_CMD_LEN) == 0)
217 g_menu_state = CURRENT_STATUS_SET_DEVICE_MASK;
218 else if (strncmp(cmd, "gk", MAX_CMD_LEN) == 0)
219 g_menu_state = CURRENT_STATUS_GET_DEVICE_MASK;
220 else if (strncmp(cmd, "gl", MAX_CMD_LEN) == 0)
221 g_menu_state = CURRENT_STATUS_GET_DEVICE_LIST;
222 else if (strncmp(cmd, "pl", MAX_CMD_LEN) == 0)
223 g_menu_state = CURRENT_STATUS_PRINT_DEVICE_LIST;
224 else if (strncmp(cmd, "fl", MAX_CMD_LEN) == 0)
225 g_menu_state = CURRENT_STATUS_FREE_DEVICE_LIST;
226 else if (strncmp(cmd, "gn", MAX_CMD_LEN) == 0)
227 g_menu_state = CURRENT_STATUS_GET_DEVICE_NEXT;
228 else if (strncmp(cmd, "gp", MAX_CMD_LEN) == 0)
229 g_menu_state = CURRENT_STATUS_GET_DEVICE_PREV;
230 else if (strncmp(cmd, "gd", MAX_CMD_LEN) == 0)
231 g_menu_state = CURRENT_STATUS_GET_DEVICE_STATE_BY_ID;
232 else if (strncmp(cmd, "gssf", MAX_CMD_LEN) == 0)
233 g_menu_state = CURRENT_STATUS_GET_SUPPORTED_SAMPLE_FORMATS;
234 else if (strncmp(cmd, "ssf", MAX_CMD_LEN) == 0)
235 g_menu_state = CURRENT_STATUS_SET_SAMPLE_FORMAT;
236 else if (strncmp(cmd, "gsf", MAX_CMD_LEN) == 0)
237 g_menu_state = CURRENT_STATUS_GET_SAMPLE_FORMAT;
238 else if (strncmp(cmd, "gssr", MAX_CMD_LEN) == 0)
239 g_menu_state = CURRENT_STATUS_GET_SUPPORTED_SAMPLE_RATES;
240 else if (strncmp(cmd, "ssr", MAX_CMD_LEN) == 0)
241 g_menu_state = CURRENT_STATUS_SET_SAMPLE_RATE;
242 else if (strncmp(cmd, "gsr", MAX_CMD_LEN) == 0)
243 g_menu_state = CURRENT_STATUS_GET_SAMPLE_RATE;
244 else if (strncmp(cmd, "sar", MAX_CMD_LEN) == 0)
245 g_menu_state = CURRENT_STATUS_SET_AVOID_RESAMPLING;
246 else if (strncmp(cmd, "gar", MAX_CMD_LEN) == 0)
247 g_menu_state = CURRENT_STATUS_GET_AVOID_RESAMPLING;
248 else if (strncmp(cmd, "sms", MAX_CMD_LEN) == 0)
249 g_menu_state = CURRENT_STATUS_SET_MEDIA_STREAM_ONLY;
250 else if (strncmp(cmd, "gms", MAX_CMD_LEN) == 0)
251 g_menu_state = CURRENT_STATUS_GET_MEDIA_STREAM_ONLY;
252 else if (strncmp(cmd, "adcc", MAX_CMD_LEN) == 0)
253 g_menu_state = CURRENT_STATUS_ADD_DEVICE_CONNECTION_CHANGED_CB;
254 else if (strncmp(cmd, "rdcc", MAX_CMD_LEN) == 0)
255 g_menu_state = CURRENT_STATUS_REMOVE_DEVICE_CONNECTION_CHANGED_CB;
256 else if (strncmp(cmd, "adrc", MAX_CMD_LEN) == 0)
257 g_menu_state = CURRENT_STATUS_ADD_DEVICE_RUNNING_CHANGED_CB;
258 else if (strncmp(cmd, "rdrc", MAX_CMD_LEN) == 0)
259 g_menu_state = CURRENT_STATUS_REMOVE_DEVICE_RUNNING_CHANGED_CB;
260 else if (strncmp(cmd, "csi", MAX_CMD_LEN) == 0)
261 g_menu_state = CURRENT_STATUS_CREATE_STREAM_INFO;
262 else if (strncmp(cmd, "ads", MAX_CMD_LEN) == 0)
263 g_menu_state = CURRENT_STATUS_ADD_DEVICE_FOR_STREAM_ROUTING;
264 else if (strncmp(cmd, "rds", MAX_CMD_LEN) == 0)
265 g_menu_state = CURRENT_STATUS_REMOVE_DEVICE_FOR_STREAM_ROUTING;
266 else if (strncmp(cmd, "rad", MAX_CMD_LEN) == 0)
267 g_menu_state = CURRENT_STATUS_REMOVE_ALL_DEVICES_FOR_STREAM_ROUTING;
268 else if (strncmp(cmd, "adi", MAX_CMD_LEN) == 0)
269 g_menu_state = CURRENT_STATUS_ADD_DEVICE_ID_FOR_STREAM_ROUTING;
270 else if (strncmp(cmd, "rdi", MAX_CMD_LEN) == 0)
271 g_menu_state = CURRENT_STATUS_REMOVE_DEVICE_ID_FOR_STREAM_ROUTING;
272 else if (strncmp(cmd, "aps", MAX_CMD_LEN) == 0)
273 g_menu_state = CURRENT_STATUS_APPLY_STREAM_ROUTING;
274 else if (strncmp(cmd, "sso", MAX_CMD_LEN) == 0)
275 g_menu_state = CURRENT_STATUS_SET_STREAM_ROUTING_OPTION;
276 else if (strncmp(cmd, "afc", MAX_CMD_LEN) == 0)
277 g_menu_state = CURRENT_STATUS_ACQUIRE_FOCUS;
278 else if (strncmp(cmd, "rfc", MAX_CMD_LEN) == 0)
279 g_menu_state = CURRENT_STATUS_RELEASE_FOCUS;
280 else if (strncmp(cmd, "afa", MAX_CMD_LEN) == 0)
281 g_menu_state = CURRENT_STATUS_ACQUIRE_FOCUS_ALL;
282 else if (strncmp(cmd, "rfa", MAX_CMD_LEN) == 0)
283 g_menu_state = CURRENT_STATUS_RELEASE_FOCUS_ALL;
284 else if (strncmp(cmd, "gfs", MAX_CMD_LEN) == 0)
285 g_menu_state = CURRENT_STATUS_GET_ACQUIRED_FOCUS;
286 else if (strncmp(cmd, "gst", MAX_CMD_LEN) == 0)
287 g_menu_state = CURRENT_STATUS_GET_SOUND_TYPE;
288 else if (strncmp(cmd, "dfc", MAX_CMD_LEN) == 0)
289 g_menu_state = CURRENT_STATUS_DELIVER_FOCUS;
290 else if (strncmp(cmd, "afw", MAX_CMD_LEN) == 0)
291 g_menu_state = CURRENT_STATUS_ADD_FOCUS_WATCH_CB;
292 else if (strncmp(cmd, "rfw", MAX_CMD_LEN) == 0)
293 g_menu_state = CURRENT_STATUS_REMOVE_FOCUS_WATCH_CB;
294 else if (strncmp(cmd, "sfr", MAX_CMD_LEN) == 0)
295 g_menu_state = CURRENT_STATUS_SET_FOCUS_REACQUISITION;
296 else if (strncmp(cmd, "gfr", MAX_CMD_LEN) == 0)
297 g_menu_state = CURRENT_STATUS_GET_FOCUS_REACQUISITION;
298 else if (strncmp(cmd, "grp", MAX_CMD_LEN) == 0)
299 g_menu_state = CURRENT_STATUS_GET_REASON_FOR_P_FOCUS;
300 else if (strncmp(cmd, "grr", MAX_CMD_LEN) == 0)
301 g_menu_state = CURRENT_STATUS_GET_REASON_FOR_R_FOCUS;
302 else if (strncmp(cmd, "gmp", MAX_CMD_LEN) == 0)
303 g_menu_state = CURRENT_STATUS_GET_CURRENT_MEDIA_PLAYBACK_DEVICE_TYPE;
304 else if (strncmp(cmd, "dsi", MAX_CMD_LEN) == 0)
305 g_menu_state = CURRENT_STATUS_DESTROY_STREAM_INFO;
306 else if (strncmp(cmd, "vcr", MAX_CMD_LEN) == 0)
307 g_menu_state = CURRENT_STATUS_CREATE_VIRTUAL_STREAM;
308 else if (strncmp(cmd, "vsr", MAX_CMD_LEN) == 0)
309 g_menu_state = CURRENT_STATUS_START_VIRTUAL_STREAM;
310 else if (strncmp(cmd, "vst", MAX_CMD_LEN) == 0)
311 g_menu_state = CURRENT_STATUS_STOP_VIRTUAL_STREAM;
312 else if (strncmp(cmd, "vdt", MAX_CMD_LEN) == 0)
313 g_menu_state = CURRENT_STATUS_DESTROY_VIRTUAL_STREAM;
314 else if (strncmp(cmd, "vsv", MAX_CMD_LEN) == 0)
315 g_menu_state = CURRENT_STATUS_SET_VIRTUAL_STREAM_VOLUME;
316 else if (strncmp(cmd, "sft", MAX_CMD_LEN) == 0)
317 g_menu_state = CURRENT_STATUS_SET_FILTER;
318 else if (strncmp(cmd, "sfp", MAX_CMD_LEN) == 0)
319 g_menu_state = CURRENT_STATUS_SET_FILTER_PRESET;
320 else if (strncmp(cmd, "uft", MAX_CMD_LEN) == 0)
321 g_menu_state = CURRENT_STATUS_UNSET_FILTER;
322 else if (strncmp(cmd, "isd", MAX_CMD_LEN) == 0)
323 g_menu_state = CURRENT_STATUS_IS_STREAM_ON_DEVICE_BY_ID;
324 #ifndef TIZEN_FEATURE_TV_PROD
325 else if (strncmp(cmd, "mgx", MAX_CMD_LEN) == 0)
326 g_menu_state = CURRENT_STATUS_GET_MAX_MASTER_VOLUME;
327 else if (strncmp(cmd, "msv", MAX_CMD_LEN) == 0)
328 g_menu_state = CURRENT_STATUS_SET_MASTER_VOLUME;
329 else if (strncmp(cmd, "mgv", MAX_CMD_LEN) == 0)
330 g_menu_state = CURRENT_STATUS_GET_MASTER_VOLUME;
331 else if (strncmp(cmd, "acm", MAX_CMD_LEN) == 0)
332 g_menu_state = CURRENT_STATUS_SET_ACM_MASTER_MODE;
334 else if (strncmp(cmd, "csd", MAX_CMD_LEN) == 0)
335 g_menu_state = CURRENT_STATUS_CREATE_STREAM_DUCKING;
336 else if (strncmp(cmd, "dsd", MAX_CMD_LEN) == 0)
337 g_menu_state = CURRENT_STATUS_DESTROY_STREAM_DUCKING;
338 else if (strncmp(cmd, "adk", MAX_CMD_LEN) == 0)
339 g_menu_state = CURRENT_STATUS_ACTIVATE_DUCKING;
340 else if (strncmp(cmd, "ddk", MAX_CMD_LEN) == 0)
341 g_menu_state = CURRENT_STATUS_DEACTIVATE_DUCKING;
342 else if (strncmp(cmd, "gds", MAX_CMD_LEN) == 0)
343 g_menu_state = CURRENT_STATUS_GET_DUCKING_STATE;
344 else if (strncmp(cmd, "q", MAX_CMD_LEN) == 0) {
345 g_print("closing the test suite\n");
348 g_print("unknown menu \n");
351 void display_sub_basic()
354 g_print("=========================================================================================\n");
355 g_print(" Sound Manager Test (press q to quit) \n");
356 g_print("-----------------------------------------------------------------------------------------\n");
357 g_print(" VOLUME MODULE \n");
358 g_print("-----------------------------------------------------------------------------------------\n");
359 g_print("gx. Get Max Volume \t");
360 g_print("gv. Get Volume \t");
361 g_print("sv. Set Volume \n");
362 g_print("gt. Get Current Sound Type \t");
363 g_print("gm. *Get Mute \t");
364 g_print("sm. *Set Mute \n");
365 g_print("av. Add Volume Changed CB \t");
366 g_print("rv. Remove Volume Changed CB \n");
367 #ifndef TIZEN_FEATURE_TV_PROD
368 g_print("mgx. *Get Max Master Volume \t");
369 g_print("mgv. *Get Master Volume \t");
370 g_print("msv. *Set Master Volume \n");
372 g_print("csd. Create Stream Ducking\t");
373 g_print("dsd. Destroy Stream Ducking\n");
374 g_print("adk. Activate Ducking\t\t");
375 g_print("ddk. Deactivate Ducking\n");
376 g_print("gds. Get Ducking State\n");
377 g_print("-----------------------------------------------------------------------------------------\n");
378 g_print(" DEVICE MODULE \n");
379 g_print("-----------------------------------------------------------------------------------------\n");
380 g_print("sk. Set Devices Mask(default ALL)\t");
381 g_print("gk. Get Devices Mask\n");
382 g_print("pl. Print Devices List\t");
383 g_print("gl. Get Devices List\t");
384 g_print("fl. Free Devices List\n");
385 g_print("gn. Get Next Device\t\t");
386 g_print("gp. Get Prev Device\n");
387 g_print("gd. *Get Device State by Id\n");
388 g_print("gssf. Get Supported Sample Formats\t");
389 g_print("gssr. Get Supported Sample Rates\n");
390 g_print("ssf. Set Sample Format\t");
391 g_print("ssr. Set Sample Rate\n");
392 g_print("gsf. Get Sample Format\t");
393 g_print("gsr. Get Sample Rate\n");
394 g_print("sar. Set Avoid Resampling\t");
395 g_print("sms. Set Media Stream Only\n");
396 g_print("gar. Get Avoid Resampling\t");
397 g_print("gms. Get Media Stream Only\n");
398 g_print("adcc. Add Device Connenection Changed CB\t\t");
399 g_print("rdcc. Remove Device Connenection Changed CB\n");
400 g_print("adrc. Add Device Running Changed CB\t\t");
401 g_print("rdrc. Remove Device Running Changed CB\n");
402 g_print("-----------------------------------------------------------------------------------------\n");
403 g_print(" STREAM POLICY MODULE \n");
404 g_print("-----------------------------------------------------------------------------------------\n");
405 g_print("csi. Create Stream Info\t");
406 g_print("dsi. Destroy Stream Info\n");
407 g_print("gst. Get Sound Type\n");
408 g_print("ads. Add Device for Stream Routing\t");
409 g_print("rds. Remove Device for Stream Routing\n");
410 g_print("adi. *Add Device ID for Stream Routing\t");
411 g_print("rdi. *Remove Device ID for Stream Routing\n");
412 g_print("aps. Apply devices for Stream Routing\t");
413 g_print("rad. Remove all devices for Stream Routing\n");
414 g_print("afc. Acquire Focus\t");
415 g_print("rfc. Release Focus\t");
416 g_print("gfs. Get Focus State\n");
417 g_print("afa. Acquire Focus All\t");
418 g_print("rfa. Release Focus All\t");
419 g_print("dfc. Deliver Focus\n");
420 g_print("afw. Add Focus State Watch CB\t");
421 g_print("rfw. Remove Focus State Watch CB\n");
422 g_print("sfr. Set Focus Reacquisition\t");
423 g_print("gfr. Get Focus Reacquisition\n");
424 g_print("grp. Get Reason for Current Acquired Playback Focus\t");
425 g_print("grr. Get Reason for Current Acquired Recording Focus\n");
426 g_print("gmp. Get Current Media Playback Routing Path\n");
427 g_print("sso. *Set option for stream routing\n");
428 g_print("vcr. *Create VStream\t");
429 g_print("vsr. *Start VStream\t");
430 g_print("vsv. *Set VStream Volume\n");
431 g_print("vdt. *Destroy VStream\t");
432 g_print("vst. *Stop VStream\n");
433 g_print("sft. *Set Filter\t");
434 g_print("sfp. *Set Filter Preset\t");
435 g_print("uft. *Unset Filter\n");
436 g_print("isd. *Is Stream on Device by ID\n");
437 #ifndef TIZEN_FEATURE_TV_PROD
438 g_print("acm. *Set ACM Master mode\n");
440 g_print(" * is for internal usage.\n");
441 g_print("=========================================================================================\n");
444 static void displaymenu()
447 if (g_menu_state == CURRENT_STATUS_MAINMENU) {
450 } else if (g_menu_state == CURRENT_STATUS_GET_MAX_VOLUME)
451 g_print("*** input sound type(0:SYSTEM 1:NOTIFICATION 2:ALARM 3:RINGTONE 4:MEDIA 5:CALL 6:VOIP 7:VOICE)\n");
452 else if (g_menu_state == CURRENT_STATUS_SET_VOLUME) {
454 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");
456 } else if (g_menu_state == CURRENT_STATUS_GET_VOLUME)
457 g_print("*** input sound type(0:SYSTEM 1:NOTIFICATION 2:ALARM 3:RINGTONE 4:MEDIA 5:CALL 6:VOIP 7:VOICE)\n");
458 else if (g_menu_state == CURRENT_STATUS_GET_CURRENT_SOUND_TYPE)
459 g_print("*** press enter to get current sound type\n");
460 else if (g_menu_state == CURRENT_STATUS_SET_MUTE) {
462 g_print("*** input sound type and desired mute state(0:SYSTEM 1:NOTIFICATION 2:ALARM 3:RINGTONE 4:MEDIA 5:CALL 6:VOIP 7:VOICE, (0:unmute, 1:mute))\n");
464 } else if (g_menu_state == CURRENT_STATUS_GET_MUTE)
465 g_print("*** input sound type(0:SYSTEM 1:NOTIFICATION 2:ALARM 3:RINGTONE 4:MEDIA 5:CALL 6:VOIP 7:VOICE)\n");
466 else if (g_menu_state == CURRENT_STATUS_ADD_VOLUME_CHANGED_CB)
467 g_print("*** press enter to add volume changed cb\n");
468 else if (g_menu_state == CURRENT_STATUS_REMOVE_VOLUME_CHANGED_CB)
469 g_print("*** press enter to remove volume changed cb\n");
470 else if (g_menu_state == CURRENT_STATUS_SET_DEVICE_MASK)
471 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");
472 else if (g_menu_state == CURRENT_STATUS_GET_DEVICE_MASK)
473 g_print("*** press enter to get device mask\n");
474 else if (g_menu_state == CURRENT_STATUS_GET_DEVICE_LIST)
475 g_print("*** press enter to get device list\n");
476 else if (g_menu_state == CURRENT_STATUS_PRINT_DEVICE_LIST)
477 g_print("*** press enter to print device list\n");
478 else if (g_menu_state == CURRENT_STATUS_FREE_DEVICE_LIST)
479 g_print("*** press enter to free device list\n");
480 else if (g_menu_state == CURRENT_STATUS_GET_DEVICE_NEXT)
481 g_print("*** press enter to get next device from the list\n");
482 else if (g_menu_state == CURRENT_STATUS_GET_DEVICE_PREV)
483 g_print("*** press enter to get previous device from the list\n");
484 else if (g_menu_state == CURRENT_STATUS_GET_DEVICE_STATE_BY_ID)
485 g_print("*** press enter device id to get state\n");
486 else if (g_menu_state == CURRENT_STATUS_GET_SUPPORTED_SAMPLE_FORMATS)
487 g_print("*** press enter to get supported sample formats\n");
488 else if (g_menu_state == CURRENT_STATUS_SET_SAMPLE_FORMAT)
489 g_print("*** input sample format (0:u8, 1:s16le, 2:s24le, 3:s24_32le)\n");
490 else if (g_menu_state == CURRENT_STATUS_GET_SAMPLE_FORMAT)
491 g_print("*** press enter to get sample format\n");
492 else if (g_menu_state == CURRENT_STATUS_GET_SUPPORTED_SAMPLE_RATES)
493 g_print("*** press enter to get supported sample rates\n");
494 else if (g_menu_state == CURRENT_STATUS_SET_SAMPLE_RATE)
495 g_print("*** input sample rate (0:8kHz, 1:16KHz, 2:22.05kHz, 3:44.1kHz, 4:48kHz, 5:88.2kHz, 6:96kHz, 7:192kHz)\n");
496 else if (g_menu_state == CURRENT_STATUS_GET_SAMPLE_RATE)
497 g_print("*** press enter to get sample ratet\n");
498 else if (g_menu_state == CURRENT_STATUS_SET_AVOID_RESAMPLING)
499 g_print("*** input avoid resampling (0:disable, 1:enable)\n");
500 else if (g_menu_state == CURRENT_STATUS_GET_AVOID_RESAMPLING)
501 g_print("*** press enter to get avoid resampling\n");
502 else if (g_menu_state == CURRENT_STATUS_SET_MEDIA_STREAM_ONLY)
503 g_print("*** input media stream only (0:disable, 1:enable)\n");
504 else if (g_menu_state == CURRENT_STATUS_GET_MEDIA_STREAM_ONLY)
505 g_print("*** press enter to get media stream only\n");
506 else if (g_menu_state == CURRENT_STATUS_ADD_DEVICE_CONNECTION_CHANGED_CB)
507 g_print("*** press enter to add device connected cb\n");
508 else if (g_menu_state == CURRENT_STATUS_REMOVE_DEVICE_CONNECTION_CHANGED_CB)
509 g_print("*** press enter to remove device connected cb\n");
510 else if (g_menu_state == CURRENT_STATUS_ADD_DEVICE_RUNNING_CHANGED_CB)
511 g_print("*** press enter to add device running changed cb\n");
512 else if (g_menu_state == CURRENT_STATUS_REMOVE_DEVICE_RUNNING_CHANGED_CB)
513 g_print("*** press enter to remove device running changed cb\n");
514 else if (g_menu_state == CURRENT_STATUS_CREATE_STREAM_INFO)
515 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, 12:media-compressed)\n");
516 else if (g_menu_state == CURRENT_STATUS_ADD_DEVICE_FOR_STREAM_ROUTING)
517 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");
518 else if (g_menu_state == CURRENT_STATUS_REMOVE_DEVICE_FOR_STREAM_ROUTING)
519 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");
520 else if (g_menu_state == CURRENT_STATUS_REMOVE_ALL_DEVICES_FOR_STREAM_ROUTING)
521 g_print("*** press enter to remove all devices in stream info\n");
522 else if (g_menu_state == CURRENT_STATUS_ADD_DEVICE_ID_FOR_STREAM_ROUTING)
523 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");
524 else if (g_menu_state == CURRENT_STATUS_REMOVE_DEVICE_ID_FOR_STREAM_ROUTING)
525 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");
526 else if (g_menu_state == CURRENT_STATUS_APPLY_STREAM_ROUTING)
527 g_print("*** press enter to apply devices for stream routing\n");
528 else if (g_menu_state == CURRENT_STATUS_SET_STREAM_ROUTING_OPTION)
529 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");
530 else if (g_menu_state == CURRENT_STATUS_ACQUIRE_FOCUS)
531 g_print("*** input focus type to acquire (0:playback, 1:recording, 2:both, 3:both+noResume, 4:both+fading)\n");
532 else if (g_menu_state == CURRENT_STATUS_RELEASE_FOCUS)
533 g_print("*** input focus type to release (0:playback, 1:recording, 2:both, 3:both+noResume, 4:both+fading)\n");
534 else if (g_menu_state == CURRENT_STATUS_ACQUIRE_FOCUS_ALL)
535 g_print("*** input behavior for acquire all (0:without behavior, 1:with noResume, 2:with fading)\n");
536 else if (g_menu_state == CURRENT_STATUS_RELEASE_FOCUS_ALL)
537 g_print("*** input behavior for release all (0:without behavior, 1:with noResume, 2:with fading)\n");
538 else if (g_menu_state == CURRENT_STATUS_DELIVER_FOCUS)
539 g_print("*** input focus type to deliver (0:playback, 1:recording, 2:both)\n");
540 else if (g_menu_state == CURRENT_STATUS_GET_ACQUIRED_FOCUS)
541 g_print("*** press enter to get focus state\n");
542 else if (g_menu_state == CURRENT_STATUS_GET_SOUND_TYPE)
543 g_print("*** press enter to get sound type\n");
544 else if (g_menu_state == CURRENT_STATUS_DESTROY_STREAM_INFO)
545 g_print("*** press enter to destroy stream information\n");
546 else if (g_menu_state == CURRENT_STATUS_ADD_FOCUS_WATCH_CB)
547 g_print("*** input focus type to watch for (0:playback, 1:recording, 2:both)\n");
548 else if (g_menu_state == CURRENT_STATUS_REMOVE_FOCUS_WATCH_CB)
549 g_print("*** input focus watch callback id to remove\n");
550 else if (g_menu_state == CURRENT_STATUS_SET_FOCUS_REACQUISITION)
551 g_print("*** input focus reacquisition property (0:disable, 1:enable)\n");
552 else if (g_menu_state == CURRENT_STATUS_GET_FOCUS_REACQUISITION)
553 g_print("*** press enter to get focus reacquisition property\n");
554 else if (g_menu_state == CURRENT_STATUS_GET_REASON_FOR_P_FOCUS)
555 g_print("*** press enter to get reason for current playback focus\n");
556 else if (g_menu_state == CURRENT_STATUS_GET_REASON_FOR_R_FOCUS)
557 g_print("*** press enter to get reason for current recording focus\n");
558 else if (g_menu_state == CURRENT_STATUS_GET_CURRENT_MEDIA_PLAYBACK_DEVICE_TYPE)
559 g_print("*** press enter to get current_media_playback_device type\n");
560 else if (g_menu_state == CURRENT_STATUS_CREATE_VIRTUAL_STREAM)
561 g_print("*** press enter to create virtual stream\n");
562 else if (g_menu_state == CURRENT_STATUS_START_VIRTUAL_STREAM)
563 g_print("*** press enter to start virtual stream\n");
564 else if (g_menu_state == CURRENT_STATUS_STOP_VIRTUAL_STREAM)
565 g_print("*** press enter to stop virtual stream\n");
566 else if (g_menu_state == CURRENT_STATUS_DESTROY_VIRTUAL_STREAM)
567 g_print("*** press enter to destroy virtual stream\n");
568 else if (g_menu_state == CURRENT_STATUS_SET_VIRTUAL_STREAM_VOLUME)
569 g_print("*** input volume ratio of virtual stream (Min:0.0 ~ Max:1.0)\n");
570 else if (g_menu_state == CURRENT_STATUS_SET_FILTER)
571 g_print("*** input filter type of media stream (0:LOW_PASS 1:HIGH_PASS 2:DELAY 3:SOUNDALIVE)\n");
572 else if (g_menu_state == CURRENT_STATUS_SET_FILTER_PRESET)
573 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");
574 else if (g_menu_state == CURRENT_STATUS_UNSET_FILTER)
575 g_print("*** press enter to unset filter of media stream\n");
576 else if (g_menu_state == CURRENT_STATUS_IS_STREAM_ON_DEVICE_BY_ID)
577 g_print("*** input device id\n");
578 #ifndef TIZEN_FEATURE_TV_PROD
579 else if (g_menu_state == CURRENT_STATUS_GET_MAX_MASTER_VOLUME)
580 g_print("*** press enter to get max master volume level\n");
581 else if (g_menu_state == CURRENT_STATUS_SET_MASTER_VOLUME)
582 g_print("*** input master volume level\n");
583 else if (g_menu_state == CURRENT_STATUS_GET_MASTER_VOLUME)
584 g_print("*** press enter to get master volume level\n");
585 else if (g_menu_state == CURRENT_STATUS_SET_ACM_MASTER_MODE)
586 g_print("*** input master mode enable or disable (0:disable 1:enable)\n");
588 else if (g_menu_state == CURRENT_STATUS_CREATE_STREAM_DUCKING)
589 g_print("*** input target stream (0:MEDIA 1:SYSTEM 2:ALARM 3:NOTIFICATION 4:EMERGENCY 5:VOICE_INFORMATION 6:VOICE_RECOGNITION 7:RINGTONE_VOIP 8:VOIP 9:MEDIA_EXTERNAL_ONLY\n");
590 else if (g_menu_state == CURRENT_STATUS_DESTROY_STREAM_DUCKING)
591 g_print("*** press enter to destroy stream ducking\n");
592 else if (g_menu_state == CURRENT_STATUS_ACTIVATE_DUCKING) {
594 g_print("*** input duration (0 <= duration <= 3000) and ratio (0.0 < ratio < 1.0)\n");
596 } else if (g_menu_state == CURRENT_STATUS_DEACTIVATE_DUCKING)
597 g_print("*** press enter to deactivate ducking\n");
598 else if (g_menu_state == CURRENT_STATUS_GET_DUCKING_STATE)
599 g_print("*** press enter to get ducking state\n");
601 g_print("*** unknown status.\n");
607 gboolean timeout_menu_display(void* data)
613 int convert_sound_type(sound_type_e *type, char *cmd)
615 int sound_type_n = atoi(cmd);
616 if (SOUND_TYPE_SYSTEM > sound_type_n || sound_type_n > SOUND_TYPE_VOICE) {
617 g_print("not supported sound type(%d)\n", sound_type_n);
620 switch (sound_type_n) {
622 *type = SOUND_TYPE_SYSTEM;
625 *type = SOUND_TYPE_NOTIFICATION;
628 *type = SOUND_TYPE_ALARM;
631 *type = SOUND_TYPE_RINGTONE;
634 *type = SOUND_TYPE_MEDIA;
637 *type = SOUND_TYPE_CALL;
640 *type = SOUND_TYPE_VOIP;
643 *type = SOUND_TYPE_VOICE;
650 void _volume_changed_cb(sound_type_e type, unsigned int volume, void *user_data)
652 g_print("***the volume has changed. the volume of this sound type(%d) is : %d \n", type, volume);
655 /* If failed to get some property, just give some default value */
656 void _get_device_props_simple(sound_device_h device, int *id, char **type, char **name,
657 const char **direc, const char **state, int *vendor_id, int *product_id, bool *is_running)
660 sound_device_type_e _type;
661 sound_device_io_direction_e _direc;
662 sound_device_state_e _state;
669 if ((ret = sound_manager_get_device_type(device, &_type)))
670 g_print("failed to get device type, ret[0x%x]\n", ret);
672 _convert_device_type_enum_to_str(_type, type);
674 if ((ret = sound_manager_get_device_id(device, id)))
675 g_print("failed to get device id, ret[0x%x]\n", ret);
677 if (_type == SOUND_DEVICE_BLUETOOTH_MEDIA || _type == SOUND_DEVICE_BLUETOOTH_VOICE || _type == SOUND_DEVICE_USB_AUDIO) {
678 if ((ret = sound_manager_get_device_name(device, name))) {
679 g_print("failed to get device name, ret[0x%x]\n", ret);
682 if (_type == SOUND_DEVICE_USB_AUDIO) {
683 if ((ret = sound_manager_get_device_vendor_id(device, vendor_id)))
684 g_print("failed to get device vendor id, ret[0x%x]\n", ret);
685 if ((ret = sound_manager_get_device_product_id(device, product_id)))
686 g_print("failed to get device product id, ret[0x%x]\n", ret);
692 if ((ret = sound_manager_get_device_io_direction(device, &_direc))) {
693 g_print("failed to get device io direction, ret[0x%x]\n", ret);
696 *direc = g_device_direction_str[_direc];
699 if ((ret = sound_manager_get_device_state(device, &_state))) {
700 g_print("failed to get device state, ret[0x%x]\n", ret);
703 *state = g_device_state_str[_state];
706 if ((ret = sound_manager_is_device_running(device, &running))) {
707 g_print("failed to get 'is running', ret[0x%x]\n", ret);
710 *is_running = running;
714 void _device_connected_cb(sound_device_h device, bool is_connected, void *user_data)
720 const char *direc, *state;
721 bool is_running = false;
723 sound_device_type_e device_type;
725 _get_device_props_simple(device, &id, &type, &name, &direc, &state, &vendor_id, &product_id, &is_running);
727 g_print("[ Device #%d %s %s ] %s\n", id, type, name, is_connected ? "Connected" : "Disconnected");
728 g_print(" Direc[ %-4s ] State[ %-12s ] Running[ %d ] VendorID[ %04x ], ProductID[ %04x ]\n",
729 direc, state, is_running, vendor_id, product_id);
732 ret = sound_manager_get_current_media_playback_device_type(&device_type);
734 g_print("fail to sound_manager_get_current_media_playback_device_type, ret(0x%x)\n", ret);
736 g_print("current media playback device type is [%d] (0:BuiltinSPK 1:BuiltinRcv 2:BuiltinMic 3:AudioJack 4:BTMedia 5:HDMI 6:Forwarding 7:USBAduio 8:BTVoice)\n", device_type);
739 void _device_running_changed_cb(sound_device_h device, bool is_running, void *user_data)
745 const char *direc, *_state;
746 bool _is_running = false;
748 _get_device_props_simple(device, &id, &type, &name, &direc, &_state, &vendor_id, &product_id, &_is_running);
750 g_print("[Device #%d %s %s] running changed to [ %d ]\n", id, type, name, is_running);
751 g_print(" Direc[ %-4s ] State[ %-12s ] Running[ %d ] VendorID[ %04x ], ProductID[ %04x ]\n",
752 direc, _state, _is_running, vendor_id, product_id);
755 void reset_menu_state(void)
757 g_menu_state = CURRENT_STATUS_MAINMENU;
760 static void interpret(char *cmd)
762 switch (g_menu_state) {
763 case CURRENT_STATUS_MAINMENU:
764 _interpret_main_menu(cmd);
766 case CURRENT_STATUS_GET_MAX_VOLUME: {
769 if (convert_sound_type(&type, cmd) == 1) {
770 if (sound_manager_get_max_volume(type, &max) != SOUND_MANAGER_ERROR_NONE)
771 g_print("failt to get max volume\n");
773 g_print("the max volume of this type(%d) is %d\n", type, max);
778 case CURRENT_STATUS_SET_VOLUME: {
780 static sound_type_e type;
784 if (convert_sound_type(&type, cmd) == 1)
791 if (sound_manager_set_volume(type, volume) != SOUND_MANAGER_ERROR_NONE)
792 g_print("fail to set volume(%d) check sound type(%d)'s available volume level\n", volume, type);
794 g_print("set volume success : sound type(%d), volume(%d)\n", type, volume);
803 case CURRENT_STATUS_GET_VOLUME: {
806 if (convert_sound_type(&type, cmd) == 1) {
807 if (sound_manager_get_volume(type, &volume) != SOUND_MANAGER_ERROR_NONE)
808 g_print("fail to get volume\n");
810 g_print("current volume of this type(%d) is : %d\n", type, volume);
815 case CURRENT_STATUS_GET_CURRENT_SOUND_TYPE: {
817 if (sound_manager_get_current_sound_type(&type) != SOUND_MANAGER_ERROR_NONE)
818 g_print("fail to get current sound type\n");
820 g_print("current sound type is (%d)\n", type);
824 case CURRENT_STATUS_SET_MUTE: {
826 static sound_type_e type;
830 if (convert_sound_type(&type, cmd) == 1)
836 mute = (bool)atoi(cmd);
837 if (sound_manager_set_mute(type, mute) != SOUND_MANAGER_ERROR_NONE)
838 g_print("fail to set mute\n");
840 g_print("set mute success : sound type(%d), mute(%d)\n", type, mute);
849 case CURRENT_STATUS_GET_MUTE: {
852 if (convert_sound_type(&type, cmd) == 1) {
853 if (sound_manager_get_mute(type, &muted) != SOUND_MANAGER_ERROR_NONE)
854 g_print("fail to get mute\n");
856 g_print("get mute success : sound_type(%d), muted(%d)\n", type, muted);
861 case CURRENT_STATUS_ADD_VOLUME_CHANGED_CB: {
862 if (sound_manager_add_volume_changed_cb(_volume_changed_cb, NULL, &g_volume_cb_id) != SOUND_MANAGER_ERROR_NONE)
863 g_print("fail to add volume changed cb\n");
865 g_print("success to add volume changed cb, id[%d]\n", g_volume_cb_id);
869 case CURRENT_STATUS_REMOVE_VOLUME_CHANGED_CB: {
870 if (sound_manager_remove_volume_changed_cb(g_volume_cb_id) != SOUND_MANAGER_ERROR_NONE)
871 g_print("fail to remove volume changed cb, id[%d]\n", g_volume_cb_id);
873 g_print("success to remove volume changed cb, id[%d]\n", g_volume_cb_id);
877 case CURRENT_STATUS_SET_DEVICE_MASK: {
878 if (strncmp(cmd, "0", 1) == 0) {
879 g_device_mask = SOUND_DEVICE_ALL_MASK;
881 } else if (strncmp(cmd, "1", 1) == 0) {
882 if (g_device_mask == SOUND_DEVICE_ALL_MASK)
883 g_device_mask = SOUND_DEVICE_TYPE_INTERNAL_MASK;
885 g_device_mask |= SOUND_DEVICE_TYPE_INTERNAL_MASK;
886 g_print("add TYPE_INTERNAL MASK\n");
887 } else if (strncmp(cmd, "2", 1) == 0) {
888 if (g_device_mask == SOUND_DEVICE_ALL_MASK)
889 g_device_mask = SOUND_DEVICE_TYPE_EXTERNAL_MASK;
891 g_device_mask |= SOUND_DEVICE_TYPE_EXTERNAL_MASK;
892 g_print("add TYPE_EXTERNAL MASK\n");
893 } else if (strncmp(cmd, "3", 1) == 0) {
894 if (g_device_mask == SOUND_DEVICE_ALL_MASK)
895 g_device_mask = SOUND_DEVICE_IO_DIRECTION_IN_MASK;
897 g_device_mask |= SOUND_DEVICE_IO_DIRECTION_IN_MASK;
898 g_print("add IO_DIRECTION_IN MASK\n");
899 } else if (strncmp(cmd, "4", 1) == 0) {
900 if (g_device_mask == SOUND_DEVICE_ALL_MASK)
901 g_device_mask = SOUND_DEVICE_IO_DIRECTION_OUT_MASK;
903 g_device_mask |= SOUND_DEVICE_IO_DIRECTION_OUT_MASK;
904 g_print("add IO_DIRECTION_OUT MASK\n");
905 } else if (strncmp(cmd, "5", 1) == 0) {
906 if (g_device_mask == SOUND_DEVICE_ALL_MASK)
907 g_device_mask = SOUND_DEVICE_IO_DIRECTION_BOTH_MASK;
909 g_device_mask |= SOUND_DEVICE_IO_DIRECTION_BOTH_MASK;
910 g_print("add IO_DIRECTION_BOTH MASK\n");
911 } else if (strncmp(cmd, "6", 1) == 0) {
912 if (g_device_mask == SOUND_DEVICE_ALL_MASK)
913 g_device_mask = SOUND_DEVICE_STATE_ACTIVATED_MASK;
915 g_device_mask |= SOUND_DEVICE_STATE_ACTIVATED_MASK;
916 g_print("add STATE_ACTIVATED MASK\n");
917 } else if (strncmp(cmd, "7", 1) == 0) {
918 if (g_device_mask == SOUND_DEVICE_ALL_MASK)
919 g_device_mask = SOUND_DEVICE_STATE_DEACTIVATED_MASK;
921 g_device_mask |= SOUND_DEVICE_STATE_DEACTIVATED_MASK;
922 g_print("add STATE_DEACTIVATED MASK\n");
923 } else if (strncmp(cmd, "b", 1) == 0) {
924 g_print("device mask[0x%x]\n", g_device_mask);
927 g_print("invalid selection, please select again..\n");
931 case CURRENT_STATUS_GET_DEVICE_MASK: {
932 g_print("current device mask[0x%x]\n", g_device_mask);
936 case CURRENT_STATUS_GET_DEVICE_LIST: {
937 int ret = SOUND_MANAGER_ERROR_NONE;
938 if (!(ret = sound_manager_get_device_list(g_device_mask, &g_device_list)))
939 g_print("success to get device list\n");
941 g_print("fail to get device list, ret[0x%x]\n", ret);
945 case CURRENT_STATUS_PRINT_DEVICE_LIST: {
946 sound_device_list_h device_list;
947 sound_device_h device;
948 int ret = SOUND_MANAGER_ERROR_NONE;
958 sound_sample_format_e *formats;
959 sound_sample_rate_e *rates;
961 if (!(ret = sound_manager_get_device_list(g_device_mask, &device_list))) {
962 g_print("success to get current device list\n");
963 while (!sound_manager_get_next_device(device_list, &device)) {
964 _get_device_props_simple(device, &id, &type, &name, &direc, &state, &vendor_id, &product_id, &is_running);
965 g_print("[ Device #%d %s %s ]\n", id, type, name);
966 g_print(" Direc[ %-4s ] State[ %-12s ] Running[ %d ] VendorID[ %04x ] ProductID[ %04x ]\n", direc, state, is_running, vendor_id, product_id);
968 if (!(ret = sound_manager_get_supported_sample_formats(device, &formats, &num))) {
970 g_print("format(%u) ", formats[num]);
971 g_print("are supported.\n");
974 if (!(ret = sound_manager_get_supported_sample_rates(device, &rates, &num))) {
976 g_print("rate(%u) ", rates[num]);
977 g_print("are supported.\n");
982 g_print("fail to get current device list, ret[0x%x]\n", ret);
987 case CURRENT_STATUS_FREE_DEVICE_LIST: {
988 int ret = SOUND_MANAGER_ERROR_NONE;
989 if (!(ret = sound_manager_free_device_list(g_device_list))) {
990 g_print("success to free device list\n");
991 g_device_list = NULL;
992 g_print("device list freed\n");
994 g_print("fail to free device list, ret[0x%x]\n", ret);
999 case CURRENT_STATUS_GET_DEVICE_NEXT: {
1000 sound_device_type_e type;
1001 sound_device_io_direction_e io_direction;
1005 int ret = SOUND_MANAGER_ERROR_NONE;
1006 if (!(ret = sound_manager_get_next_device(g_device_list, &g_device))) {
1007 g_print("success to get next device\n");
1008 if ((ret = sound_manager_get_device_type(g_device, &type)))
1009 g_print("failed to get device type, ret[0x%x]\n", ret);
1010 if ((ret = sound_manager_get_device_io_direction(g_device, &io_direction)))
1011 g_print("failed to get device io direction, ret[0x%x]\n", ret);
1012 if ((ret = sound_manager_get_device_id(g_device, &id)))
1013 g_print("failed to get device id, ret[0x%x]\n", ret);
1014 if ((ret = sound_manager_get_device_name(g_device, &name)))
1015 g_print("failed to get device name, ret[0x%x]\n", ret);
1016 if ((ret = sound_manager_is_device_running(g_device, &is_running)))
1017 g_print("failed to get device state, ret[0x%x]\n", ret);
1019 g_print("-- NEXT device type[%d], io_direction[%d], id[%d], name[%s], state[%s]\n",
1020 type, io_direction, id, name, is_running ? "Running" : "Not running");
1022 g_print("failed to get next device, ret[0x%x]\n", ret);
1027 case CURRENT_STATUS_GET_DEVICE_PREV: {
1028 sound_device_type_e type;
1029 sound_device_io_direction_e io_direction;
1033 int ret = SOUND_MANAGER_ERROR_NONE;
1034 if (!(ret = sound_manager_get_prev_device(g_device_list, &g_device))) {
1035 g_print("success to get previous device\n");
1036 if ((ret = sound_manager_get_device_type(g_device, &type)))
1037 g_print("failed to get device type, ret[0x%x]\n", ret);
1038 if ((ret = sound_manager_get_device_io_direction(g_device, &io_direction)))
1039 g_print("failed to get device io direction, ret[0x%x]\n", ret);
1040 if ((ret = sound_manager_get_device_id(g_device, &id)))
1041 g_print("failed to get device id, ret[0x%x]\n", ret);
1042 if ((ret = sound_manager_get_device_name(g_device, &name)))
1043 g_print("failed to get device name, ret[0x%x]\n", ret);
1044 if ((ret = sound_manager_is_device_running(g_device, &is_running)))
1045 g_print("failed to get device state, ret[0x%x]\n", ret);
1047 g_print("-- PREV device type[%d], io_direction[%d], id[%d], name[%s], state[%s]\n",
1048 type, io_direction, id, name, is_running ? "Running" : "Not running");
1050 g_print("failed to get previous device, ret[0x%x]\n", ret);
1055 case CURRENT_STATUS_GET_DEVICE_STATE_BY_ID: {
1056 int ret = SOUND_MANAGER_ERROR_NONE;
1060 device_id = atoi(cmd);
1062 if ((ret = sound_manager_is_device_running_by_id(device_id, &is_running)))
1063 g_print("failed to is device running by id, ret[0x%x]\n", ret);
1065 g_print("device id[%d], state[%s]\n", device_id, is_running ? "Running" : "Not running");
1070 case CURRENT_STATUS_GET_SUPPORTED_SAMPLE_FORMATS: {
1071 int ret = SOUND_MANAGER_ERROR_NONE;
1072 unsigned int num = 0;
1073 sound_sample_format_e *formats;
1075 if ((ret = sound_manager_get_supported_sample_formats(g_device, &formats, &num))) {
1076 g_print("failed to get supported sample formats, ret[0x%x]\n", ret);
1079 g_print("sample format(%u) is supported\n", formats[num]);
1086 case CURRENT_STATUS_SET_SAMPLE_FORMAT: {
1087 int ret = SOUND_MANAGER_ERROR_NONE;
1088 sound_sample_format_e format;
1092 if ((ret = sound_manager_set_sample_format(g_device, format)))
1093 g_print("failed to set sample format, ret[0x%x]\n", ret);
1095 g_print("set sample format(%u)\n", format);
1100 case CURRENT_STATUS_GET_SAMPLE_FORMAT: {
1101 int ret = SOUND_MANAGER_ERROR_NONE;
1102 sound_sample_format_e format;
1104 if ((ret = sound_manager_get_sample_format(g_device, &format)))
1105 g_print("failed to get sample format, ret[0x%x]\n", ret);
1107 g_print("get sample format(%u)\n", format);
1112 case CURRENT_STATUS_GET_SUPPORTED_SAMPLE_RATES: {
1113 int ret = SOUND_MANAGER_ERROR_NONE;
1114 unsigned int num = 0;
1115 sound_sample_rate_e *rates;
1117 if ((ret = sound_manager_get_supported_sample_rates(g_device, &rates, &num))) {
1118 g_print("failed to get supported sample rates, ret[0x%x]\n", ret);
1121 g_print("sample rate(%u) is supported\n", rates[num]);
1128 case CURRENT_STATUS_SET_SAMPLE_RATE: {
1129 int ret = SOUND_MANAGER_ERROR_NONE;
1130 sound_sample_rate_e rate;
1134 if ((ret = sound_manager_set_sample_rate(g_device, rate)))
1135 g_print("failed to set sample rate, ret[0x%x]\n", ret);
1137 g_print("set sample rate(%u)\n", rate);
1142 case CURRENT_STATUS_GET_SAMPLE_RATE: {
1143 int ret = SOUND_MANAGER_ERROR_NONE;
1144 sound_sample_rate_e rate;
1146 if ((ret = sound_manager_get_sample_rate(g_device, &rate)))
1147 g_print("failed to get sample format, ret[0x%x]\n", ret);
1149 g_print("get sample rate(%u)\n", rate);
1154 case CURRENT_STATUS_SET_AVOID_RESAMPLING: {
1155 int ret = SOUND_MANAGER_ERROR_NONE;
1160 if ((ret = sound_manager_set_avoid_resampling(g_device, enable)))
1161 g_print("failed to set avoid resampling, ret[0x%x]\n", ret);
1163 g_print("set avoid resampling(%d)\n", enable);
1168 case CURRENT_STATUS_GET_AVOID_RESAMPLING: {
1169 int ret = SOUND_MANAGER_ERROR_NONE;
1172 if ((ret = sound_manager_get_avoid_resampling(g_device, &enabled)))
1173 g_print("failed to get avoid resampling, ret[0x%x]\n", ret);
1175 g_print("get avoid resampling(%d)\n", enabled);
1180 case CURRENT_STATUS_SET_MEDIA_STREAM_ONLY: {
1181 int ret = SOUND_MANAGER_ERROR_NONE;
1186 if ((ret = sound_manager_set_media_stream_only(g_device, enable)))
1187 g_print("failed to set media stream only, ret[0x%x]\n", ret);
1189 g_print("set media stream only(%d)\n", enable);
1194 case CURRENT_STATUS_GET_MEDIA_STREAM_ONLY: {
1195 int ret = SOUND_MANAGER_ERROR_NONE;
1198 if ((ret = sound_manager_get_media_stream_only(g_device, &enabled)))
1199 g_print("failed to get media stream only, ret[0x%x]\n", ret);
1201 g_print("get media stream only(%d)\n", enabled);
1206 case CURRENT_STATUS_ADD_DEVICE_CONNECTION_CHANGED_CB: {
1207 if (sound_manager_add_device_connection_changed_cb(g_device_mask, _device_connected_cb, NULL, &g_device_conn_cb_id))
1208 g_print("fail to add device connection changed cb\n");
1210 g_print("success to add device connection changed cb\n");
1214 case CURRENT_STATUS_REMOVE_DEVICE_CONNECTION_CHANGED_CB: {
1215 if (sound_manager_remove_device_connection_changed_cb(g_device_conn_cb_id))
1216 g_print("fail to remove device connection changed cb\n");
1218 g_print("success to remove device connection changed cb\n");
1222 case CURRENT_STATUS_ADD_DEVICE_RUNNING_CHANGED_CB: {
1223 if (sound_manager_add_device_running_changed_cb(g_device_mask, _device_running_changed_cb, NULL, &g_device_running_cb_id))
1224 g_print("fail to add device running changed cb\n");
1226 g_print("success to add device running changed cb\n");
1230 case CURRENT_STATUS_REMOVE_DEVICE_RUNNING_CHANGED_CB: {
1231 if (sound_manager_remove_device_state_changed_cb(g_device_running_cb_id))
1232 g_print("fail to remove device running changed cb\n");
1234 g_print("success to remove device running changed cb\n");
1238 case CURRENT_STATUS_CREATE_STREAM_INFO: {
1239 int ret = SOUND_MANAGER_ERROR_NONE;
1240 int stream_type = 0;
1241 sound_stream_type_e type = SOUND_STREAM_TYPE_MEDIA;
1242 if (g_stream_info_h) {
1243 g_print("fail to create stream information, g_stream_info_h(%p) is already set\n", g_stream_info_h);
1247 stream_type = atoi(cmd);
1248 switch (stream_type) {
1250 type = SOUND_STREAM_TYPE_MEDIA;
1252 case 1: /* system */
1253 type = SOUND_STREAM_TYPE_SYSTEM;
1256 type = SOUND_STREAM_TYPE_ALARM;
1258 case 3: /* notification */
1259 type = SOUND_STREAM_TYPE_NOTIFICATION;
1261 case 4: /* emergency */
1262 type = SOUND_STREAM_TYPE_EMERGENCY;
1264 case 5: /* ringtone for call*/
1265 type = SOUND_STREAM_TYPE_RINGTONE_CALL;
1267 case 6: /* voice call */
1268 type = SOUND_STREAM_TYPE_VOICE_CALL;
1271 type = SOUND_STREAM_TYPE_VOIP;
1273 case 8: /* media only for external devices */
1274 type = SOUND_STREAM_TYPE_MEDIA_EXTERNAL_ONLY;
1276 case 9: /* loopback */
1277 type = SOUND_STREAM_TYPE_LOOPBACK;
1280 type = SOUND_STREAM_TYPE_SOLO;
1282 case 11: /* radio */
1283 type = SOUND_STREAM_TYPE_RADIO;
1285 case 12: /* media compressed */
1286 type = SOUND_STREAM_TYPE_MEDIA_COMPRESSED;
1289 type = SOUND_STREAM_TYPE_MEDIA;
1292 if (type == (int)SOUND_STREAM_TYPE_RINGTONE_CALL ||
1293 type == (int)SOUND_STREAM_TYPE_VOICE_CALL ||
1294 type == (int)SOUND_STREAM_TYPE_RADIO ||
1295 type == (int)SOUND_STREAM_TYPE_MEDIA_COMPRESSED ||
1296 type == (int)SOUND_STREAM_TYPE_LOOPBACK)
1297 ret = sound_manager_create_stream_information_internal(type, focus_callback, NULL, &g_stream_info_h);
1298 else if (type == (int)SOUND_STREAM_TYPE_SOLO)
1299 ret = sound_manager_create_stream_information_internal(type, NULL, NULL, &g_stream_info_h);
1301 ret = sound_manager_create_stream_information(type, focus_callback, NULL, &g_stream_info_h);
1304 g_print("fail to sound_manager_create_stream_information(), ret(0x%x)\n", ret);
1309 case CURRENT_STATUS_ADD_DEVICE_FOR_STREAM_ROUTING: {
1310 int ret = SOUND_MANAGER_ERROR_NONE;
1311 int device_type = 0;
1312 sound_device_h device = NULL;
1313 sound_device_type_e selected_type = SOUND_DEVICE_BUILTIN_SPEAKER;
1314 sound_device_type_e type = SOUND_DEVICE_BUILTIN_SPEAKER;
1315 bool need_to_go = false;
1317 device_type = atoi(cmd);
1318 switch (device_type) {
1319 case 0: /* built-in mic */
1320 selected_type = SOUND_DEVICE_BUILTIN_MIC;
1322 case 1: /* built-in spk */
1323 selected_type = SOUND_DEVICE_BUILTIN_SPEAKER;
1325 case 2: /* built-in rcv */
1326 selected_type = SOUND_DEVICE_BUILTIN_RECEIVER;
1328 case 3: /* audio-jack */
1329 selected_type = SOUND_DEVICE_AUDIO_JACK;
1331 case 4: /* bt a2dp */
1332 selected_type = SOUND_DEVICE_BLUETOOTH_MEDIA;
1334 case 5: /* bt sco */
1335 selected_type = SOUND_DEVICE_BLUETOOTH_VOICE;
1338 selected_type = SOUND_DEVICE_USB_AUDIO;
1341 g_print("invalid argument, device_type(%d) is not valid for this feature\n", device_type);
1345 if (!(ret = sound_manager_get_device_list(SOUND_DEVICE_ALL_MASK, &g_device_list))) {
1346 g_print("success to get current device list\n");
1347 while (!sound_manager_get_next_device(g_device_list, &device)) {
1348 if ((ret = sound_manager_get_device_type(device, &type))) {
1349 g_print("fail to get type of device, ret(0x%x)\n", ret);
1353 if (selected_type == type) {
1359 ret = sound_manager_add_device_for_stream_routing(g_stream_info_h, device);
1361 g_print("failed to sound_manager_add_device_for_stream_routing(), ret(0x%x)\n", ret);
1363 g_print("the device is not available now\n");
1366 if (!(ret = sound_manager_free_device_list(g_device_list))) {
1367 g_print("success to free device list\n");
1368 g_device_list = NULL;
1370 g_print("fail to free device list, ret[0x%x]\n", ret);
1373 g_print("fail to get current device list, ret(0x%x)\n", ret);
1378 case CURRENT_STATUS_REMOVE_DEVICE_FOR_STREAM_ROUTING: {
1379 int ret = SOUND_MANAGER_ERROR_NONE;
1380 int device_type = 0;
1381 sound_device_h device = NULL;
1382 sound_device_type_e selected_type = SOUND_DEVICE_BUILTIN_SPEAKER;
1383 sound_device_type_e type = SOUND_DEVICE_BUILTIN_SPEAKER;
1384 bool need_to_go = false;
1386 device_type = atoi(cmd);
1387 switch (device_type) {
1388 case 0: /* built-in mic */
1389 selected_type = SOUND_DEVICE_BUILTIN_MIC;
1391 case 1: /* built-in spk */
1392 selected_type = SOUND_DEVICE_BUILTIN_SPEAKER;
1394 case 2: /* built-in rcv */
1395 selected_type = SOUND_DEVICE_BUILTIN_RECEIVER;
1397 case 3: /* audio-jack */
1398 selected_type = SOUND_DEVICE_AUDIO_JACK;
1400 case 4: /* bt a2dp */
1401 selected_type = SOUND_DEVICE_BLUETOOTH_MEDIA;
1403 case 5: /* bt sco */
1404 selected_type = SOUND_DEVICE_BLUETOOTH_VOICE;
1407 selected_type = SOUND_DEVICE_USB_AUDIO;
1410 g_print("invalid argument, device_type(%d) is not valid for this feature\n", device_type);
1414 if (!(ret = sound_manager_get_device_list(SOUND_DEVICE_ALL_MASK, &g_device_list))) {
1415 g_print("success to get current device list\n");
1416 while (!sound_manager_get_next_device(g_device_list, &device)) {
1417 if ((ret = sound_manager_get_device_type(device, &type))) {
1418 g_print("fail to get type of device, ret(0x%x)\n", ret);
1422 if (selected_type == type) {
1428 ret = sound_manager_remove_device_for_stream_routing(g_stream_info_h, device);
1430 g_print("failed to sound_manager_remove_device_for_stream_routing(), ret(0x%x)\n", ret);
1432 g_print("the device is not available now\n");
1435 g_print("fail to get current device list, ret(0x%x)\n", ret);
1439 if (!(ret = sound_manager_free_device_list(g_device_list))) {
1440 g_print("success to free device list\n");
1441 g_device_list = NULL;
1443 g_print("fail to free device list, ret[0x%x]\n", ret);
1448 case CURRENT_STATUS_REMOVE_ALL_DEVICES_FOR_STREAM_ROUTING: {
1449 int ret = SOUND_MANAGER_ERROR_NONE;
1451 if ((ret = sound_manager_remove_all_devices_for_stream_routing(g_stream_info_h)))
1452 g_print("fail to remove all devices for stream routing, ret[0x%x]\n", ret);
1457 case CURRENT_STATUS_ADD_DEVICE_ID_FOR_STREAM_ROUTING: {
1458 int ret = SOUND_MANAGER_ERROR_NONE;
1459 int device_type = 0;
1460 sound_device_h device = NULL;
1461 sound_device_type_e selected_type = SOUND_DEVICE_BUILTIN_SPEAKER;
1462 sound_device_type_e type = SOUND_DEVICE_BUILTIN_SPEAKER;
1463 bool need_to_go = false;
1466 device_type = atoi(cmd);
1467 switch (device_type) {
1468 case 0: /* built-in mic */
1469 selected_type = SOUND_DEVICE_BUILTIN_MIC;
1471 case 1: /* built-in spk */
1472 selected_type = SOUND_DEVICE_BUILTIN_SPEAKER;
1474 case 2: /* built-in rcv */
1475 selected_type = SOUND_DEVICE_BUILTIN_RECEIVER;
1477 case 3: /* audio-jack */
1478 selected_type = SOUND_DEVICE_AUDIO_JACK;
1480 case 4: /* bt a2dp */
1481 selected_type = SOUND_DEVICE_BLUETOOTH_MEDIA;
1483 case 5: /* bt sco */
1484 selected_type = SOUND_DEVICE_BLUETOOTH_VOICE;
1487 selected_type = SOUND_DEVICE_USB_AUDIO;
1490 g_print("invalid argument, device_type(%d) is not valid for this feature\n", device_type);
1494 if (!(ret = sound_manager_get_device_list(SOUND_DEVICE_ALL_MASK, &g_device_list))) {
1495 g_print("success to get current device list\n");
1496 while (!sound_manager_get_next_device(g_device_list, &device)) {
1497 if ((ret = sound_manager_get_device_type(device, &type))) {
1498 g_print("fail to get type of device, ret(0x%x)\n", ret);
1502 if (selected_type == type) {
1503 if ((ret = sound_manager_get_device_id(device, &device_id))) {
1504 g_print("fail to get device id, ret(0x%x)\n", ret);
1513 ret = sound_manager_add_device_id_for_stream_routing(g_stream_info_h, device_id);
1515 g_print("failed to sound_manager_add_device_id_for_stream_routing(), ret(0x%x)\n", ret);
1517 g_print("the device is not available now\n");
1520 if (!(ret = sound_manager_free_device_list(g_device_list))) {
1521 g_print("success to free device list\n");
1522 g_device_list = NULL;
1524 g_print("fail to free device list, ret[0x%x]\n", ret);
1527 g_print("fail to get current device list, ret(0x%x)\n", ret);
1532 case CURRENT_STATUS_REMOVE_DEVICE_ID_FOR_STREAM_ROUTING: {
1533 int ret = SOUND_MANAGER_ERROR_NONE;
1534 int device_type = 0;
1535 sound_device_h device = NULL;
1536 sound_device_type_e selected_type = SOUND_DEVICE_BUILTIN_SPEAKER;
1537 sound_device_type_e type = SOUND_DEVICE_BUILTIN_SPEAKER;
1538 bool need_to_go = false;
1541 device_type = atoi(cmd);
1542 switch (device_type) {
1543 case 0: /* built-in mic */
1544 selected_type = SOUND_DEVICE_BUILTIN_MIC;
1546 case 1: /* built-in spk */
1547 selected_type = SOUND_DEVICE_BUILTIN_SPEAKER;
1549 case 2: /* built-in rcv */
1550 selected_type = SOUND_DEVICE_BUILTIN_RECEIVER;
1552 case 3: /* audio-jack */
1553 selected_type = SOUND_DEVICE_AUDIO_JACK;
1555 case 4: /* bt a2dp */
1556 selected_type = SOUND_DEVICE_BLUETOOTH_MEDIA;
1558 case 5: /* bt sco */
1559 selected_type = SOUND_DEVICE_BLUETOOTH_VOICE;
1562 selected_type = SOUND_DEVICE_USB_AUDIO;
1565 g_print("invalid argument, device_type(%d) is not valid for this feature\n", device_type);
1569 if (!(ret = sound_manager_get_device_list(SOUND_DEVICE_ALL_MASK, &g_device_list))) {
1570 g_print("success to get current device list\n");
1571 while (!sound_manager_get_next_device(g_device_list, &device)) {
1572 if ((ret = sound_manager_get_device_type(device, &type))) {
1573 g_print("fail to get type of device, ret(0x%x)\n", ret);
1577 if (selected_type == type) {
1578 if ((ret = sound_manager_get_device_id(device, &device_id))) {
1579 g_print("fail to get device id, ret(0x%x)\n", ret);
1588 ret = sound_manager_remove_device_id_for_stream_routing(g_stream_info_h, device_id);
1590 g_print("failed to sound_manager_remove_device_id_for_stream_routing(), ret(0x%x)\n", ret);
1592 g_print("the device is not available now\n");
1595 g_print("fail to get current device list, ret(0x%x)\n", ret);
1599 if (!(ret = sound_manager_free_device_list(g_device_list))) {
1600 g_print("success to free device list\n");
1601 g_device_list = NULL;
1603 g_print("fail to free device list, ret[0x%x]\n", ret);
1608 case CURRENT_STATUS_APPLY_STREAM_ROUTING: {
1609 int ret = SOUND_MANAGER_ERROR_NONE;
1610 ret = sound_manager_apply_stream_routing(g_stream_info_h);
1612 g_print("failed to sound_manager_apply_stream_routing(), ret(0x%x)\n", ret);
1617 case CURRENT_STATUS_SET_STREAM_ROUTING_OPTION: {
1618 int ret = SOUND_MANAGER_ERROR_NONE;
1623 selection = atoi(cmd);
1624 switch (selection) {
1642 g_print("invalid argument, try again..\n");
1646 ret = sound_manager_set_stream_routing_option(g_stream_info_h, name, value);
1648 g_print("failed to sound_manager_set_stream_routing_option(), ret(0x%x)\n", ret);
1653 case CURRENT_STATUS_ACQUIRE_FOCUS: {
1654 int ret = SOUND_MANAGER_ERROR_NONE;
1656 sound_stream_focus_mask_e focus_mask;
1657 int behavior = SOUND_BEHAVIOR_NONE;
1659 focus_type = atoi(cmd);
1660 switch (focus_type) {
1661 case 0: /* playback */
1662 focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK;
1664 case 1: /* recording */
1665 focus_mask = SOUND_STREAM_FOCUS_FOR_RECORDING;
1668 focus_mask = SOUND_STREAM_FOCUS_FOR_BOTH;
1670 case 3: /* both + no-resumption */
1671 focus_mask = SOUND_STREAM_FOCUS_FOR_BOTH;
1672 behavior = SOUND_BEHAVIOR_NO_RESUME;
1674 case 4: /* both + fading */
1675 focus_mask = SOUND_STREAM_FOCUS_FOR_BOTH;
1676 behavior = SOUND_BEHAVIOR_FADING;
1679 g_print("invalid selection(%d), keep going with PLAYBACK focus..\n", focus_type);
1680 focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK;
1683 ret = sound_manager_acquire_focus(g_stream_info_h, focus_mask,
1685 "sound_manager_test(acquire_focus)");
1687 g_print("fail to sound_manager_acquire_focus(), ret(0x%x)\n", ret);
1692 case CURRENT_STATUS_RELEASE_FOCUS: {
1693 int ret = SOUND_MANAGER_ERROR_NONE;
1695 sound_stream_focus_mask_e focus_mask;
1696 int behavior = SOUND_BEHAVIOR_NONE;
1698 focus_type = atoi(cmd);
1699 switch (focus_type) {
1700 case 0: /* playback */
1701 focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK;
1703 case 1: /* recording */
1704 focus_mask = SOUND_STREAM_FOCUS_FOR_RECORDING;
1707 focus_mask = SOUND_STREAM_FOCUS_FOR_BOTH;
1709 case 3: /* both + no-resumption */
1710 focus_mask = SOUND_STREAM_FOCUS_FOR_BOTH;
1711 behavior = SOUND_BEHAVIOR_NO_RESUME;
1713 case 4: /* both + fading */
1714 focus_mask = SOUND_STREAM_FOCUS_FOR_BOTH;
1715 behavior = SOUND_BEHAVIOR_FADING;
1718 g_print("invalid selection(%d), keep going with PLAYBACK focus..\n", focus_type);
1719 focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK;
1722 ret = sound_manager_release_focus(g_stream_info_h, focus_mask,
1724 "sound_manager_test(release_focus)");
1726 g_print("fail to sound_manager_release_focus(), ret(0x%x)\n", ret);
1731 case CURRENT_STATUS_ACQUIRE_FOCUS_ALL: {
1732 int ret = SOUND_MANAGER_ERROR_NONE;
1733 int behavior = atoi(cmd);
1736 case 0: /* without behavior */
1737 behavior = SOUND_BEHAVIOR_NONE;
1739 case 1: /* no-resumption */
1740 behavior = SOUND_BEHAVIOR_NO_RESUME;
1742 case 2: /* fading */
1743 behavior = SOUND_BEHAVIOR_FADING;
1746 g_print("invalid selection(%d), keep going without behavior..\n", behavior);
1747 behavior = SOUND_BEHAVIOR_NONE;
1750 ret = sound_manager_acquire_focus_all(g_stream_info_h, behavior, "sound_manager_test(acquire_focus_all)");
1752 g_print("fail to sound_manager_acquire_focus_all(), ret(0x%x)\n", ret);
1757 case CURRENT_STATUS_RELEASE_FOCUS_ALL: {
1758 int ret = SOUND_MANAGER_ERROR_NONE;
1759 int behavior = atoi(cmd);
1762 case 0: /* without behavior */
1763 behavior = SOUND_BEHAVIOR_NONE;
1765 case 1: /* no-resumption */
1766 behavior = SOUND_BEHAVIOR_NO_RESUME;
1768 case 2: /* fading */
1769 behavior = SOUND_BEHAVIOR_FADING;
1772 g_print("invalid selection(%d), keep going without behavior..\n", behavior);
1773 behavior = SOUND_BEHAVIOR_NONE;
1776 ret = sound_manager_release_focus_all(g_stream_info_h, behavior, "sound_manager_test(release_focus_all)");
1778 g_print("fail to sound_manager_release_focus_all(), ret(0x%x)\n", ret);
1783 case CURRENT_STATUS_DELIVER_FOCUS: {
1784 int ret = SOUND_MANAGER_ERROR_NONE;
1785 sound_stream_focus_mask_e focus_mask;
1786 sound_stream_info_h stream_info_h = NULL;
1787 int focus_type = atoi(cmd);
1789 ret = sound_manager_create_stream_information(SOUND_STREAM_TYPE_MEDIA, focus_callback, NULL, &stream_info_h);
1791 g_print("fail to sound_manager_create_stream_information(), ret(0x%x)\n", ret);
1796 switch (focus_type) {
1797 case 0: /* playback */
1798 focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK;
1800 case 1: /* recording */
1801 focus_mask = SOUND_STREAM_FOCUS_FOR_RECORDING;
1804 focus_mask = SOUND_STREAM_FOCUS_FOR_BOTH;
1807 g_print("invalid selection(%d), keep going with PLAYBACK focus..\n", focus_type);
1808 focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK;
1811 ret = sound_manager_deliver_focus(g_stream_info_h, stream_info_h, focus_mask);
1813 g_print("fail to sound_manager_deliver_focus(), ret(0x%x)\n", ret);
1815 sound_manager_destroy_stream_information(stream_info_h);
1820 case CURRENT_STATUS_GET_ACQUIRED_FOCUS: {
1821 sound_stream_focus_state_e for_playback;
1822 sound_stream_focus_state_e for_recording;
1823 int ret = SOUND_MANAGER_ERROR_NONE;
1824 if (g_stream_info_h) {
1825 ret = sound_manager_get_focus_state(g_stream_info_h, &for_playback, &for_recording);
1827 g_print("fail to sound_manager_get_focus_state(), ret(0x%x)\n", ret);
1829 g_print("focus_state(playback:%d, capture:%d)\n", for_playback, for_recording);
1832 g_print("please create stream info. first\n");
1837 case CURRENT_STATUS_GET_SOUND_TYPE: {
1838 int ret = SOUND_MANAGER_ERROR_NONE;
1839 sound_type_e sound_type;
1840 if (g_stream_info_h) {
1841 ret = sound_manager_get_sound_type(g_stream_info_h, &sound_type);
1843 g_print("fail to sound_manager_get_sound_type(), ret(0x%x)\n", ret);
1845 g_print("sound_type(%d)\n", sound_type);
1848 g_print("please create stream info. first\n");
1853 case CURRENT_STATUS_DESTROY_STREAM_INFO: {
1854 int ret = SOUND_MANAGER_ERROR_NONE;
1855 ret = sound_manager_destroy_stream_information(g_stream_info_h);
1857 g_print("fail to sound_manager_destroy_stream_information(), ret(0x%x)\n", ret);
1859 g_stream_info_h = NULL;
1864 case CURRENT_STATUS_ADD_FOCUS_WATCH_CB: {
1865 int ret = SOUND_MANAGER_ERROR_NONE;
1867 sound_stream_focus_mask_e focus_mask;
1870 focus_type = atoi(cmd);
1871 switch (focus_type) {
1872 case 0: /* playback */
1873 focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK;
1875 case 1: /* recording */
1876 focus_mask = SOUND_STREAM_FOCUS_FOR_RECORDING;
1879 focus_mask = SOUND_STREAM_FOCUS_FOR_BOTH;
1882 focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK;
1885 ret = sound_manager_add_focus_state_watch_cb(focus_mask, focus_watch_callback, NULL, &id);
1887 g_print("fail to sound_manager_add_focus_state_watch_cb(), ret(0x%x)\n", ret);
1889 g_print("id: %d\n", id);
1894 case CURRENT_STATUS_REMOVE_FOCUS_WATCH_CB: {
1895 int ret = SOUND_MANAGER_ERROR_NONE;
1899 ret = sound_manager_remove_focus_state_watch_cb(id);
1901 g_print("fail to sound_manager_remove_focus_state_watch_cb(%d), ret(0x%x)\n", id, ret);
1905 case CURRENT_STATUS_SET_FOCUS_REACQUISITION: {
1906 int ret = SOUND_MANAGER_ERROR_NONE;
1911 ret = sound_manager_set_focus_reacquisition(g_stream_info_h, enable);
1913 g_print("fail to sound_manager_set_focus_reacquisition, ret(0x%x)\n", ret);
1917 case CURRENT_STATUS_GET_FOCUS_REACQUISITION: {
1918 int ret = SOUND_MANAGER_ERROR_NONE;
1921 ret = sound_manager_get_focus_reacquisition(g_stream_info_h, &enabled);
1923 g_print("fail to sound_manager_get_focus_reacquisition, ret(0x%x)\n", ret);
1925 g_print("auto focus reacquisition is enabled\n");
1927 g_print("auto focus reacquisition is disabled\n");
1931 case CURRENT_STATUS_GET_REASON_FOR_P_FOCUS: {
1932 int ret = SOUND_MANAGER_ERROR_NONE;
1933 char *extra_info = NULL;
1934 sound_stream_focus_change_reason_e reason;
1937 ret = sound_manager_get_current_playback_focus(&reason, &sound_behavior, &extra_info);
1939 g_print("fail to sound_manager_get_current_playback_focus, ret(0x%x)\n", ret);
1941 g_print("reason(%d), sound_behavior(0x%x, 0x0:none 0x1:no_resume 0x2:fading), extra_info(%s)\n", reason, sound_behavior, extra_info);
1947 case CURRENT_STATUS_GET_REASON_FOR_R_FOCUS: {
1948 int ret = SOUND_MANAGER_ERROR_NONE;
1949 char *extra_info = NULL;
1950 sound_stream_focus_change_reason_e reason;
1953 ret = sound_manager_get_current_recording_focus(&reason, &sound_behavior, &extra_info);
1955 g_print("fail to sound_manager_get_current_recording_focus, ret(0x%x)\n", ret);
1957 g_print("reason(%d), sound_behavior(0x%x, 0x0:none 0x1:no_resume 0x2:fading), extra_info(%s)\n", reason, sound_behavior, extra_info);
1963 case CURRENT_STATUS_GET_CURRENT_MEDIA_PLAYBACK_DEVICE_TYPE: {
1964 int ret = SOUND_MANAGER_ERROR_NONE;
1965 sound_device_type_e device_type;
1967 ret = sound_manager_get_current_media_playback_device_type(&device_type);
1969 g_print("fail to sound_manager_get_current_media_playback_device_type, ret(0x%x)\n", ret);
1971 g_print("device_type(%d)\n", device_type);
1976 case CURRENT_STATUS_CREATE_VIRTUAL_STREAM: {
1977 int ret = SOUND_MANAGER_ERROR_NONE;
1978 if (!g_stream_info_h || g_vstream_h) {
1979 g_print("fail to create virtual stream, g_stream_info_h(%p)/g_vstream_h(%p)\n", g_stream_info_h, g_vstream_h);
1983 ret = sound_manager_create_virtual_stream(g_stream_info_h, &g_vstream_h);
1985 g_print("fail to sound_manager_create_virtual_stream(), ret(0x%x)\n", ret);
1987 g_print("success to sound_manager_create_virtual_stream(), ret(0x%x)\n", ret);
1992 case CURRENT_STATUS_START_VIRTUAL_STREAM: {
1993 int ret = SOUND_MANAGER_ERROR_NONE;
1995 ret = sound_manager_start_virtual_stream(g_vstream_h);
1997 g_print("fail to sound_manager_start_virtual_stream(), ret(0x%x)\n", ret);
1999 g_print("success to sound_manager_start_virtual_stream(), ret(0x%x)\n", ret);
2004 case CURRENT_STATUS_STOP_VIRTUAL_STREAM: {
2005 int ret = SOUND_MANAGER_ERROR_NONE;
2007 ret = sound_manager_stop_virtual_stream(g_vstream_h);
2009 g_print("fail to sound_manager_stop_virtual_stream(), ret(0x%x)\n", ret);
2011 g_print("success to sound_manager_stop_virtual_stream(), ret(0x%x)\n", ret);
2016 case CURRENT_STATUS_DESTROY_VIRTUAL_STREAM: {
2017 int ret = SOUND_MANAGER_ERROR_NONE;
2019 ret = sound_manager_destroy_virtual_stream(g_vstream_h);
2021 g_print("fail to sound_manager_destroy_virtual_stream(), ret(0x%x)\n", ret);
2023 g_print("success to sound_manager_destroy_virtual_stream(), ret(0x%x)\n", ret);
2029 case CURRENT_STATUS_SET_VIRTUAL_STREAM_VOLUME: {
2030 int ret = SOUND_MANAGER_ERROR_NONE;
2036 ret = sound_manager_set_virtual_stream_volume(g_vstream_h, ratio);
2038 g_print("fail to sound_manager_set_virtual_stream_volume(), ret(0x%x)\n", ret);
2040 g_print("success to sound_manager_set_virtual_stream_volume(), ratio(%f), ret(0x%x)\n", ratio, ret);
2045 case CURRENT_STATUS_SET_FILTER: {
2046 int ret = SOUND_MANAGER_ERROR_NONE;
2047 sound_filter_e filter;
2048 int selection = atoi(cmd);
2049 switch (selection) {
2050 case 0: /* low pass filter */
2051 filter = SOUND_FILTER_LOW_PASS;
2053 case 1: /* high pass filter */
2054 filter = SOUND_FILTER_HIGH_PASS;
2057 filter = SOUND_FILTER_DELAY;
2059 case 3: /* soundAlive */
2060 filter = SOUND_FILTER_SOUNDALIVE;
2063 filter = SOUND_FILTER_DELAY;
2064 g_print("invalid selection(%d), keep going with filter(%d)\n", selection, filter);
2068 ret = sound_manager_set_filter(SOUND_STREAM_TYPE_MEDIA, filter);
2070 g_print("fail to sound_manager_set_filter(), ret(0x%x)\n", ret);
2072 g_print("success to sound_manager_set_filter(), ret(0x%x)\n", ret);
2077 case CURRENT_STATUS_SET_FILTER_PRESET: {
2078 int ret = SOUND_MANAGER_ERROR_NONE;
2079 sound_filter_e filter;
2080 sound_filter_preset_e preset;
2081 int selection = atoi(cmd);
2083 switch (selection) {
2084 case 0: /* low pass under none */
2085 filter = SOUND_FILTER_LOW_PASS;
2086 preset = SOUND_FILTER_PRESET_LOW_PASS_NONE;
2088 case 1: /* low pass under 240hz */
2089 filter = SOUND_FILTER_LOW_PASS;
2090 preset = SOUND_FILTER_PRESET_LOW_PASS_UNDER_240HZ;
2092 case 2: /* low pass under 480hz */
2093 filter = SOUND_FILTER_LOW_PASS;
2094 preset = SOUND_FILTER_PRESET_LOW_PASS_UNDER_480HZ;
2096 case 3: /* high pass over none */
2097 filter = SOUND_FILTER_HIGH_PASS;
2098 preset = SOUND_FILTER_PRESET_HIGH_PASS_NONE;
2100 case 4: /* high pass over 240hz */
2101 filter = SOUND_FILTER_HIGH_PASS;
2102 preset = SOUND_FILTER_PRESET_HIGH_PASS_OVER_240HZ;
2104 case 5: /* high pass over 480hz */
2105 filter = SOUND_FILTER_HIGH_PASS;
2106 preset = SOUND_FILTER_PRESET_HIGH_PASS_OVER_480HZ;
2108 case 6: /* delay none */
2109 filter = SOUND_FILTER_DELAY;
2110 preset = SOUND_FILTER_PRESET_DELAY_NONE;
2112 case 7: /* delay 1 sec */
2113 filter = SOUND_FILTER_DELAY;
2114 preset = SOUND_FILTER_PRESET_DELAY_1SEC;
2116 case 8: /* delay 2 sec */
2117 filter = SOUND_FILTER_DELAY;
2118 preset = SOUND_FILTER_PRESET_DELAY_2SEC;
2120 case 9: /* soundAlive concert normal */
2121 filter = SOUND_FILTER_SOUNDALIVE;
2122 preset = SOUND_FILTER_PRESET_SOUNDALIVE_NORMAL;
2124 case 10: /* soundAlive concert hall */
2125 filter = SOUND_FILTER_SOUNDALIVE;
2126 preset = SOUND_FILTER_PRESET_SOUNDALIVE_CONCERT_HALL;
2129 filter = SOUND_FILTER_DELAY;
2130 preset = SOUND_FILTER_PRESET_DELAY_NONE;
2131 g_print("invalid selection(%d), keep going with filter(%d), preset(%d)\n", selection, filter, preset);
2135 ret = sound_manager_set_filter_preset(SOUND_STREAM_TYPE_MEDIA, filter, preset);
2137 g_print("fail to sound_manager_set_filter_preset(), ret(0x%x)\n", ret);
2139 g_print("success to sound_manager_set_filter_preset(), ret(0x%x)\n", ret);
2144 case CURRENT_STATUS_UNSET_FILTER: {
2145 int ret = SOUND_MANAGER_ERROR_NONE;
2146 ret = sound_manager_unset_filter(SOUND_STREAM_TYPE_MEDIA);
2148 g_print("fail to sound_manager_unset_filter(), ret(0x%x)\n", ret);
2150 g_print("success to sound_manager_unset_filter(), ret(0x%x)\n", ret);
2154 case CURRENT_STATUS_IS_STREAM_ON_DEVICE_BY_ID: {
2155 int ret = SOUND_MANAGER_ERROR_NONE;
2159 device_id = atoi(cmd);
2160 ret = sound_manager_is_stream_on_device_by_id(g_stream_info_h, device_id, &is_on);
2162 g_print("fail to sound_manager_is_stream_on_device_by_id(), device_id(%d), ret(0x%x)\n", device_id, ret);
2164 g_print("stream info is on the device_id(%d): %s\n", device_id, is_on ? "true" : "false");
2168 #ifndef TIZEN_FEATURE_TV_PROD
2169 case CURRENT_STATUS_GET_MAX_MASTER_VOLUME: {
2171 if (sound_manager_get_max_master_volume(&max_level) != SOUND_MANAGER_ERROR_NONE)
2172 g_print("failed to get max master volume\n");
2174 g_print("the max level of master volume is %d\n", max_level);
2179 case CURRENT_STATUS_SET_MASTER_VOLUME: {
2182 if (sound_manager_set_master_volume(level) != SOUND_MANAGER_ERROR_NONE)
2183 g_print("failed to set master volume(%d)\n", level);
2185 g_print("set master volume success : level(%d)\n", level);
2190 case CURRENT_STATUS_GET_MASTER_VOLUME: {
2192 if (sound_manager_get_master_volume(&level) != SOUND_MANAGER_ERROR_NONE)
2193 g_print("failed to get master volume\n");
2195 g_print("current master volume is : %d\n", level);
2200 case CURRENT_STATUS_SET_ACM_MASTER_MODE: {
2201 int ret = SOUND_MANAGER_ERROR_NONE;
2202 int selection = atoi(cmd);
2204 if (selection < 0 || selection > 1) {
2205 g_print("invalid selection(%d)\n", selection);
2210 if ((ret = sound_manager_set_acm_master_mode((bool)selection)))
2211 g_print("fail to sound_manager_set_acm_master_mode(), ret(0x%x)\n", ret);
2213 g_print("success to sound_manager_set_acm_master_mode(), ret(0x%x)\n", ret);
2219 case CURRENT_STATUS_CREATE_STREAM_DUCKING: {
2220 int ret = SOUND_MANAGER_ERROR_NONE;
2221 sound_stream_type_e target_stream = SOUND_STREAM_TYPE_MEDIA;
2223 if (g_stream_ducking_h) {
2224 g_print("fail to create stream ducking, g_stream_ducking_h(%p) is already set\n", g_stream_ducking_h);
2229 target_stream = (sound_stream_type_e)atoi(cmd);
2231 ret = sound_manager_create_stream_ducking(target_stream,
2232 ducking_state_changed_cb, NULL, &g_stream_ducking_h);
2234 g_print("fail to sound_manager_create_stream_ducking(t:%u), ret(0x%x)\n", target_stream, ret);
2239 case CURRENT_STATUS_DESTROY_STREAM_DUCKING: {
2240 int ret = SOUND_MANAGER_ERROR_NONE;
2241 ret = sound_manager_destroy_stream_ducking(g_stream_ducking_h);
2243 g_print("fail to sound_manager_destroy_stream_ducking(), ret(0x%x)\n", ret);
2245 g_stream_ducking_h = NULL;
2250 case CURRENT_STATUS_ACTIVATE_DUCKING: {
2251 int ret = SOUND_MANAGER_ERROR_NONE;
2253 static unsigned int duration = 0;
2254 static double ratio = 0;
2258 duration = (unsigned int)atoi(cmd);
2262 ratio = (double)atof(cmd);
2264 ret = sound_manager_activate_ducking(g_stream_ducking_h, duration, ratio);
2266 g_print("fail to activate_ducking(%u,%lf), ret(0x%x)\n", duration, ratio, ret);
2268 g_print("success to sound_manager_activate_ducking()\n");
2276 case CURRENT_STATUS_DEACTIVATE_DUCKING: {
2277 int ret = SOUND_MANAGER_ERROR_NONE;
2279 ret = sound_manager_deactivate_ducking(g_stream_ducking_h);
2281 g_print("fail to sound_manager_deactivate_ducking(), ret(0x%x)\n", ret);
2283 g_print("success to sound_manager_deactivate_ducking()\n");
2288 case CURRENT_STATUS_GET_DUCKING_STATE: {
2289 int ret = SOUND_MANAGER_ERROR_NONE;
2290 bool is_ducked = false;
2292 ret = sound_manager_is_ducked(g_stream_ducking_h, &is_ducked);
2294 g_print("fail to sound_manager_is_ducked(), ret(0x%x)\n", ret);
2296 g_print("success to sound_manager_is_ducked() - is_ducked %u\n", is_ducked);
2302 g_timeout_add(100, timeout_menu_display, 0);
2305 gboolean input(GIOChannel *channel)
2307 gchar buf[MAX_STRING_LEN];
2309 GError *error = NULL;
2311 g_io_channel_read_chars(channel, buf, MAX_STRING_LEN - 1, &read, &error);
2319 int main(int argc, char *argv[])
2321 GIOChannel *stdin_channel;
2322 stdin_channel = g_io_channel_unix_new(0);
2323 g_io_channel_set_flags(stdin_channel, G_IO_FLAG_NONBLOCK, NULL);
2324 g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc)input, NULL);
2325 g_loop = g_main_loop_new(NULL, 1);
2328 g_main_loop_run(g_loop);