4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Seungbae Shin <seungbae.shin@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
26 #define debug_log(msg, args...) fprintf(stderr, msg, ##args)
27 #define debug_error(msg, args...) fprintf(stderr, msg, ##args)
28 #define MAX_STRING_LEN 256
29 #define MAX_PATH_LEN 1024
30 #define MIN_TONE_PLAY_TIME 300
31 #include "../include/mm_sound.h"
33 #include "../include/mm_sound_focus.h"
35 #include "../include/mm_sound_common.h"
36 #include "../include/mm_sound_private.h"
37 #include "../include/mm_sound_pa_client.h"
43 #include <sys/types.h>
48 #include <mm_session_private.h>
50 #define POWERON_FILE "/usr/share/feedback/sound/operation/power_on.wav"
51 #define KEYTONE_FILE "/usr/share/feedback/sound/operation/operation.wav"
54 // For testsuite status
56 CURRENT_STATUS_MAINMENU = 0,
57 CURRENT_STATUS_FILENAME = 1,
58 CURRENT_STATUS_POSITION = 2,
59 CURRENT_STATUS_DIRNAME = 3,
62 int g_menu_state = CURRENT_STATUS_MAINMENU;
64 volume_type_t g_volume_type = VOLUME_TYPE_MEDIA;
65 unsigned int g_volume_value;
67 GIOChannel *stdin_channel;
68 char g_file_name[MAX_STRING_LEN];
69 char g_dir_name[MAX_PATH_LEN];
72 int g_focus_watch_index = -1;
76 unsigned int g_subs_id_test, g_subs_id_volume, g_subs_id_device_conn, g_subs_id_device_info;
79 static void interpret (char *buf);
80 gboolean timeout_menu_display(void *data);
81 gboolean timeout_quit_program(void *data);
82 gboolean input (GIOChannel *channel);
84 void mycallback(void *data, int id)
86 char *str = (char*)data;
88 debug_log("mycallback called (user data:%s ,id:%d)\n", str, id);
90 debug_log("mycallback called (no user data)\n");
92 volatile char test_callback_done;
93 void test_callback(void *data, int id)
95 debug_log("test_callback is called\n");
96 test_callback_done = 1;
98 void mm_sound_test_cb1(int a, void *user_data)
100 debug_log("dbus test user callback called: param(%d), userdata(%d)\n", a, (int)user_data);
101 g_print("my callback pid : %u tid : %ld\n", getpid(), pthread_self());
103 void device_connected_cb (MMSoundDevice_t device_h, bool is_connected, void *user_data)
106 mm_sound_device_type_e device_type = 0;
107 mm_sound_device_io_direction_e io_direction = 0;
108 mm_sound_device_state_e state = 0;
111 debug_log("*** device_connected_cb is called, device_h[%p], is_connected[%d], user_date[%p]\n", device_h, is_connected, user_data);
112 ret = mm_sound_get_device_type(device_h, &device_type);
114 debug_error("failed to mm_sound_get_device_type()\n");
116 ret = mm_sound_get_device_io_direction(device_h, &io_direction);
118 debug_error("failed to mm_sound_get_device_io_direction()\n");
120 ret = mm_sound_get_device_state(device_h, &state);
122 debug_error("failed to mm_sound_get_device_state()\n");
124 ret = mm_sound_get_device_id(device_h, &id);
126 debug_error("failed to mm_sound_get_device_id()\n");
128 ret = mm_sound_get_device_name(device_h, &name);
130 debug_error("failed to mm_sound_get_device_name()\n");
132 debug_log("*** --- type[%d], id[%d], io_direction[%d], state[%d], name[%s]\n", device_type, id, io_direction, state, name);
134 void device_info_changed_cb (MMSoundDevice_t device_h, int changed_info_type, void *user_data)
137 mm_sound_device_type_e device_type = 0;
138 mm_sound_device_io_direction_e io_direction = 0;
139 mm_sound_device_state_e state = 0;
142 debug_log("*** device_info_changed_cb is called, device_h[%p], changed_info_type[%d], user_date[%p]\n", device_h, changed_info_type, user_data);
143 ret = mm_sound_get_device_type(device_h, &device_type);
145 debug_error("failed to mm_sound_get_device_type()\n");
147 ret = mm_sound_get_device_io_direction(device_h, &io_direction);
149 debug_error("failed to mm_sound_get_device_io_direction()\n");
151 ret = mm_sound_get_device_state(device_h, &state);
153 debug_error("failed to mm_sound_get_device_state()\n");
155 ret = mm_sound_get_device_id(device_h, &id);
157 debug_error("failed to mm_sound_get_device_id()\n");
159 ret = mm_sound_get_device_name(device_h, &name);
161 debug_error("failed to mm_sound_get_device_name()\n");
163 debug_log("*** --- type[%d], id[%d], io_direction[%d], state[%d], name[%s]\n", device_type, id, io_direction, state, name);
166 void focus_cb0(int index, mm_sound_focus_type_e type, mm_sound_focus_state_e state, const char *reason_for_change, int option, const char *ext_info, void *user_data)
169 if (state == FOCUS_IS_RELEASED)
173 debug_log("*** focus_cb0 is called, index[%d], focus_type[%d], state[%s], reason_for_change[%s], option[0x%x], ext_info[%s], user_data[%s]\n",
174 index, type, _state, reason_for_change, option, ext_info, (char*)user_data);
176 void focus_cb1(int index, mm_sound_focus_type_e type, mm_sound_focus_state_e state, const char *reason_for_change, int option, const char *ext_info, void *user_data)
179 if (state == FOCUS_IS_RELEASED)
183 debug_log("*** focus_cb1 is called, index[%d], focus_type[%d], state[%s], reason_for_change[%s], option[0x%x], ext_info[%s], user_data[%s]\n",
184 index, type, _state, reason_for_change, option, ext_info, (char*)user_data);
186 void focus_watch_cb(int index, mm_sound_focus_type_e type, mm_sound_focus_state_e state, const char *reason_for_change, const char *ext_info, void *user_data)
189 if (state == FOCUS_IS_RELEASED)
193 debug_log("*** focus_watch_cb is called, index[%d], focus_type[%d], state[%s], reason_for_change[%s], ext_info[%s], user_data[%s]\n",
194 index, type, _state, reason_for_change, ext_info, (char*)user_data);
199 g_main_loop_quit(g_loop);
202 static void displaymenu()
204 if (g_menu_state == CURRENT_STATUS_MAINMENU) {
205 g_print("==================================================================\n");
206 g_print(" Sound Path APIs\n");
207 g_print("==================================================================\n");
208 g_print("1. Play speaker \t");
209 g_print("2. Play headset \n");
210 g_print("3. (blank) \n");
211 g_print("4. Rec. with mic \t");
212 g_print("5. (blank) \t");
213 g_print("6. Call receiver \n");
214 g_print("7. Call end \t");
215 g_print("8. VT call speaker \t");
216 g_print("9. VT call end \n");
217 g_print("==================================================================\n");
218 g_print(" Sound Play APIs\n");
219 g_print("==================================================================\n");
220 g_print("k : Key Sound \t");
221 g_print("an : play sound \t");
222 g_print("as : play sound with stream type\t");
223 g_print("A : play loud solo\n");
224 g_print("c : play sound ex \t");
225 g_print("FN : Play DTMF \t");
226 g_print("FS : Play DTMF with stream type\t");
227 g_print("b : Play directory\n");
228 g_print("s : Stop play \t");
229 g_print("m : stereo to mono\n");
230 g_print("==================================================================\n");
231 g_print(" Volume APIs\n");
232 g_print("==================================================================\n");
233 g_print("q : Get media \t");
234 g_print("w : Inc. media \t");
235 g_print("e : Dec. media \n");
236 g_print("r : Get system \t");
237 g_print("t : Inc. system \t");
238 g_print("y : Dec. system \n");
239 g_print("g : Get voice \t");
240 g_print("h : Inc. voice \t");
241 g_print("j : Dec. voice \n");
242 g_print("==================================================================\n");
243 g_print(" Audio route APIs\n");
244 g_print("==================================================================\n");
245 g_print("u : Foreach Available Routes \t");
246 g_print("i : Get Active Devices \n");
247 g_print("o : Add Available Routes Callback \t");
248 g_print("O : Remove Available Routes Callback \n");
249 g_print("p : Add Active Route Callback\t");
250 g_print("P : Remove Active Route Callback \n");
251 g_print("{ : Get BT A2DP Status\n");
252 g_print("} : Set Active Route\n");
253 g_print("==================================================================\n");
254 g_print(" Session Test\n");
255 g_print("==================================================================\n");
256 g_print("z : Call start \t");
257 g_print("Z : VideoCall start \t");
258 g_print("N : Notification start \n");
259 g_print("n : VOIP start \t");
260 g_print("v : Session end \n");
261 g_print("==================================================================\n");
262 g_print(" Audio device APIs\n");
263 g_print("==================================================================\n");
264 g_print("L : Get current list of connected devices \n");
265 g_print("I : Get device by id \n");
266 g_print("C : Add device connected callback \t");
267 g_print("D : Remove device connected callback \n");
268 g_print("Q : Add device info. changed callback \t");
269 g_print("W : Remove device info. changed callback \n");
270 g_print("==================================================================\n");
272 g_print(" Focus APIs\n");
273 g_print("==================================================================\n");
274 g_print("DS : signal subscribe for stream info\t");
275 g_print("DU : signal unsubscribe for stream info\n");
276 g_print("SS : Send signal for stream info\n");
277 g_print("GU : Get Focus id\n");
278 g_print("SF : Set Focus Callback\t");
279 g_print("FFS : Set Focus Callback for session\t");
280 g_print("UF : Unset Focus Callback\n");
281 g_print("DF : Disable Auto Focus Reacquirement\t");
282 g_print("AF : Acquire Focus\t");
283 g_print("RF : Release Focus\n");
284 g_print("WS : Set Focus Watch Callback\t");
285 g_print("WFS : Set Focus Watch Callback for session\t");
286 g_print("WU : Unset Focus Watch Callback\n");
287 g_print("==================================================================\n");
289 g_print("d : Input Directory \t");
290 g_print("f : Input File name \t");
291 g_print("x : Exit Program \n");
292 g_print("==================================================================\n");
293 g_print(" Input command >>>>>>>> ");
295 else if (g_menu_state == CURRENT_STATUS_FILENAME) {
296 g_print(">>>>Input file name to play : ");
298 else if (g_menu_state == CURRENT_STATUS_DIRNAME) {
299 g_print(">>>>Input directory which contain audio files : ");
302 g_print("**** Unknown status.\n");
307 gboolean timeout_menu_display(void* data)
313 gboolean timeout_quit_program(void* data)
319 gboolean input (GIOChannel *channel)
325 if (g_io_channel_read_line(channel, &buf, &length, NULL, &err) == G_IO_STATUS_NORMAL) {
337 static void input_filename(char *filename)
339 MMSOUND_STRNCPY(g_file_name, filename, MAX_STRING_LEN);
340 g_print("\nThe input filename is '%s' \n\n",g_file_name);
344 static void input_dirname(char *dirname)
346 MMSOUND_STRNCPY(g_dir_name, dirname, MAX_PATH_LEN);
347 g_print("\nThe input directory is '%s' \n\n",g_dir_name);
351 static void __mm_sound_signal_cb1 (mm_sound_signal_name_t signal, int value, void *user_data)
354 g_print ("[%s] signal[%d], value[%d], user_data[%p]]\n", __func__, signal, value, user_data);
355 mm_sound_get_signal_value (signal, &_value);
356 g_print (" -- get value : %d\n", _value);
359 static void __mm_sound_signal_cb2 (mm_sound_signal_name_t signal, int value, void *user_data)
362 g_print ("[%s] signal[%d], value[%d], user_data[%p]]\n", __func__, signal, value, user_data);
363 mm_sound_get_signal_value (signal, &_value);
364 g_print (" -- get value : %d\n", _value);
367 unsigned int g_subscribe_id1 = 0;
368 unsigned int g_subscribe_id2 = 0;
371 static void interpret (char *cmd)
374 static int handle = -1;
375 MMSoundPlayParam soundparam = {0,};
377 switch (g_menu_state)
379 case CURRENT_STATUS_MAINMENU:
381 if(strncmp(cmd, "DS", 2) == 0) {
382 ret = mm_sound_subscribe_signal(MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, &g_subscribe_id1, __mm_sound_signal_cb1, NULL);
384 debug_log("mm_sound_subscribe_signal() failed with 0x%x\n", ret);
386 debug_log("id: %u, callback:%p\n", g_subscribe_id1, __mm_sound_signal_cb1);
387 ret = mm_sound_subscribe_signal(MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, &g_subscribe_id2, __mm_sound_signal_cb2, NULL);
389 debug_log("mm_sound_subscribe_signal() failed with 0x%x\n", ret);
391 debug_log("id: %u, callback:%p\n", g_subscribe_id2, __mm_sound_signal_cb2);
394 else if(strncmp(cmd, "DU", 2) == 0) {
395 mm_sound_unsubscribe_signal(g_subscribe_id1);
396 debug_log("unsubscribe_signal for id[%d]\n", g_subscribe_id1);
397 mm_sound_unsubscribe_signal(g_subscribe_id2);
398 debug_log("unsubscribe_signal for id[%d]\n", g_subscribe_id2);
401 else if(strncmp(cmd, "SS", 2) == 0) {
403 ret = mm_sound_send_signal(MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, 1);
405 debug_log("mm_sound_send_signal() failed with 0x%x\n", ret);
407 debug_log("mm_sound_send_signal for signal[%d], value[%d] is success\n", MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, 1);
408 mm_sound_get_signal_value (MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, &value);
409 g_print (" -- get value of RELEASE_INTERNAL_FOCUS : %d\n", value);
410 ret = mm_sound_send_signal(MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, 0);
412 debug_log("mm_sound_send_signal() failed with 0x%x\n", ret);
414 debug_log("mm_sound_send_signal for signal[%d], value[%d] is success\n", MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, 0);
415 mm_sound_get_signal_value (MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, &value);
416 g_print (" -- get value of RELEASE_INTERNAL_FOCUS : %d\n", value);
419 else if(strncmp(cmd, "GU", 2) == 0) {
421 ret = mm_sound_focus_get_id(&id);
423 debug_log("mm_sound_focus_get_id() failed with 0x%x\n", ret);
425 debug_log("id : %d\n", id);
428 else if(strncmp(cmd, "SF", 2) == 0) {
430 char input_string[128];
433 char *stream_type = NULL;
434 const char *user_data = "this is user data";
437 g_print ("1. Media\n");
438 g_print ("2. Alarm\n");
439 g_print ("3. Notification\n");
440 g_print ("4. Emergency\n");
441 g_print ("5. Voice Information\n");
442 g_print ("6. Ringtone\n");
443 g_print ("7. Ringtone Call\n");
444 g_print ("8. VOIP\n");
445 g_print ("0. Voice Recognition\n");
446 g_print("> select id and stream type: (eg. 0 3)");
448 if (fgets(input_string, sizeof(input_string)-1, stdin)) {
449 g_print ("### fgets return NULL\n");
451 flag_1 = input_string[0];
452 flag_2 = input_string[2];
454 if(flag_1 == '0') { id = 0; }
455 else if(flag_1 == '1') { id = 1; }
456 else if(flag_1 == '2') { id = 2; }
458 if(flag_2 == '1') { stream_type = "media"; }
459 else if(flag_2 == '2') { stream_type = "alarm"; }
460 else if(flag_2 == '3') { stream_type = "notification"; }
461 else if(flag_2 == '4') { stream_type = "emergency"; }
462 else if(flag_2 == '5') { stream_type = "voice-information"; }
463 else if(flag_2 == '6') { stream_type = "ringtone"; }
464 else if(flag_2 == '7') { stream_type = "ringtone-call"; }
465 else if(flag_2 == '8') { stream_type = "voip"; }
466 else if(flag_2 == '0') { stream_type = "voice-recognition"; }
467 else { stream_type = "media"; }
469 ret = mm_sound_register_focus(id, stream_type, (id == 0)? focus_cb0 : focus_cb1, (void*)user_data);
471 g_print("failed to mm_sound_register_focus(), ret[0x%x]\n", ret);
473 g_print("id[%d], stream_type[%s], callback fun[%p]\n", id, stream_type, (id == 0)? focus_cb0 : focus_cb1);
477 else if(strncmp(cmd, "FFS", 3) == 0) {
479 char input_string[128];
482 char *stream_type = NULL;
483 const char *user_data = "this is user data";
486 g_print ("1. Media\n");
487 g_print ("2. Alarm\n");
488 g_print ("3. Notification\n");
489 g_print ("4. Emergency\n");
490 g_print ("5. Voice Information\n");
491 g_print ("6. Ringtone\n");
492 g_print ("7. Ringtone Call\n");
493 g_print ("8. VOIP\n");
494 g_print ("0. Voice Recognition\n");
495 g_print("> select id and stream type: (eg. 0 3)");
497 if (fgets(input_string, sizeof(input_string)-1, stdin)) {
498 g_print ("### fgets return NULL\n");
500 flag_1 = input_string[0];
501 flag_2 = input_string[2];
503 if(flag_1 == '0') { id = 0; }
504 else if(flag_1 == '1') { id = 1; }
505 else if(flag_1 == '2') { id = 2; }
507 if(flag_2 == '1') { stream_type = "media"; }
508 else if(flag_2 == '2') { stream_type = "alarm"; }
509 else if(flag_2 == '3') { stream_type = "notification"; }
510 else if(flag_2 == '4') { stream_type = "emergency"; }
511 else if(flag_2 == '5') { stream_type = "voice-information"; }
512 else if(flag_2 == '6') { stream_type = "ringtone"; }
513 else if(flag_2 == '7') { stream_type = "ringtone-call"; }
514 else if(flag_2 == '8') { stream_type = "voip"; }
515 else if(flag_2 == '0') { stream_type = "voice-recognition"; }
516 else { stream_type = "media"; }
518 ret = mm_sound_register_focus_for_session(id, getpid(), stream_type, (id == 0)? focus_cb0 : focus_cb1, (void*)user_data);
520 g_print("failed to mm_sound_register_focus_for_session(), ret[0x%x]\n", ret);
522 g_print("id[%d], stream_type[%s], callback fun[%p]\n", id, stream_type, (id == 0)? focus_cb0 : focus_cb1);
526 else if(strncmp(cmd, "UF", 2) == 0) {
528 char input_string[128];
532 g_print("> select id:");
533 if (fgets(input_string, sizeof(input_string)-1, stdin)) {
534 g_print ("### fgets return NULL\n");
536 flag_1 = input_string[0];
537 if(flag_1 == '0') { id = 0; }
538 else if(flag_1 == '1') { id = 1; }
539 else if(flag_1 == '2') { id = 2; }
541 ret = mm_sound_unregister_focus(id);
543 g_print("failed to mm_sound_unregister_focus(), ret[0x%x]\n", ret);
547 else if(strncmp(cmd, "DF", 2) == 0) {
549 char input_string[128];
552 bool reacquisition = true;
554 g_print ("1. enable auto reacquirement\n");
555 g_print ("2. disable auto reacquirement\n");
556 g_print("> select id and option: (eg. 0 1)");
557 if (fgets(input_string, sizeof(input_string)-1, stdin)) {
558 g_print ("### fgets return NULL\n");
560 flag_1 = input_string[0];
561 flag_2 = input_string[2];
563 if(flag_1 == '0') { id = 0; }
564 else if(flag_1 == '1') { id = 1; }
565 else if(flag_1 == '2') { id = 2; }
568 if(flag_2 == '1') { reacquisition = true; }
569 else if(flag_2 == '2') { reacquisition = false; }
570 else { reacquisition = true; }
571 ret = mm_sound_set_focus_reacquisition(id, reacquisition);
573 g_print("failed to mm_sound_disable_focus_reacquirement(), ret[0x%x]\n", ret);
577 else if(strncmp(cmd, "AF", 2) == 0) {
579 char input_string[128];
582 mm_sound_focus_type_e type = FOCUS_FOR_PLAYBACK;
584 g_print ("1. focus for playback\n");
585 g_print ("2. focus for recording\n");
586 g_print ("3. focus for both\n");
587 g_print("> select id and focus_type: (eg. 0 1)");
588 if (fgets(input_string, sizeof(input_string)-1, stdin)) {
589 g_print ("### fgets return NULL\n");
591 flag_1 = input_string[0];
592 flag_2 = input_string[2];
594 if(flag_1 == '0') { id = 0; }
595 else if(flag_1 == '1') { id = 1; }
598 if(flag_2 == '1') { type = FOCUS_FOR_PLAYBACK; }
599 else if(flag_2 == '2') { type = FOCUS_FOR_CAPTURE; }
600 else { type = FOCUS_FOR_BOTH; }
601 ret = mm_sound_acquire_focus(id, type, "additional_info. for acquire");
603 g_print("failed to mm_sound_acquire_focus(), ret[0x%x]\n", ret);
607 else if(strncmp(cmd, "RF", 2) == 0) {
609 char input_string[128];
612 mm_sound_focus_type_e type = FOCUS_FOR_PLAYBACK;
614 g_print ("1. focus for playback\n");
615 g_print ("2. focus for recording\n");
616 g_print ("3. focus for all\n");
617 g_print("> select id and focus_type: (eg. 0 1)");
618 if (fgets(input_string, sizeof(input_string)-1, stdin)) {
619 g_print ("### fgets return NULL\n");
621 flag_1 = input_string[0];
622 flag_2 = input_string[2];
624 if(flag_1 == '0') { id = 0; }
625 else if(flag_1 == '1') { id = 1; }
628 if(flag_2 == '1') { type = FOCUS_FOR_PLAYBACK; }
629 else if(flag_2 == '2') { type = FOCUS_FOR_CAPTURE; }
630 else { type = FOCUS_FOR_BOTH; }
631 ret = mm_sound_release_focus(id, type, "additional_info. for release");
633 g_print("failed to mm_sound_release_focus(), ret[0x%x]\n", ret);
637 else if(strncmp(cmd, "WFS", 3) == 0) {
639 char input_string[128];
642 const char *user_data = "this is user data for watch";
645 g_print ("1. playback\n");
646 g_print ("2. recording\n");
647 g_print ("3. both\n");
648 g_print("> select interest focus type:");
650 if (fgets(input_string, sizeof(input_string)-1, stdin)) {
651 g_print ("### fgets return NULL\n");
653 flag_1 = input_string[0];
655 if(flag_1 == '1') { type = 1; }
656 else if(flag_1 == '2') { type = 2; }
657 else if(flag_1 == '3') { type = 3; }
659 ret = mm_sound_set_focus_watch_callback_for_session(getpid(), type, focus_watch_cb, (void*)user_data, &g_focus_watch_index);
661 g_print("failed to mm_sound_set_focus_watch_callback(), ret[0x%x]\n", ret);
663 g_print("index[%d], type[%d], callback fun[%p]\n", g_focus_watch_index, type, focus_watch_cb);
667 else if(strncmp(cmd, "WS", 2) == 0) {
669 char input_string[128];
672 const char *user_data = "this is user data for watch";
675 g_print ("1. playback\n");
676 g_print ("2. recording\n");
677 g_print ("3. both\n");
678 g_print("> select interest focus type:");
680 if (fgets(input_string, sizeof(input_string)-1, stdin)) {
681 g_print ("### fgets return NULL\n");
683 flag_1 = input_string[0];
685 if(flag_1 == '1') { type = 1; }
686 else if(flag_1 == '2') { type = 2; }
687 else if(flag_1 == '3') { type = 3; }
689 ret = mm_sound_set_focus_watch_callback(type, focus_watch_cb, (void*)user_data, &g_focus_watch_index);
691 g_print("failed to mm_sound_set_focus_watch_callback(), ret[0x%x]\n", ret);
693 g_print("index[%d], type[%d], callback fun[%p]\n", g_focus_watch_index, type, focus_watch_cb);
697 else if(strncmp(cmd, "WU", 2) == 0) {
699 ret = mm_sound_unset_focus_watch_callback(g_focus_watch_index);
701 g_print("failed to mm_sound_unset_focus_watch_callback(), ret[0x%x]\n", ret);
705 else if(strncmp(cmd, "k", 1) == 0)
707 if(strncmp(cmd, "k", 1) == 0)
710 ret = mm_sound_play_keysound(KEYTONE_FILE, 0);
712 debug_log("keysound play failed with 0x%x\n", ret);
714 else if (strcmp(cmd, "dbus-m") == 0) {
719 g_print("dbus method test call\n");
720 ret = mm_sound_test(a, b, &result_val);
722 g_print("failed to mm_sound_test(), ret[0x%x]\n", ret);
724 g_print("Got answer : %d\n", result_val);
726 } else if (strcmp(cmd, "dbus-a") == 0) {
729 g_print("dbus method test add callback\n");
730 g_print("my testsuite pid : %u tid : %ld\n", getpid(), pthread_self());
731 ret = mm_sound_add_test_callback(mm_sound_test_cb1, (void *)user_data, &g_subs_id_test);
733 g_print("failed to mm_sound_add_test_callback(), ret[0x%x]\n", ret);
735 g_print("add test callback success\n");
737 } else if (strcmp(cmd, "dbus-r") == 0) {
739 g_print("dbus method test remove callback\n");
740 ret = mm_sound_remove_test_callback(g_subs_id_test);
742 g_print("failed to mm_sound_remove_test_callback(), ret[0x%x]\n", ret);
744 g_print("remove test callback success\n");
747 else if(strncmp(cmd, "q", 1) == 0)
749 unsigned int value = 100;
750 ret = mm_sound_volume_get_value(g_volume_type, &value);
752 debug_log("mm_sound_volume_get_value 0x%x\n", ret);
755 g_print("*** MEDIA VOLUME : %u ***\n", value);
756 g_volume_value = value;
759 else if(strncmp(cmd, "e", 1) == 0)
760 {//set media volume down
761 unsigned int value = 100;
762 ret = mm_sound_volume_get_value(g_volume_type, &value);
764 debug_log("mm_sound_volume_get_value 0x%x\n", ret);
771 ret = mm_sound_volume_set_value(g_volume_type, value);
773 debug_log("mm_sound_volume_set_value 0x%x\n", ret);
777 else if(strncmp(cmd, "r", 1) == 0)
779 unsigned int value = 100;
780 ret = mm_sound_volume_get_value(VOLUME_TYPE_SYSTEM, &value);
782 debug_log("mm_sound_volume_get_value 0x%x\n", ret);
785 g_print("*** SYSTEM VOLUME : %u ***\n", value);
786 g_volume_value = value;
789 else if(strncmp(cmd, "y", 1) == 0)
790 {//set media volume down
791 unsigned int value = 100;
792 ret = mm_sound_volume_get_value(VOLUME_TYPE_SYSTEM, &value);
794 debug_log("mm_sound_volume_get_value 0x%x\n", ret);
801 ret = mm_sound_volume_set_value(VOLUME_TYPE_SYSTEM, value);
803 debug_log("mm_sound_volume_set_value 0x%x\n", ret);
805 g_print("Current System volume is %d\n", value);
809 else if(strncmp(cmd, "g", 1) == 0)
811 unsigned int value = 100;
812 ret = mm_sound_volume_get_value(VOLUME_TYPE_VOICE, &value);
814 debug_log("mm_sound_volume_get_value 0x%x\n", ret);
817 g_print("*** VOICE VOLUME : %u ***\n", value);
818 g_volume_value = value;
821 else if(strncmp(cmd, "j", 1) == 0)
822 {//set voice volume down
823 unsigned int value = 100;
824 ret = mm_sound_volume_get_value(VOLUME_TYPE_VOICE, &value);
826 debug_log("mm_sound_volume_get_value 0x%x\n", ret);
833 ret = mm_sound_volume_set_value(VOLUME_TYPE_VOICE, value);
835 debug_log("mm_sound_volume_set_value 0x%x\n", ret);
837 g_print("Current Voice volume is %d\n", value);
841 else if(strncmp(cmd, "an", 2) == 0)
843 debug_log("volume is %d type, %d\n", g_volume_type, g_volume_value);
844 ret = mm_sound_play_sound(g_file_name, g_volume_type, mycallback ,"USERDATA", &handle);
846 debug_log("mm_sound_play_sound() failed with 0x%x\n", ret);
848 else if(strncmp(cmd, "as", 2) == 0)
850 debug_log("stream %s type, %d\n", "media", g_volume_value);
851 ret = mm_sound_play_sound_with_stream_info(g_file_name, "media", -1, 1, mycallback ,"USERDATA", &handle);
853 debug_log("mm_sound_play_sound() failed with 0x%x\n", ret);
855 else if(strncmp(cmd, "A", 1) == 0)
857 debug_log("volume is %d type, %d\n", g_volume_type, g_volume_value);
858 ret = mm_sound_play_loud_solo_sound(g_file_name, g_volume_type, mycallback ,"USERDATA", &handle);
860 debug_log("mm_sound_play_sound_loud_solo() failed with 0x%x\n", ret);
862 else if(strncmp(cmd, "FN", 2) == 0)
865 char input_string[128] = "";
869 int volume_type = -1;
870 bool enable_session = 0;
871 MMSoundTone_t tone = MM_SOUND_TONE_DTMF_0;
875 g_print("enter number(0~H exit:q), volume type(0~7), volume(0.0~1.0), time(ms), enable_session(0:unable , 1:enable):\t ");
876 if (fgets(input_string, sizeof(input_string)-1, stdin) == NULL) {
877 g_print ("### fgets return NULL\n");
879 tok = strtok(input_string, " ");
884 else if(tok[0] < '0' || tok[0] > '~') {
885 if(tok[0] == '*' || tok[0] == '#')
891 if(num >= '0' && num <= '9') {
892 tone = (MMSoundTone_t)(num - '0');
894 else if(num == '*') {
895 tone = MM_SOUND_TONE_DTMF_S;
897 else if(num == '#') {
898 tone =MM_SOUND_TONE_DTMF_P;
900 else if(num == 'A') { tone = MM_SOUND_TONE_DTMF_A; }
901 else if(num == 'B') { tone = MM_SOUND_TONE_DTMF_B; }
902 else if(num == 'C') { tone = MM_SOUND_TONE_DTMF_C; }
903 else if(num == 'D') { tone = MM_SOUND_TONE_DTMF_D; }
904 else if(num == 'E') { tone = MM_SOUND_TONE_SUP_DIAL; }
905 else if(num == 'F') { tone = MM_SOUND_TONE_ANSI_DIAL; }
906 else if(num == 'G') { tone = MM_SOUND_TONE_JAPAN_DIAL; }
907 else if(num == 'H') { tone = MM_SOUND_TONE_SUP_BUSY; }
908 else if(num == 'I') { tone = MM_SOUND_TONE_ANSI_BUSY; }
909 else if(num == 'J') { tone = MM_SOUND_TONE_JAPAN_BUSY; }
910 else if(num == 'K') { tone = MM_SOUND_TONE_SUP_CONGESTION; }
911 else if(num == 'L') { tone = MM_SOUND_TONE_ANSI_CONGESTION; }
912 else if(num == 'M') { tone = MM_SOUND_TONE_SUP_RADIO_ACK; }
913 else if(num == 'N') { tone = MM_SOUND_TONE_JAPAN_RADIO_ACK; }
914 else if(num == 'O') { tone = MM_SOUND_TONE_SUP_RADIO_NOTAVAIL; }
915 else if(num == 'P') { tone = MM_SOUND_TONE_SUP_ERROR; }
916 else if(num == 'Q') { tone = MM_SOUND_TONE_SUP_CALL_WAITING; }
917 else if(num == 'R') { tone = MM_SOUND_TONE_ANSI_CALL_WAITING; }
918 else if(num == 'S') { tone = MM_SOUND_TONE_SUP_RINGTONE; }
919 else if(num == 'T') { tone = MM_SOUND_TONE_ANSI_RINGTONE; }
920 else if(num == 'U') { tone = MM_SOUND_TONE_PROP_BEEP; }
921 else if(num == 'V') { tone = MM_SOUND_TONE_PROP_ACK; }
922 else if(num == 'W') { tone = MM_SOUND_TONE_PROP_NACK; }
923 else if(num == 'X') { tone = MM_SOUND_TONE_PROP_PROMPT; }
924 else if(num == 'Y') { tone = MM_SOUND_TONE_PROP_BEEP2; }
925 else if(num == 'Z') { tone =MM_SOUND_TONE_CDMA_HIGH_SLS; }
926 else if(num == '[') { tone = MM_SOUND_TONE_CDMA_MED_SLS; }
927 else if(num == ']') { tone = MM_SOUND_TONE_CDMA_LOW_SLS; }
928 else if(num == '^') { tone =MM_SOUND_TONE_CDMA_HIGH_S_X4; }
929 else if(num == '_') { tone =MM_SOUND_TONE_CDMA_MED_S_X4; }
930 else if(num == 'a') { tone =MM_SOUND_TONE_CDMA_LOW_S_X4; }
931 else if(num == 'b') { tone =MM_SOUND_TONE_CDMA_HIGH_PBX_L; }
932 else if(num == 'c') { tone =MM_SOUND_TONE_CDMA_MED_PBX_L; }
933 else if(num == 'd') { tone =MM_SOUND_TONE_CDMA_LOW_PBX_L; }
934 else if(num == 'e') { tone =MM_SOUND_TONE_CDMA_HIGH_PBX_SS; }
935 else if(num == 'f') { tone =MM_SOUND_TONE_CDMA_MED_PBX_SS; }
936 else if(num == 'g') { tone =MM_SOUND_TONE_CDMA_LOW_PBX_SS; }
937 else if(num == 'h') { tone =MM_SOUND_TONE_CDMA_HIGH_PBX_SSL; }
938 else if(num == 'i') { tone =MM_SOUND_TONE_CDMA_MED_PBX_SSL; }
939 else if(num == 'j') { tone =MM_SOUND_TONE_CDMA_LOW_PBX_SSL; }
940 else if(num == 'k') { tone =MM_SOUND_TONE_CDMA_HIGH_PBX_SLS; }
941 else if(num == 'l') { tone =MM_SOUND_TONE_CDMA_MED_PBX_SLS; }
942 else if(num == 'm') { tone =MM_SOUND_TONE_CDMA_LOW_PBX_SLS; }
943 else if(num == 'n') { tone =MM_SOUND_TONE_CDMA_HIGH_PBX_S_X4; }
944 else if(num == 'o') { tone =MM_SOUND_TONE_CDMA_MED_PBX_S_X4; }
945 else if(num == 'p') { tone =MM_SOUND_TONE_CDMA_LOW_PBX_S_X4; }
946 else if(num == 'q') { tone =MM_SOUND_TONE_CDMA_ALERT_NETWORK_LITE; }
947 else if(num == 'r') { tone =MM_SOUND_TONE_CDMA_ALERT_AUTOREDIAL_LITE; }
948 else if(num == 's') { tone =MM_SOUND_TONE_CDMA_ONE_MIN_BEEP; }
949 else if(num == 't') { tone =MM_SOUND_TONE_CDMA_KEYPAD_VOLUME_KEY_LITE; }
950 else if(num == 'u') { tone =MM_SOUND_TONE_CDMA_PRESSHOLDKEY_LITE; }
951 else if(num == 'v') { tone =MM_SOUND_TONE_CDMA_ALERT_INCALL_LITE; }
952 else if(num == 'w') { tone =MM_SOUND_TONE_CDMA_EMERGENCY_RINGBACK; }
953 else if(num == 'x') { tone =MM_SOUND_TONE_CDMA_ALERT_CALL_GUARD; }
954 else if(num == 'y') { tone =MM_SOUND_TONE_CDMA_SOFT_ERROR_LITE; }
955 else if(num == 'z') { tone =MM_SOUND_TONE_CDMA_CALLDROP_LITE; }
956 else if(num == '{') { tone =MM_SOUND_TONE_LOW_FRE; }
957 else if(num == '}') { tone =MM_SOUND_TONE_MED_FRE; }
958 else if(num == '~') { tone =MM_SOUND_TONE_HIGH_FRE; }
959 tok = strtok(NULL, " ");
960 if(tok) volume_type = (double)atoi(tok);
962 tok = strtok(NULL, " ");
963 if(tok) volume = (double)atof(tok);
965 tok = strtok(NULL, " ");
968 tonetime = atoi(tok);
972 tonetime = MIN_TONE_PLAY_TIME;
975 tok = strtok(NULL, " ");
976 if(tok) enable_session = (bool)atof(tok);
978 debug_log("volume type: %d\t volume is %f\t tonetime: %d\t enable_session %d \n", volume_type, volume, tonetime, enable_session);
979 ret = mm_sound_play_tone_ex(tone, volume_type, volume, tonetime, &handle, enable_session);
981 debug_log ("[magpie] Play DTMF sound cannot be played ! %d\n", handle);
984 else if(strncmp(cmd, "FS", 2) == 0)
987 char input_string[128] = "";
989 char *stream_type = NULL;
992 MMSoundTone_t tone = MM_SOUND_TONE_DTMF_0;
996 g_print("enter number(0~H exit:q), stream type(media, system, ...), volume(0.0~1.0), time(ms):\t ");
997 if (fgets(input_string, sizeof(input_string)-1, stdin) == NULL) {
998 g_print ("### fgets return NULL\n");
1000 tok = strtok(input_string, " ");
1005 else if(tok[0] < '0' || tok[0] > '~') {
1006 if(tok[0] == '*' || tok[0] == '#')
1012 if(num >= '0' && num <= '9') {
1013 tone = (MMSoundTone_t)(num - '0');
1015 else if(num == '*') {
1016 tone = MM_SOUND_TONE_DTMF_S;
1018 else if(num == '#') {
1019 tone =MM_SOUND_TONE_DTMF_P;
1021 else if(num == 'A') { tone = MM_SOUND_TONE_DTMF_A; }
1022 else if(num == 'B') { tone = MM_SOUND_TONE_DTMF_B; }
1023 else if(num == 'C') { tone = MM_SOUND_TONE_DTMF_C; }
1024 else if(num == 'D') { tone = MM_SOUND_TONE_DTMF_D; }
1025 else if(num == 'E') { tone = MM_SOUND_TONE_SUP_DIAL; }
1026 else if(num == 'F') { tone = MM_SOUND_TONE_ANSI_DIAL; }
1027 else if(num == 'G') { tone = MM_SOUND_TONE_JAPAN_DIAL; }
1028 else if(num == 'H') { tone = MM_SOUND_TONE_SUP_BUSY; }
1029 else if(num == 'I') { tone = MM_SOUND_TONE_ANSI_BUSY; }
1030 else if(num == 'J') { tone = MM_SOUND_TONE_JAPAN_BUSY; }
1031 else if(num == 'K') { tone = MM_SOUND_TONE_SUP_CONGESTION; }
1032 else if(num == 'L') { tone = MM_SOUND_TONE_ANSI_CONGESTION; }
1033 else if(num == 'M') { tone = MM_SOUND_TONE_SUP_RADIO_ACK; }
1034 else if(num == 'N') { tone = MM_SOUND_TONE_JAPAN_RADIO_ACK; }
1035 else if(num == 'O') { tone = MM_SOUND_TONE_SUP_RADIO_NOTAVAIL; }
1036 else if(num == 'P') { tone = MM_SOUND_TONE_SUP_ERROR; }
1037 else if(num == 'Q') { tone = MM_SOUND_TONE_SUP_CALL_WAITING; }
1038 else if(num == 'R') { tone = MM_SOUND_TONE_ANSI_CALL_WAITING; }
1039 else if(num == 'S') { tone = MM_SOUND_TONE_SUP_RINGTONE; }
1040 else if(num == 'T') { tone = MM_SOUND_TONE_ANSI_RINGTONE; }
1041 else if(num == 'U') { tone = MM_SOUND_TONE_PROP_BEEP; }
1042 else if(num == 'V') { tone = MM_SOUND_TONE_PROP_ACK; }
1043 else if(num == 'W') { tone = MM_SOUND_TONE_PROP_NACK; }
1044 else if(num == 'X') { tone = MM_SOUND_TONE_PROP_PROMPT; }
1045 else if(num == 'Y') { tone = MM_SOUND_TONE_PROP_BEEP2; }
1046 else if(num == 'Z') { tone =MM_SOUND_TONE_CDMA_HIGH_SLS; }
1047 else if(num == '[') { tone = MM_SOUND_TONE_CDMA_MED_SLS; }
1048 else if(num == ']') { tone = MM_SOUND_TONE_CDMA_LOW_SLS; }
1049 else if(num == '^') { tone =MM_SOUND_TONE_CDMA_HIGH_S_X4; }
1050 else if(num == '_') { tone =MM_SOUND_TONE_CDMA_MED_S_X4; }
1051 else if(num == 'a') { tone =MM_SOUND_TONE_CDMA_LOW_S_X4; }
1052 else if(num == 'b') { tone =MM_SOUND_TONE_CDMA_HIGH_PBX_L; }
1053 else if(num == 'c') { tone =MM_SOUND_TONE_CDMA_MED_PBX_L; }
1054 else if(num == 'd') { tone =MM_SOUND_TONE_CDMA_LOW_PBX_L; }
1055 else if(num == 'e') { tone =MM_SOUND_TONE_CDMA_HIGH_PBX_SS; }
1056 else if(num == 'f') { tone =MM_SOUND_TONE_CDMA_MED_PBX_SS; }
1057 else if(num == 'g') { tone =MM_SOUND_TONE_CDMA_LOW_PBX_SS; }
1058 else if(num == 'h') { tone =MM_SOUND_TONE_CDMA_HIGH_PBX_SSL; }
1059 else if(num == 'i') { tone =MM_SOUND_TONE_CDMA_MED_PBX_SSL; }
1060 else if(num == 'j') { tone =MM_SOUND_TONE_CDMA_LOW_PBX_SSL; }
1061 else if(num == 'k') { tone =MM_SOUND_TONE_CDMA_HIGH_PBX_SLS; }
1062 else if(num == 'l') { tone =MM_SOUND_TONE_CDMA_MED_PBX_SLS; }
1063 else if(num == 'm') { tone =MM_SOUND_TONE_CDMA_LOW_PBX_SLS; }
1064 else if(num == 'n') { tone =MM_SOUND_TONE_CDMA_HIGH_PBX_S_X4; }
1065 else if(num == 'o') { tone =MM_SOUND_TONE_CDMA_MED_PBX_S_X4; }
1066 else if(num == 'p') { tone =MM_SOUND_TONE_CDMA_LOW_PBX_S_X4; }
1067 else if(num == 'q') { tone =MM_SOUND_TONE_CDMA_ALERT_NETWORK_LITE; }
1068 else if(num == 'r') { tone =MM_SOUND_TONE_CDMA_ALERT_AUTOREDIAL_LITE; }
1069 else if(num == 's') { tone =MM_SOUND_TONE_CDMA_ONE_MIN_BEEP; }
1070 else if(num == 't') { tone =MM_SOUND_TONE_CDMA_KEYPAD_VOLUME_KEY_LITE; }
1071 else if(num == 'u') { tone =MM_SOUND_TONE_CDMA_PRESSHOLDKEY_LITE; }
1072 else if(num == 'v') { tone =MM_SOUND_TONE_CDMA_ALERT_INCALL_LITE; }
1073 else if(num == 'w') { tone =MM_SOUND_TONE_CDMA_EMERGENCY_RINGBACK; }
1074 else if(num == 'x') { tone =MM_SOUND_TONE_CDMA_ALERT_CALL_GUARD; }
1075 else if(num == 'y') { tone =MM_SOUND_TONE_CDMA_SOFT_ERROR_LITE; }
1076 else if(num == 'z') { tone =MM_SOUND_TONE_CDMA_CALLDROP_LITE; }
1077 else if(num == '{') { tone =MM_SOUND_TONE_LOW_FRE; }
1078 else if(num == '}') { tone =MM_SOUND_TONE_MED_FRE; }
1079 else if(num == '~') { tone =MM_SOUND_TONE_HIGH_FRE; }
1081 stream_type = strtok(NULL, " ");
1083 tok = strtok(NULL, " ");
1084 if(tok) volume = (double)atof(tok);
1086 tok = strtok(NULL, " ");
1089 tonetime = atoi(tok);
1093 tonetime = MIN_TONE_PLAY_TIME;
1096 debug_log("stream type: %s\t volume is %f\t tonetime: %d\n", stream_type, volume, tonetime);
1097 ret = mm_sound_play_tone_with_stream_info(tone, stream_type, -1, volume, tonetime, &handle);
1099 debug_log ("[magpie] Play DTMF sound with stream type cannot be played ! %d\n", handle);
1102 else if (strncmp (cmd, "b",1) == 0)
1105 struct dirent *entry;
1106 struct stat file_stat;
1107 char fullpath[MAX_PATH_LEN]="";
1108 struct timespec start_time = {0,};
1109 struct timespec current_time = {0,};
1111 if(g_dir_name[strlen(g_dir_name)-1] == '/')
1112 g_dir_name[strlen(g_dir_name)-1] = '\0';
1114 basedir = opendir(g_dir_name);
1117 while( (entry = readdir(basedir)) != NULL)
1121 if(entry->d_name[0] == '.')
1123 memset(fullpath, '\0' ,sizeof(fullpath));
1124 snprintf(fullpath, sizeof(fullpath)-1,"%s/%s", g_dir_name, entry->d_name);
1125 debug_log("Try %s\n", fullpath);
1127 if (lstat(fullpath, &file_stat) == -1)
1130 if(S_ISREG(file_stat.st_mode))
1132 test_callback_done = 0 ;
1133 start_time.tv_sec = (long int)(time(NULL));
1134 start_time.tv_nsec = 0;
1135 ret = mm_sound_play_sound(fullpath, g_volume_type, test_callback, NULL, &handle);
1136 if(ret != MM_ERROR_NONE)
1138 debug_log("Play file error : %s\n", fullpath);
1145 debug_log("this is not regular file : %s\n", fullpath);
1148 while((test_callback_done == 0) && (playfail ==0))
1150 current_time.tv_sec = (long int)(time(NULL));
1151 current_time.tv_nsec = 0;
1152 if(current_time.tv_sec - start_time.tv_sec > 200)
1154 if((++mywait)%5 == 0)
1156 debug_log("I'm waiting callback for %d seconds after play %s\n",
1157 (int)(current_time.tv_sec - start_time.tv_sec),
1163 debug_log("goto next file\n");
1169 debug_log("Cannot Open such a directory %s\n", g_dir_name);
1174 else if (strncmp (cmd, "c",1) == 0)
1176 soundparam.volume = g_volume_value;
1177 soundparam.loop = -1; /* loop case */
1178 soundparam.callback = mycallback;
1179 soundparam.data = NULL;
1180 soundparam.mem_ptr = NULL;
1181 soundparam.mem_size = 0;
1182 soundparam.filename = g_file_name;
1183 soundparam.volume_config = g_volume_type;
1185 if ((mm_sound_play_sound_ex (&soundparam, &handle))<0)
1186 debug_log ("Play EX sound cannot be played !\n");
1188 debug_log ("Ex sound is played Handle is [%d]\n", handle);
1190 else if (strncmp (cmd, "f",1) == 0) {
1191 g_menu_state=CURRENT_STATUS_FILENAME;
1194 else if (strncmp (cmd, "d",1) == 0) {
1195 g_menu_state=CURRENT_STATUS_DIRNAME;
1197 else if (strncmp (cmd, "s",1) == 0) {
1198 if(mm_sound_stop_sound(handle))
1199 debug_log (" Cannot stop sound !!! %d \n", handle);
1201 else if (strncmp (cmd, "1",1) == 0) {
1203 g_print("Not supported - Set path for speaker playback\n");
1206 else if (strncmp (cmd, "2",1) == 0) {
1208 g_print("Not supported - Set path for headset playback\n");
1210 else if (strncmp (cmd, "3",1) == 0) {
1213 else if (strncmp (cmd, "4",1) == 0) {
1215 g_print("Not supported - Set path for recording with main mic\n");
1217 else if (strncmp (cmd, "5",1) == 0) {
1220 else if (strncmp (cmd, "6",1) == 0) {
1222 g_print("Not supported - Set path for voicecall\n");
1224 else if (strncmp (cmd, "7",1) == 0) {
1226 g_print("Not supported - release path for voicecall\n");
1228 else if (strncmp (cmd, "8",1) == 0) {
1230 g_print("Not supported - Set path for VT call\n");
1233 else if (strncmp (cmd, "9",1) == 0) {
1235 g_print("Not supported - release path for VT call\n");
1238 /* -------------------------- Route Test : Starts -------------------------- */
1240 g_print("==================================================================\n");
1241 g_print(" Audio route APIs\n");
1242 g_print("==================================================================\n");
1243 g_print("u : Foreach Available Routes \t");
1244 g_print("i : Get Active Devices \n");
1245 g_print("o : Add Available Routes Callback \t");
1246 g_print("O : Remove Available Routes Callback \n");
1247 g_print("p : Add Active Route Callback\t");
1248 g_print("P : Remove Active Route Callback \n");
1249 g_print("{ : Get BT A2DP Status\n");
1251 else if(strncmp(cmd, "z", 1) == 0) {
1252 if(MM_ERROR_NONE != mm_session_init(MM_SESSION_TYPE_CALL))
1254 g_print("Call session init failed\n");
1257 else if(strncmp(cmd, "Z", 1) == 0) {
1258 if(MM_ERROR_NONE != mm_session_init(MM_SESSION_TYPE_VIDEOCALL))
1260 g_print("VideoCall session init failed\n");
1263 else if(strncmp(cmd, "N", 1) == 0) {
1264 if(MM_ERROR_NONE != mm_session_init(MM_SESSION_TYPE_NOTIFY))
1266 g_print("Notify session init failed\n");
1269 else if(strncmp(cmd, "n", 1) == 0) {
1270 if(MM_ERROR_NONE != mm_session_init(MM_SESSION_TYPE_VOIP))
1272 g_print("VOIP session init failed\n");
1275 else if(strncmp(cmd, "v", 1) == 0) {
1276 if(MM_ERROR_NONE != mm_session_finish())
1278 g_print("Call session finish failed\n");
1282 else if(strncmp(cmd, "L", 1) == 0) {
1284 mm_sound_device_flags_e flags = MM_SOUND_DEVICE_ALL_FLAG;
1285 MMSoundDeviceList_t device_list;
1286 mm_sound_device_type_e device_type = 0;
1287 mm_sound_device_io_direction_e io_direction = 0;
1288 mm_sound_device_state_e state = 0;
1291 MMSoundDevice_t device_h = NULL;
1292 int dret = MM_ERROR_NONE;
1294 ret = mm_sound_get_current_device_list(flags, &device_list);
1296 g_print("failed to mm_sound_get_current_device_list(), ret[0x%x]\n", ret);
1298 g_print("device_list[%p], device_h[%p]\n", device_list, device_h);
1300 dret = mm_sound_get_next_device (device_list, &device_h);
1302 debug_error("failed to mm_sound_get_next_device(), dret[0x%x]\n", dret);
1304 ret = mm_sound_get_device_type(device_h, &device_type);
1306 debug_error("failed to mm_sound_get_device_type()\n");
1308 ret = mm_sound_get_device_io_direction(device_h, &io_direction);
1310 debug_error("failed to mm_sound_get_device_io_direction()\n");
1312 ret = mm_sound_get_device_state(device_h, &state);
1314 debug_error("failed to mm_sound_get_device_state()\n");
1316 ret = mm_sound_get_device_id(device_h, &id);
1318 debug_error("failed to mm_sound_get_device_id()\n");
1320 ret = mm_sound_get_device_name(device_h, &name);
1322 debug_error("failed to mm_sound_get_device_name()\n");
1324 debug_log("*** --- [NEXT DEVICE] type[%d], id[%d], io_direction[%d], state[%d], name[%s]\n", device_type, id, io_direction, state, name);
1326 } while (dret == MM_ERROR_NONE);
1328 dret = MM_ERROR_NONE;
1329 dret = mm_sound_get_prev_device (device_list, &device_h);
1331 debug_error("failed to mm_sound_get_prev_device(), dret[0x%x]\n", dret);
1333 ret = mm_sound_get_device_type(device_h, &device_type);
1335 debug_error("failed to mm_sound_get_device_type()\n");
1337 ret = mm_sound_get_device_io_direction(device_h, &io_direction);
1339 debug_error("failed to mm_sound_get_device_io_direction()\n");
1341 ret = mm_sound_get_device_state(device_h, &state);
1343 debug_error("failed to mm_sound_get_device_state()\n");
1345 ret = mm_sound_get_device_id(device_h, &id);
1347 debug_error("failed to mm_sound_get_device_id()\n");
1349 ret = mm_sound_get_device_name(device_h, &name);
1351 debug_error("failed to mm_sound_get_device_name()\n");
1353 debug_log("*** --- [PREV DEVICE] type[%d], id[%d], io_direction[%d], state[%d], name[%s]\n", device_type, id, io_direction, state, name);
1355 } while (dret == MM_ERROR_NONE);
1359 else if(strncmp(cmd, "I", 1) == 0) {
1361 MMSoundDevice_t device_h = NULL;
1362 mm_sound_device_type_e device_type = 0;
1363 mm_sound_device_io_direction_e io_direction = 0;
1364 mm_sound_device_state_e state = 0;
1366 int id = 0, input_id = 0;
1367 char input_string[128];
1370 g_print ("> Input id : ");
1372 if (fgets(input_string, sizeof(input_string)-1, stdin)) {
1373 input_id = atoi(input_string);
1375 ret = mm_sound_get_device_by_id(input_id, &device_h);
1376 if (ret == MM_ERROR_NONE) {
1377 ret = mm_sound_get_device_type(device_h, &device_type);
1379 g_print("failed to mm_sound_get_device_type()\n");
1380 ret = mm_sound_get_device_io_direction(device_h, &io_direction);
1382 g_print("failed to mm_sound_get_device_io_direction()\n");
1383 ret = mm_sound_get_device_state(device_h, &state);
1385 g_print("failed to mm_sound_get_device_state()\n");
1386 ret = mm_sound_get_device_id(device_h, &id);
1388 g_print("failed to mm_sound_get_device_id()\n");
1389 ret = mm_sound_get_device_name(device_h, &name);
1391 g_print("failed to mm_sound_get_device_name()\n");
1392 g_print("*** --- type[%d], id[%d], io_direction[%d], state[%d], name[%s]\n", device_type, id, io_direction, state, name);
1394 g_print("failed to mm_sound_get_device_by_id()\n");
1397 g_print("### fgets return NULL\n");
1401 else if(strncmp(cmd, "C", 1) == 0) {
1403 char input_string[128];
1404 mm_sound_device_flags_e device_flag_1 = MM_SOUND_DEVICE_ALL_FLAG;
1405 mm_sound_device_flags_e device_flag_2 = MM_SOUND_DEVICE_ALL_FLAG;
1406 mm_sound_device_flags_e device_flag_3 = MM_SOUND_DEVICE_ALL_FLAG;
1408 char flag_1, flag_2, flag_3;
1411 g_print ("1. IO_DIRECTION_IN_FLAG\n");
1412 g_print ("2. IO_DIRECTION_OUT_FLAG\n");
1413 g_print ("3. IO_DIRECTION_BOTH_FLAG\n");
1414 g_print ("4. TYPE_INTERNAL_FLAG\n");
1415 g_print ("5. TYPE_EXTERNAL_FLAG\n");
1416 g_print ("6. STATE_DEACTIVATED_FLAG\n");
1417 g_print ("7. STATE_ACTIVATED_FLAG\n");
1418 g_print ("8. ALL_FLAG\n");
1419 g_print("> select flag numbers (total 3): (eg. 2 5 7)");
1421 if (fgets(input_string, sizeof(input_string)-1, stdin)) {
1422 g_print ("### fgets return NULL\n");
1424 flag_1 = input_string[0];
1425 flag_2 = input_string[2];
1426 flag_3 = input_string[4];
1428 if(flag_1 == '1') { device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG; }
1429 else if(flag_1 == '2') { device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG; }
1430 else if(flag_1 == '3') { device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG; }
1431 else if(flag_1 == '4') { device_flag_1 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG; }
1432 else if(flag_1 == '5') { device_flag_1 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG; }
1433 else if(flag_1 == '6') { device_flag_1 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG; }
1434 else if(flag_1 == '7') { device_flag_1 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG; }
1435 else if(flag_1 == '8') { device_flag_1 = MM_SOUND_DEVICE_ALL_FLAG; }
1436 if(flag_2 == '1') { device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG; }
1437 else if(flag_2 == '2') { device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG; }
1438 else if(flag_2 == '3') { device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG; }
1439 else if(flag_2 == '4') { device_flag_2 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG; }
1440 else if(flag_2 == '5') { device_flag_2 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG; }
1441 else if(flag_2 == '6') { device_flag_2 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG; }
1442 else if(flag_2 == '7') { device_flag_2 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG; }
1443 else if(flag_2 == '8') { device_flag_2 = MM_SOUND_DEVICE_ALL_FLAG; }
1444 if(flag_3 == '1') { device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG; }
1445 else if(flag_3 == '2') { device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG; }
1446 else if(flag_3 == '3') { device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG; }
1447 else if(flag_3 == '4') { device_flag_3 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG; }
1448 else if(flag_3 == '5') { device_flag_3 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG; }
1449 else if(flag_3 == '6') { device_flag_3 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG; }
1450 else if(flag_3 == '7') { device_flag_3 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG; }
1451 else if(flag_3 == '8') { device_flag_3 = MM_SOUND_DEVICE_ALL_FLAG; }
1452 g_print("device_connected_callback");
1453 ret = mm_sound_add_device_connected_callback(device_flag_1|device_flag_2|device_flag_3, device_connected_cb, NULL, &g_subs_id_device_conn);
1455 g_print("failed to mm_sound_add_device_connected_callback(), ret[0x%x]\n", ret);
1457 g_print("device_flags[0x%x], callback fun[%p], subs_id[%u]\n", device_flag_1|device_flag_2|device_flag_3, device_connected_cb, g_subs_id_device_conn);
1461 else if(strncmp(cmd, "D", 1) == 0) {
1463 ret = mm_sound_remove_device_connected_callback(g_subs_id_device_conn);
1465 g_print("failed to mm_sound_remove_device_connected_callback(), ret[0x%x]\n", ret);
1468 else if(strncmp(cmd, "Q", 1) == 0) {
1470 char input_string[128];
1471 mm_sound_device_flags_e device_flag_1 = MM_SOUND_DEVICE_ALL_FLAG;
1472 mm_sound_device_flags_e device_flag_2 = MM_SOUND_DEVICE_ALL_FLAG;
1473 mm_sound_device_flags_e device_flag_3 = MM_SOUND_DEVICE_ALL_FLAG;
1475 char flag_1, flag_2, flag_3;
1478 g_print ("1. IO_DIRECTION_IN_FLAG\n");
1479 g_print ("2. IO_DIRECTION_OUT_FLAG\n");
1480 g_print ("3. IO_DIRECTION_BOTH_FLAG\n");
1481 g_print ("4. TYPE_INTERNAL_FLAG\n");
1482 g_print ("5. TYPE_EXTERNAL_FLAG\n");
1483 g_print ("6. STATE_DEACTIVATED_FLAG\n");
1484 g_print ("7. STATE_ACTIVATED_FLAG\n");
1485 g_print ("8. ALL_FLAG\n");
1486 g_print("> select flag numbers (total 3): (eg. 2 5 7)");
1488 if (fgets(input_string, sizeof(input_string)-1, stdin)) {
1489 g_print ("### fgets return NULL\n");
1491 flag_1 = input_string[0];
1492 flag_2 = input_string[2];
1493 flag_3 = input_string[4];
1495 if(flag_1 == '1') { device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG; }
1496 else if(flag_1 == '2') { device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG; }
1497 else if(flag_1 == '3') { device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG; }
1498 else if(flag_1 == '4') { device_flag_1 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG; }
1499 else if(flag_1 == '5') { device_flag_1 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG; }
1500 else if(flag_1 == '6') { device_flag_1 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG; }
1501 else if(flag_1 == '7') { device_flag_1 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG; }
1502 else if(flag_1 == '8') { device_flag_1 = MM_SOUND_DEVICE_ALL_FLAG; }
1503 if(flag_2 == '1') { device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG; }
1504 else if(flag_2 == '2') { device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG; }
1505 else if(flag_2 == '3') { device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG; }
1506 else if(flag_2 == '4') { device_flag_2 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG; }
1507 else if(flag_2 == '5') { device_flag_2 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG; }
1508 else if(flag_2 == '6') { device_flag_2 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG; }
1509 else if(flag_2 == '7') { device_flag_2 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG; }
1510 else if(flag_2 == '8') { device_flag_2 = MM_SOUND_DEVICE_ALL_FLAG; }
1511 if(flag_3 == '1') { device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG; }
1512 else if(flag_3 == '2') { device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG; }
1513 else if(flag_3 == '3') { device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG; }
1514 else if(flag_3 == '4') { device_flag_3 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG; }
1515 else if(flag_3 == '5') { device_flag_3 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG; }
1516 else if(flag_3 == '6') { device_flag_3 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG; }
1517 else if(flag_3 == '7') { device_flag_3 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG; }
1518 else if(flag_3 == '8') { device_flag_3 = MM_SOUND_DEVICE_ALL_FLAG; }
1519 g_print("add_device_info_changed");
1520 ret = mm_sound_add_device_information_changed_callback(device_flag_1 | device_flag_2 | device_flag_3, device_info_changed_cb, NULL, &g_subs_id_device_info);
1522 g_print("failed to mm_sound_add_device_information_changed_callback(), ret[0x%x]\n", ret);
1524 g_print("device_flags[0x%x], callback fun[%p], subs_id[%u]\n", device_flag_1|device_flag_2|device_flag_3, device_info_changed_cb, g_subs_id_device_info);
1528 else if(strncmp(cmd, "W", 1) == 0) {
1530 ret = mm_sound_remove_device_information_changed_callback(g_subs_id_device_info);
1532 g_print("failed to mm_sound_remove_device_information_changed_callback(), ret[0x%x]\n", ret);
1536 else if (strncmp(cmd, "x", 1) == 0) {
1541 case CURRENT_STATUS_FILENAME:
1542 input_filename(cmd);
1543 g_menu_state=CURRENT_STATUS_MAINMENU;
1546 case CURRENT_STATUS_DIRNAME:
1548 g_menu_state=CURRENT_STATUS_MAINMENU;
1550 case CURRENT_STATUS_POSITION:
1553 //g_timeout_add(100, timeout_menu_display, 0);
1556 void volume_change_callback(volume_type_t type, unsigned int volume, void *user_data)
1558 if (type == VOLUME_TYPE_MEDIA)
1559 g_print("Volume Callback Runs :::: MEDIA VALUME %d\n", volume);
1562 int main(int argc, char *argv[])
1566 stdin_channel = g_io_channel_unix_new(0);
1567 g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc)input, NULL);
1568 g_loop = g_main_loop_new (NULL, 1);
1570 MMSOUND_STRNCPY(g_file_name, POWERON_FILE, MAX_STRING_LEN);
1571 g_print("\nThe input filename is '%s' \n\n",g_file_name);
1573 /* test volume changed callback */
1574 g_print("callback function addr :: %p\n", volume_change_callback);
1575 g_volume_type = VOLUME_TYPE_MEDIA;
1576 ret = mm_sound_volume_get_value(g_volume_type, &g_volume_value);
1578 g_print("mm_sound_volume_get_value 0x%x\n", ret);
1580 mm_sound_add_volume_changed_callback(volume_change_callback, (void*) &g_volume_type, &g_subs_id_volume);
1583 g_main_loop_run (g_loop);