#define MAX_PATH_LEN 1024
#define MIN_TONE_PLAY_TIME 300
#include "../include/mm_sound.h"
-#ifdef USE_FOCUS
#include "../include/mm_sound_focus.h"
-#endif
#include "../include/mm_sound_common.h"
#include "../include/mm_sound_private.h"
#include "../include/mm_sound_pa_client.h"
#include <unistd.h>
#include <dirent.h>
#include <vconf.h>
-#include <mm_session_private.h>
#define POWERON_FILE "/usr/share/feedback/sound/operation/power_on.wav"
#define KEYTONE_FILE "/usr/share/feedback/sound/operation/operation.wav"
-
-// For testsuite status
enum {
- CURRENT_STATUS_MAINMENU = 0,
- CURRENT_STATUS_FILENAME = 1,
- CURRENT_STATUS_POSITION = 2,
- CURRENT_STATUS_DIRNAME = 3,
+ CURRENT_STATUS_MAINMENU = 0,
+ CURRENT_STATUS_FILENAME = 1,
+ CURRENT_STATUS_POSITION = 2,
+ CURRENT_STATUS_DIRNAME = 3,
};
+int g_focus_id = 0;
int g_menu_state = CURRENT_STATUS_MAINMENU;
-
volume_type_t g_volume_type = VOLUME_TYPE_MEDIA;
unsigned int g_volume_value;
-
GIOChannel *stdin_channel;
char g_file_name[MAX_STRING_LEN];
char g_dir_name[MAX_PATH_LEN];
-
int g_focus_watch_index = -1;
GMainLoop* g_loop;
+unsigned int g_subs_id_test, g_subs_id_volume, g_subs_id_device_conn, g_subs_id_device_state;
-unsigned int g_subs_id_test, g_subs_id_volume, g_subs_id_device_conn, g_subs_id_device_info;
-
-// Function
-static void interpret (char *buf);
+static void interpret(char *buf);
gboolean timeout_menu_display(void *data);
gboolean timeout_quit_program(void *data);
-gboolean input (GIOChannel *channel);
+gboolean input(GIOChannel *channel);
void mycallback(void *data, int id)
{
char *str = (char*)data;
- if(data != NULL)
- debug_log("mycallback called (user data:%s ,id:%d)\n", str, id);
+ if (data != NULL)
+ debug_log("mycallback called (user data:%s ,id:%d)", str, id);
else
- debug_log("mycallback called (no user data)\n");
+ debug_log("mycallback called (no user data)");
}
volatile char test_callback_done;
void test_callback(void *data, int id)
{
- debug_log("test_callback is called\n");
+ debug_log("test_callback is called");
test_callback_done = 1;
}
void mm_sound_test_cb1(int a, void *user_data)
{
- debug_log("dbus test user callback called: param(%d), userdata(%d)\n", a, (int)user_data);
+ debug_log("dbus test user callback called: param(%d), userdata(%d)", a, (int)user_data);
g_print("my callback pid : %u tid : %ld\n", getpid(), pthread_self());
}
-void device_connected_cb (MMSoundDevice_t device_h, bool is_connected, void *user_data)
+void device_connected_cb(MMSoundDevice_t device_h, bool is_connected, void *user_data)
{
int ret = 0;
mm_sound_device_type_e device_type = 0;
mm_sound_device_io_direction_e io_direction = 0;
mm_sound_device_state_e state = 0;
int id = 0;
+ int vendor_id = -1, product_id = -1;
char *name = NULL;
- debug_log("*** device_connected_cb is called, device_h[%p], is_connected[%d], user_date[%p]\n", device_h, is_connected, user_data);
+
+ debug_log("*** device_connected_cb is called, device_h[%p], is_connected[%d], user_data[%p]", device_h, is_connected, user_data);
ret = mm_sound_get_device_type(device_h, &device_type);
- if (ret) {
- debug_error("failed to mm_sound_get_device_type()\n");
- }
+ if (ret)
+ debug_error("failed to mm_sound_get_device_type()");
ret = mm_sound_get_device_io_direction(device_h, &io_direction);
- if (ret) {
- debug_error("failed to mm_sound_get_device_io_direction()\n");
- }
+ if (ret)
+ debug_error("failed to mm_sound_get_device_io_direction()");
ret = mm_sound_get_device_state(device_h, &state);
- if (ret) {
- debug_error("failed to mm_sound_get_device_state()\n");
- }
+ if (ret)
+ debug_error("failed to mm_sound_get_device_state()");
ret = mm_sound_get_device_id(device_h, &id);
- if (ret) {
- debug_error("failed to mm_sound_get_device_id()\n");
- }
+ if (ret)
+ debug_error("failed to mm_sound_get_device_id()");
ret = mm_sound_get_device_name(device_h, &name);
- if (ret) {
- debug_error("failed to mm_sound_get_device_name()\n");
- }
- debug_log("*** --- type[%d], id[%d], io_direction[%d], state[%d], name[%s]\n", device_type, id, io_direction, state, name);
+ if (ret)
+ debug_error("failed to mm_sound_get_device_name()");
+ ret = mm_sound_get_device_vendor_id(device_h, &vendor_id);
+ if (ret)
+ debug_error("failed to mm_sound_get_device_vendor_id()");
+ ret = mm_sound_get_device_product_id(device_h, &product_id);
+ if (ret)
+ debug_error("failed to mm_sound_get_device_produt_id()");
+ debug_log("*** --- type[%d], id[%d], io_direction[%d], state[%d], name[%s], "
+ "vendor-id(%04x) product-id(%04x)",
+ device_type, id, io_direction, state, name, vendor_id, product_id);
}
-void device_info_changed_cb (MMSoundDevice_t device_h, int changed_info_type, void *user_data)
+void device_state_changed_cb(MMSoundDevice_t device_h, mm_sound_device_state_e new_state, void *user_data)
{
int ret = 0;
mm_sound_device_type_e device_type = 0;
mm_sound_device_state_e state = 0;
int id = 0;
char *name = NULL;
- 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);
+ int vendor_id = -1, product_id = -1;
+
+ debug_log("*** device_state_changed_cb is called, device_h[%p], state[%d], user_data[%p]", device_h, new_state, user_data);
ret = mm_sound_get_device_type(device_h, &device_type);
- if (ret) {
- debug_error("failed to mm_sound_get_device_type()\n");
- }
+ if (ret)
+ debug_error("failed to mm_sound_get_device_type()");
ret = mm_sound_get_device_io_direction(device_h, &io_direction);
- if (ret) {
- debug_error("failed to mm_sound_get_device_io_direction()\n");
- }
+ if (ret)
+ debug_error("failed to mm_sound_get_device_io_direction()");
ret = mm_sound_get_device_state(device_h, &state);
- if (ret) {
- debug_error("failed to mm_sound_get_device_state()\n");
- }
+ if (ret)
+ debug_error("failed to mm_sound_get_device_state()");
ret = mm_sound_get_device_id(device_h, &id);
- if (ret) {
- debug_error("failed to mm_sound_get_device_id()\n");
- }
+ if (ret)
+ debug_error("failed to mm_sound_get_device_id()");
ret = mm_sound_get_device_name(device_h, &name);
- if (ret) {
- debug_error("failed to mm_sound_get_device_name()\n");
- }
- debug_log("*** --- type[%d], id[%d], io_direction[%d], state[%d], name[%s]\n", device_type, id, io_direction, state, name);
-}
-#ifdef USE_FOCUS
-void focus_cb0 (int index, mm_sound_focus_type_e type, mm_sound_focus_state_e state, const char *reason_for_change, const char *additional_info, void *user_data)
-{
- char *_state = NULL;
- if (state == FOCUS_IS_RELEASED)
- _state = "RELEASED";
- else
- _state = "ACQUIRED";
- debug_log("*** focus_cb0 is called, index[%d], focus_type[%d], state[%s], reason_for_change[%s], additional_info[%s], user_data[%s]\n",
- index, type, _state, reason_for_change, additional_info, (char*)user_data);
+ if (ret)
+ debug_error("failed to mm_sound_get_device_name()");
+ ret = mm_sound_get_device_vendor_id(device_h, &vendor_id);
+ if (ret)
+ debug_error("failed to mm_sound_get_device_vendor_id()");
+ ret = mm_sound_get_device_product_id(device_h, &product_id);
+ if (ret)
+ debug_error("failed to mm_sound_get_device_produt_id()");
+ debug_log("*** --- type[%d], id[%d], io_direction[%d], state[%d], name[%s], "
+ "vendor-id(%04x) product-id(%04x)",
+ device_type, id, io_direction, state, name, vendor_id, product_id);
}
-void focus_cb1 (int index, mm_sound_focus_type_e type, mm_sound_focus_state_e state, const char *reason_for_change, const char *additional_info, void *user_data)
+
+void focus_cb(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)
{
char *_state = NULL;
if (state == FOCUS_IS_RELEASED)
_state = "RELEASED";
else
_state = "ACQUIRED";
- debug_log("*** focus_cb1 is called, index[%d], focus_type[%d], state[%s], reason_for_change[%s], additional_info[%s], user_data[%s]\n",
- index, type, _state, reason_for_change, additional_info, (char*)user_data);
+ debug_log("*** focus_cb is called, index[%d], focus_type[%d], state[%s], reason_for_change[%s], option[0x%x], ext_info[%s], user_data[%s]",
+ index, type, _state, reason_for_change, option, ext_info, (char*)user_data);
}
-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 *additional_info, void *user_data)
+
+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)
{
char *_state = NULL;
if (state == FOCUS_IS_RELEASED)
_state = "RELEASED";
else
_state = "ACQUIRED";
- debug_log("*** focus_watch_cb is called, index[%d], focus_type[%d], state[%s], reason_for_change[%s], additional_info[%s], user_data[%s]\n",
- index, type, _state, reason_for_change, additional_info, (char*)user_data);
+ debug_log("*** focus_watch_cb is called, index[%d], focus_type[%d], state[%s], reason_for_change[%s], ext_info[%s], user_data[%s]",
+ index, type, _state, reason_for_change, ext_info, (char*)user_data);
}
-#endif
+
void quit_program()
{
g_main_loop_quit(g_loop);
{
if (g_menu_state == CURRENT_STATUS_MAINMENU) {
g_print("==================================================================\n");
- g_print(" Sound Path APIs\n");
- g_print("==================================================================\n");
- g_print("1. Play speaker \t");
- g_print("2. Play headset \n");
- g_print("3. (blank) \n");
- g_print("4. Rec. with mic \t");
- g_print("5. (blank) \t");
- g_print("6. Call receiver \n");
- g_print("7. Call end \t");
- g_print("8. VT call speaker \t");
- g_print("9. VT call end \n");
- g_print("==================================================================\n");
g_print(" Sound Play APIs\n");
g_print("==================================================================\n");
g_print("k : Key Sound \t");
- g_print("an : play sound \t");
- g_print("as : play sound with stream type\t");
- g_print("A : play loud solo\n");
- g_print("c : play sound ex \t");
- g_print("FN : Play DTMF \t");
+ g_print("as : play sound with stream type\n");
g_print("FS : Play DTMF with stream type\t");
g_print("b : Play directory\n");
- g_print("s : Stop play \t");
- g_print("m : stereo to mono\n");
+ g_print("s : Stop play \n");
g_print("==================================================================\n");
g_print(" Volume APIs\n");
g_print("==================================================================\n");
g_print("{ : Get BT A2DP Status\n");
g_print("} : Set Active Route\n");
g_print("==================================================================\n");
- g_print(" Session Test\n");
- g_print("==================================================================\n");
- g_print("z : Call start \t");
- g_print("Z : VideoCall start \t");
- g_print("N : Notification start \n");
- g_print("n : VOIP start \t");
- g_print("v : Session end \t");
- g_print("==================================================================\n");
g_print(" Audio device APIs\n");
g_print("==================================================================\n");
g_print("L : Get current list of connected devices \n");
+ g_print("I : Get device by id \n");
g_print("C : Add device connected callback \t");
g_print("D : Remove device connected callback \n");
- g_print("Q : Add device info. changed callback \t");
- g_print("W : Remove device info. changed callback \n");
+ g_print("Q : Add device state. changed callback \t");
+ g_print("W : Remove device state. changed callback \n");
g_print("==================================================================\n");
-#ifdef USE_FOCUS
g_print(" Focus APIs\n");
g_print("==================================================================\n");
- g_print("DS : signal subscribe for stream info\t");
- g_print("DU : signal unsubscribe for stream info\n");
- g_print("SS : Send signal for stream info\n");
- g_print("GU : Get Focus id\n");
g_print("SF : Set Focus Callback\t");
- g_print("FFS : Set Focus Callback for session\t");
g_print("UF : Unset Focus Callback\n");
g_print("DF : Disable Auto Focus Reacquirement\t");
g_print("AF : Acquire Focus\t");
g_print("RF : Release Focus\n");
g_print("WS : Set Focus Watch Callback\t");
- g_print("WFS : Set Focus Watch Callback for session\t");
g_print("WU : Unset Focus Watch Callback\n");
g_print("==================================================================\n");
-#endif
g_print("d : Input Directory \t");
g_print("f : Input File name \t");
g_print("x : Exit Program \n");
g_print("==================================================================\n");
g_print(" Input command >>>>>>>> ");
- }
- else if (g_menu_state == CURRENT_STATUS_FILENAME) {
+ } else if (g_menu_state == CURRENT_STATUS_FILENAME) {
g_print(">>>>Input file name to play : ");
- }
- else if (g_menu_state == CURRENT_STATUS_DIRNAME) {
+ } else if (g_menu_state == CURRENT_STATUS_DIRNAME) {
g_print(">>>>Input directory which contain audio files : ");
- }
- else {
+ } else {
g_print("**** Unknown status.\n");
quit_program();
}
return FALSE;
}
-gboolean input (GIOChannel *channel)
+gboolean input(GIOChannel *channel)
{
GError *err = NULL;
gchar *buf = NULL;
static void input_filename(char *filename)
{
MMSOUND_STRNCPY(g_file_name, filename, MAX_STRING_LEN);
- g_print("\nThe input filename is '%s' \n\n",g_file_name);
+ g_print("\nThe input filename is '%s' \n\n", g_file_name);
}
static void input_dirname(char *dirname)
{
MMSOUND_STRNCPY(g_dir_name, dirname, MAX_PATH_LEN);
- g_print("\nThe input directory is '%s' \n\n",g_dir_name);
-}
-
-static void __mm_sound_signal_cb1 (mm_sound_signal_name_t signal, int value, void *user_data)
-{
- int _value = 0;
- g_print ("[%s] signal[%d], value[%d], user_data[%p]]\n", __func__, signal, value, user_data);
- mm_sound_get_signal_value (signal, &_value);
- g_print (" -- get value : %d\n", _value);
-}
-
-static void __mm_sound_signal_cb2 (mm_sound_signal_name_t signal, int value, void *user_data)
-{
- int _value = 0;
- g_print ("[%s] signal[%d], value[%d], user_data[%p]]\n", __func__, signal, value, user_data);
- mm_sound_get_signal_value (signal, &_value);
- g_print (" -- get value : %d\n", _value);
+ g_print("\nThe input directory is '%s' \n\n", g_dir_name);
}
-unsigned int g_subscribe_id1 = 0;
-unsigned int g_subscribe_id2 = 0;
-static void interpret (char *cmd)
+static void interpret(char *cmd)
{
- int ret=0;
- int value = 0;
+ int ret = 0;
static int handle = -1;
- MMSoundPlayParam soundparam = {0,};
-
- switch (g_menu_state)
- {
- case CURRENT_STATUS_MAINMENU:
-#ifdef USE_FOCUS
- if(strncmp(cmd, "DS", 2) == 0) {
- ret = mm_sound_subscribe_signal(MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, &g_subscribe_id1, __mm_sound_signal_cb1, NULL);
- if(ret < 0)
- debug_log("mm_sound_subscribe_signal() failed with 0x%x\n", ret);
- else
- debug_log("id: %u, callback:%p\n", g_subscribe_id1, __mm_sound_signal_cb1);
- ret = mm_sound_subscribe_signal(MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, &g_subscribe_id2, __mm_sound_signal_cb2, NULL);
- if(ret < 0)
- debug_log("mm_sound_subscribe_signal() failed with 0x%x\n", ret);
- else
- debug_log("id: %u, callback:%p\n", g_subscribe_id2, __mm_sound_signal_cb2);
- }
- else if(strncmp(cmd, "DU", 2) == 0) {
- mm_sound_unsubscribe_signal(g_subscribe_id1);
- debug_log("unsubscribe_signal for id[%d]\n", g_subscribe_id1);
- mm_sound_unsubscribe_signal(g_subscribe_id2);
- debug_log("unsubscribe_signal for id[%d]\n", g_subscribe_id2);
- }
+ switch (g_menu_state) {
+ case CURRENT_STATUS_MAINMENU:
+ if (strncmp(cmd, "SF", 2) == 0) {
+ int ret = 0;
+ char input_string[128];
+ char select;
+ char *stream_type = NULL;
+ const char *user_data = "this is user data";
- else if(strncmp(cmd, "SS", 2) == 0) {
- ret = mm_sound_send_signal(MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, 1);
- if(ret < 0)
- debug_log("mm_sound_send_signal() failed with 0x%x\n", ret);
- else
- debug_log("mm_sound_send_signal for signal[%d], value[%d] is success\n", MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, 1);
- mm_sound_get_signal_value (MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, &value);
- g_print (" -- get value of RELEASE_INTERNAL_FOCUS : %d\n", value);
- ret = mm_sound_send_signal(MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, 0);
- if(ret < 0)
- debug_log("mm_sound_send_signal() failed with 0x%x\n", ret);
- else
- debug_log("mm_sound_send_signal for signal[%d], value[%d] is success\n", MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, 0);
- mm_sound_get_signal_value (MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, &value);
- g_print (" -- get value of RELEASE_INTERNAL_FOCUS : %d\n", value);
- }
+ fflush(stdin);
+ g_print("1. Media\n");
+ g_print("2. Alarm\n");
+ g_print("3. Notification\n");
+ g_print("4. Emergency\n");
+ g_print("5. Voice Information\n");
+ g_print("6. Ringtone\n");
+ g_print("7. Ringtone Call\n");
+ g_print("8. VOIP\n");
+ g_print("0. Voice Recognition\n");
+ g_print("> stream type: ");
- else if(strncmp(cmd, "GU", 2) == 0) {
- int id = 0;
- ret = mm_sound_focus_get_id(&id);
- if(ret < 0)
- debug_log("mm_sound_focus_get_id() failed with 0x%x\n", ret);
+ if (fgets(input_string, sizeof(input_string)-1, stdin)) {
+ select = input_string[0];
+
+ if (select == '1')
+ stream_type = "media";
+ else if (select == '2')
+ stream_type = "alarm";
+ else if (select == '3')
+ stream_type = "notification";
+ else if (select == '4')
+ stream_type = "emergency";
+ else if (select == '5')
+ stream_type = "voice-information";
+ else if (select == '6')
+ stream_type = "ringtone";
+ else if (select == '7')
+ stream_type = "ringtone-call";
+ else if (select == '8')
+ stream_type = "voip";
+ else if (select == '0')
+ stream_type = "voice-recognition";
+
+ ret = mm_sound_register_focus(stream_type, focus_cb, (void*)user_data, &g_focus_id);
+ if (ret)
+ g_print("failed to mm_sound_register_focus(), ret[0x%x]\n", ret);
else
- debug_log("id : %d\n", id);
+ g_print("id[%d], stream_type[%s], callback fun[%p]\n", g_focus_id, stream_type, focus_cb);
+ } else {
+ g_print("### fgets return NULL\n");
}
+ } else if (strncmp(cmd, "UF", 2) == 0) {
+ int ret = 0;
- else if(strncmp(cmd, "SF", 2) == 0) {
- int ret = 0;
- char input_string[128];
- char flag_1, flag_2;
- int id = 0;
- char *stream_type = NULL;
- const char *user_data = "this is user data";
-
- fflush(stdin);
- g_print ("1. Media\n");
- g_print ("2. Alarm\n");
- g_print ("3. Notification\n");
- g_print ("4. Emergency\n");
- g_print ("5. Voice Information\n");
- g_print ("6. Ringtone\n");
- g_print ("7. Ringtone Call\n");
- g_print ("8. VOIP\n");
- g_print ("0. Voice Recognition\n");
- g_print("> select id and stream type: (eg. 0 3)");
-
- if (fgets(input_string, sizeof(input_string)-1, stdin)) {
- g_print ("### fgets return NULL\n");
- }
+ ret = mm_sound_unregister_focus(g_focus_id);
+ if (ret)
+ g_print("failed to mm_sound_unregister_focus(), ret[0x%x]\n", ret);
+ } else if (strncmp(cmd, "DF", 2) == 0) {
+ int ret = 0;
+ char input_string[128];
+ char flag_1, flag_2;
+ int id = 2;
+ bool reacquisition = true;
+ fflush(stdin);
+ g_print("1. enable auto reacquirement\n");
+ g_print("2. disable auto reacquirement\n");
+ g_print("> select id and option: (eg. 0 1)");
+ if (fgets(input_string, sizeof(input_string)-1, stdin)) {
flag_1 = input_string[0];
flag_2 = input_string[2];
- if(flag_1 == '0') { id = 0; }
- else if(flag_1 == '1') { id = 1; }
- else if(flag_1 == '2') { id = 2; }
- else { id = 2; }
- if(flag_2 == '1') { stream_type = "media"; }
- else if(flag_2 == '2') { stream_type = "alarm"; }
- else if(flag_2 == '3') { stream_type = "notification"; }
- else if(flag_2 == '4') { stream_type = "emergency"; }
- else if(flag_2 == '5') { stream_type = "voice-information"; }
- else if(flag_2 == '6') { stream_type = "ringtone"; }
- else if(flag_2 == '7') { stream_type = "ringtone-call"; }
- else if(flag_2 == '8') { stream_type = "voip"; }
- else if(flag_2 == '0') { stream_type = "voice-recognition"; }
- else { stream_type = "media"; }
-
- ret = mm_sound_register_focus(id, stream_type, (id == 0)? focus_cb0 : focus_cb1, (void*)user_data);
- if (ret) {
- g_print("failed to mm_sound_register_focus(), ret[0x%x]\n", ret);
- } else {
- g_print("id[%d], stream_type[%s], callback fun[%p]\n", id, stream_type, (id == 0)? focus_cb0 : focus_cb1);
- }
- }
-
- else if(strncmp(cmd, "FFS", 3) == 0) {
- int ret = 0;
- char input_string[128];
- char flag_1, flag_2;
- int id = 0;
- char *stream_type = NULL;
- const char *user_data = "this is user data";
-
- fflush(stdin);
- g_print ("1. Media\n");
- g_print ("2. Alarm\n");
- g_print ("3. Notification\n");
- g_print ("4. Emergency\n");
- g_print ("5. Voice Information\n");
- g_print ("6. Ringtone\n");
- g_print ("7. Ringtone Call\n");
- g_print ("8. VOIP\n");
- g_print ("0. Voice Recognition\n");
- g_print("> select id and stream type: (eg. 0 3)");
-
- if (fgets(input_string, sizeof(input_string)-1, stdin)) {
- g_print ("### fgets return NULL\n");
- }
- flag_1 = input_string[0];
- flag_2 = input_string[2];
+ if (flag_1 == '0')
+ id = 0;
+ else if (flag_1 == '1')
+ id = 1;
+ else if (flag_1 == '2')
+ id = 2;
- if(flag_1 == '0') { id = 0; }
- else if(flag_1 == '1') { id = 1; }
- else if(flag_1 == '2') { id = 2; }
- else { id = 2; }
- if(flag_2 == '1') { stream_type = "media"; }
- else if(flag_2 == '2') { stream_type = "alarm"; }
- else if(flag_2 == '3') { stream_type = "notification"; }
- else if(flag_2 == '4') { stream_type = "emergency"; }
- else if(flag_2 == '5') { stream_type = "voice-information"; }
- else if(flag_2 == '6') { stream_type = "ringtone"; }
- else if(flag_2 == '7') { stream_type = "ringtone-call"; }
- else if(flag_2 == '8') { stream_type = "voip"; }
- else if(flag_2 == '0') { stream_type = "voice-recognition"; }
- else { stream_type = "media"; }
-
- ret = mm_sound_register_focus_for_session(id, getpid(), stream_type, (id == 0)? focus_cb0 : focus_cb1, (void*)user_data);
- if (ret) {
- g_print("failed to mm_sound_register_focus_for_session(), ret[0x%x]\n", ret);
- } else {
- g_print("id[%d], stream_type[%s], callback fun[%p]\n", id, stream_type, (id == 0)? focus_cb0 : focus_cb1);
- }
- }
+ if (flag_2 == '1')
+ reacquisition = true;
+ else if (flag_2 == '2')
+ reacquisition = false;
- else if(strncmp(cmd, "UF", 2) == 0) {
- int ret = 0;
- char input_string[128];
- char flag_1;
- int id = 0;
- fflush(stdin);
- g_print("> select id:");
- if (fgets(input_string, sizeof(input_string)-1, stdin)) {
- g_print ("### fgets return NULL\n");
- }
- flag_1 = input_string[0];
- if(flag_1 == '0') { id = 0; }
- else if(flag_1 == '1') { id = 1; }
- else if(flag_1 == '2') { id = 2; }
- else { id = 2; }
- ret = mm_sound_unregister_focus(id);
- if (ret) {
- g_print("failed to mm_sound_unregister_focus(), ret[0x%x]\n", ret);
- }
- }
-
- else if(strncmp(cmd, "DF", 2) == 0) {
- int ret = 0;
- char input_string[128];
- char flag_1, flag_2;
- int id = 0;
- bool reacquisition = true;
- fflush(stdin);
- g_print ("1. enable auto reacquirement\n");
- g_print ("2. disable auto reacquirement\n");
- g_print("> select id and option: (eg. 0 1)");
- if (fgets(input_string, sizeof(input_string)-1, stdin)) {
- g_print ("### fgets return NULL\n");
- }
- flag_1 = input_string[0];
- flag_2 = input_string[2];
-
- if(flag_1 == '0') { id = 0; }
- else if(flag_1 == '1') { id = 1; }
- else if(flag_1 == '2') { id = 2; }
- else { id = 2; }
-
- if(flag_2 == '1') { reacquisition = true; }
- else if(flag_2 == '2') { reacquisition = false; }
- else { reacquisition = true; }
ret = mm_sound_set_focus_reacquisition(id, reacquisition);
- if (ret) {
+ if (ret)
g_print("failed to mm_sound_disable_focus_reacquirement(), ret[0x%x]\n", ret);
- }
+ } else {
+ g_print("### fgets return NULL\n");
}
-
- else if(strncmp(cmd, "AF", 2) == 0) {
- int ret = 0;
- char input_string[128];
- char flag_1, flag_2;
- int id = 0;
- mm_sound_focus_type_e type = FOCUS_FOR_PLAYBACK;
- fflush(stdin);
- g_print ("1. focus for playback\n");
- g_print ("2. focus for recording\n");
- g_print ("3. focus for both\n");
- g_print("> select id and focus_type: (eg. 0 1)");
- if (fgets(input_string, sizeof(input_string)-1, stdin)) {
- g_print ("### fgets return NULL\n");
- }
+ } else if (strncmp(cmd, "AF", 2) == 0) {
+ int ret = 0;
+ char input_string[128];
+ char flag_1, flag_2;
+ int id = 0;
+ mm_sound_focus_type_e type = FOCUS_FOR_BOTH;
+ fflush(stdin);
+ g_print("1. focus for playback\n");
+ g_print("2. focus for recording\n");
+ g_print("3. focus for both\n");
+ g_print("> select id and focus_type: (eg. 0 1)");
+ if (fgets(input_string, sizeof(input_string)-1, stdin)) {
flag_1 = input_string[0];
flag_2 = input_string[2];
- if(flag_1 == '0') { id = 0; }
- else if(flag_1 == '1') { id = 1; }
- else { id = 2; }
+ if (flag_1 == '0')
+ id = 0;
+ else if (flag_1 == '1')
+ id = 1;
+
+ if (flag_2 == '1')
+ type = FOCUS_FOR_PLAYBACK;
+ else if (flag_2 == '2')
+ type = FOCUS_FOR_CAPTURE;
- if(flag_2 == '1') { type = FOCUS_FOR_PLAYBACK; }
- else if(flag_2 == '2') { type = FOCUS_FOR_CAPTURE; }
- else { type = FOCUS_FOR_BOTH; }
ret = mm_sound_acquire_focus(id, type, "additional_info. for acquire");
- if (ret) {
+ if (ret)
g_print("failed to mm_sound_acquire_focus(), ret[0x%x]\n", ret);
- }
+
+ } else {
+ g_print("### fgets return NULL\n");
}
- else if(strncmp(cmd, "RF", 2) == 0) {
- int ret = 0;
- char input_string[128];
- char flag_1, flag_2;
- int id = 0;
- mm_sound_focus_type_e type = FOCUS_FOR_PLAYBACK;
- fflush(stdin);
- g_print ("1. focus for playback\n");
- g_print ("2. focus for recording\n");
- g_print ("3. focus for all\n");
- g_print("> select id and focus_type: (eg. 0 1)");
- if (fgets(input_string, sizeof(input_string)-1, stdin)) {
- g_print ("### fgets return NULL\n");
- }
+ } else if (strncmp(cmd, "RF", 2) == 0) {
+ int ret = 0;
+ char input_string[128];
+ char flag_1, flag_2;
+ int id = 2;
+ mm_sound_focus_type_e type = FOCUS_FOR_BOTH;
+ fflush(stdin);
+ g_print("1. focus for playback\n");
+ g_print("2. focus for recording\n");
+ g_print("3. focus for all\n");
+ g_print("> select id and focus_type: (eg. 0 1)");
+ if (fgets(input_string, sizeof(input_string)-1, stdin)) {
flag_1 = input_string[0];
flag_2 = input_string[2];
- if(flag_1 == '0') { id = 0; }
- else if(flag_1 == '1') { id = 1; }
- else { id = 2; }
+ if (flag_1 == '0')
+ id = 0;
+ else if (flag_1 == '1')
+ id = 1;
+
+ if (flag_2 == '1')
+ type = FOCUS_FOR_PLAYBACK;
+ else if (flag_2 == '2')
+ type = FOCUS_FOR_CAPTURE;
- if(flag_2 == '1') { type = FOCUS_FOR_PLAYBACK; }
- else if(flag_2 == '2') { type = FOCUS_FOR_CAPTURE; }
- else { type = FOCUS_FOR_BOTH; }
ret = mm_sound_release_focus(id, type, "additional_info. for release");
- if (ret) {
+ if (ret)
g_print("failed to mm_sound_release_focus(), ret[0x%x]\n", ret);
- }
- }
- else if(strncmp(cmd, "WFS", 3) == 0) {
- int ret = 0;
- char input_string[128];
- char flag_1;
- int type = 0;
- const char *user_data = "this is user data for watch";
-
- fflush(stdin);
- g_print ("1. playback\n");
- g_print ("2. recording\n");
- g_print ("3. both\n");
- g_print("> select interest focus type:");
-
- if (fgets(input_string, sizeof(input_string)-1, stdin)) {
- g_print ("### fgets return NULL\n");
- }
- flag_1 = input_string[0];
-
- if(flag_1 == '1') { type = 1; }
- else if(flag_1 == '2') { type = 2; }
- else if(flag_1 == '3') { type = 3; }
- else { type = 1; }
- ret = mm_sound_set_focus_watch_callback_for_session(getpid(), type, focus_watch_cb, (void*)user_data, &g_focus_watch_index);
- if (ret) {
- g_print("failed to mm_sound_set_focus_watch_callback(), ret[0x%x]\n", ret);
- } else {
- g_print("index[%d], type[%d], callback fun[%p]\n", g_focus_watch_index, type, focus_watch_cb);
- }
+ } else {
+ g_print("### fgets return NULL\n");
}
- else if(strncmp(cmd, "WS", 2) == 0) {
- int ret = 0;
- char input_string[128];
- char flag_1;
- int type = 0;
- const char *user_data = "this is user data for watch";
+ } else if (strncmp(cmd, "WS", 2) == 0) {
+ int ret = 0;
+ char input_string[128];
+ char flag_1;
+ int type = 1;
+ const char *user_data = "this is user data for watch";
- fflush(stdin);
- g_print ("1. playback\n");
- g_print ("2. recording\n");
- g_print ("3. both\n");
- g_print("> select interest focus type:");
+ fflush(stdin);
+ g_print("1. playback\n");
+ g_print("2. recording\n");
+ g_print("3. both\n");
+ g_print("> select interest focus type:");
- if (fgets(input_string, sizeof(input_string)-1, stdin)) {
- g_print ("### fgets return NULL\n");
- }
+ if (fgets(input_string, sizeof(input_string)-1, stdin)) {
flag_1 = input_string[0];
- if(flag_1 == '1') { type = 1; }
- else if(flag_1 == '2') { type = 2; }
- else if(flag_1 == '3') { type = 3; }
- else { type = 1; }
+ if (flag_1 == '1')
+ type = 1;
+ else if (flag_1 == '2')
+ type = 2;
+ else if (flag_1 == '3')
+ type = 3;
+
ret = mm_sound_set_focus_watch_callback(type, focus_watch_cb, (void*)user_data, &g_focus_watch_index);
- if (ret) {
+ if (ret)
g_print("failed to mm_sound_set_focus_watch_callback(), ret[0x%x]\n", ret);
- } else {
+ else
g_print("index[%d], type[%d], callback fun[%p]\n", g_focus_watch_index, type, focus_watch_cb);
- }
+ } else {
+ g_print("### fgets return NULL\n");
}
- else if(strncmp(cmd, "WU", 2) == 0) {
- int ret = 0;
- ret = mm_sound_unset_focus_watch_callback(g_focus_watch_index);
- if (ret) {
- g_print("failed to mm_sound_unset_focus_watch_callback(), ret[0x%x]\n", ret);
- }
- }
- else if(strncmp(cmd, "k", 1) == 0)
-#else
- if(strncmp(cmd, "k", 1) == 0)
-#endif
- {
- ret = mm_sound_play_keysound(KEYTONE_FILE, 0);
- if(ret < 0)
- debug_log("keysound play failed with 0x%x\n", ret);
- }
- else if (strcmp(cmd, "dbus-m") == 0) {
- int ret = 0;
- int a = 3;
- int b = 4;
- int result_val = 0;
- g_print("dbus method test call\n");
- ret = mm_sound_test(a, b, &result_val);
- if (ret) {
+ } else if (strncmp(cmd, "WU", 2) == 0) {
+ int ret = 0;
+ ret = mm_sound_unset_focus_watch_callback(g_focus_watch_index);
+ if (ret)
+ g_print("failed to mm_sound_unset_focus_watch_callback(), ret[0x%x]\n", ret);
+ } else if (strncmp(cmd, "k", 1) == 0) {
+ ret = mm_sound_play_keysound(KEYTONE_FILE, 0);
+ if (ret < 0)
+ debug_log("keysound play failed with 0x%x", ret);
+ } else if (strcmp(cmd, "dbus-m") == 0) {
+ int ret = 0;
+ int a = 3;
+ int b = 4;
+ int result_val = 0;
+ g_print("dbus method test call\n");
+ ret = mm_sound_test(a, b, &result_val);
+ if (ret)
g_print("failed to mm_sound_test(), ret[0x%x]\n", ret);
- } else {
+ else
g_print("Got answer : %d\n", result_val);
- }
- } else if (strcmp(cmd, "dbus-a") == 0) {
- int ret = 0;
- int user_data = 3;
- g_print("dbus method test add callback\n");
- g_print("my testsuite pid : %u tid : %ld\n", getpid(), pthread_self());
- ret = mm_sound_add_test_callback(mm_sound_test_cb1, (void *)user_data, &g_subs_id_test);
- if (ret) {
+
+ } else if (strcmp(cmd, "dbus-a") == 0) {
+ int ret = 0;
+ int user_data = 3;
+ g_print("dbus method test add callback\n");
+ g_print("my testsuite pid : %u tid : %ld\n", getpid(), pthread_self());
+ ret = mm_sound_add_test_callback(mm_sound_test_cb1, (void *)user_data, &g_subs_id_test);
+ if (ret)
g_print("failed to mm_sound_add_test_callback(), ret[0x%x]\n", ret);
- } else {
+ else
g_print("add test callback success\n");
- }
- } else if (strcmp(cmd, "dbus-r") == 0) {
- int ret = 0;
- g_print("dbus method test remove callback\n");
- ret = mm_sound_remove_test_callback(g_subs_id_test);
- if (ret) {
+
+ } else if (strcmp(cmd, "dbus-r") == 0) {
+ int ret = 0;
+ g_print("dbus method test remove callback\n");
+ ret = mm_sound_remove_test_callback(g_subs_id_test);
+ if (ret)
g_print("failed to mm_sound_remove_test_callback(), ret[0x%x]\n", ret);
- } else {
+ else
g_print("remove test callback success\n");
- }
- }
- else if(strncmp(cmd, "q", 1) == 0)
- {//get media volume
- unsigned int value = 100;
- ret = mm_sound_volume_get_value(g_volume_type, &value);
- if(ret < 0) {
- debug_log("mm_sound_volume_get_value 0x%x\n", ret);
- }
- else{
- g_print("*** MEDIA VOLUME : %u ***\n", value);
- g_volume_value = value;
- }
- }
- else if(strncmp(cmd, "e", 1) == 0)
- {//set media volume down
- unsigned int value = 100;
- ret = mm_sound_volume_get_value(g_volume_type, &value);
- if(ret < 0) {
- debug_log("mm_sound_volume_get_value 0x%x\n", ret);
- }
- else {
- if(value != 0) {
- value--;
- }
- ret = mm_sound_volume_set_value(g_volume_type, value);
- if(ret < 0) {
- debug_log("mm_sound_volume_set_value 0x%x\n", ret);
- }
- }
- }
- else if(strncmp(cmd, "r", 1) == 0)
- {//get media volume
- unsigned int value = 100;
- ret = mm_sound_volume_get_value(VOLUME_TYPE_SYSTEM, &value);
- if(ret < 0) {
- debug_log("mm_sound_volume_get_value 0x%x\n", ret);
- }
- else{
- g_print("*** SYSTEM VOLUME : %u ***\n", value);
- g_volume_value = value;
- }
+ } else if (strncmp(cmd, "q", 1) == 0) {
+ unsigned int value = 100;
+ ret = mm_sound_volume_get_value(g_volume_type, &value);
+ if (ret < 0) {
+ debug_log("mm_sound_volume_get_value 0x%x", ret);
+ } else {
+ g_print("*** MEDIA VOLUME : %u ***\n", value);
+ g_volume_value = value;
}
- else if(strncmp(cmd, "y", 1) == 0)
- {//set media volume down
- unsigned int value = 100;
- ret = mm_sound_volume_get_value(VOLUME_TYPE_SYSTEM, &value);
- if(ret < 0) {
- debug_log("mm_sound_volume_get_value 0x%x\n", ret);
- }
- else {
- if(value != 0) {
- value--;
- }
- ret = mm_sound_volume_set_value(VOLUME_TYPE_SYSTEM, value);
- if(ret < 0) {
- debug_log("mm_sound_volume_set_value 0x%x\n", ret);
- }else {
- g_print("Current System volume is %d\n", value);
- }
- }
- }
- else if(strncmp(cmd, "g", 1) == 0)
- {//get voice volume
- unsigned int value = 100;
- ret = mm_sound_volume_get_value(VOLUME_TYPE_VOICE, &value);
- if(ret < 0) {
- debug_log("mm_sound_volume_get_value 0x%x\n", ret);
- }
- else{
- g_print("*** VOICE VOLUME : %u ***\n", value);
- g_volume_value = value;
- }
+ } else if (strncmp(cmd, "e", 1) == 0) {
+ unsigned int value = 100;
+ ret = mm_sound_volume_get_value(g_volume_type, &value);
+ if (ret < 0) {
+ debug_log("mm_sound_volume_get_value 0x%x", ret);
+ } else {
+ if (value != 0)
+ value--;
+ ret = mm_sound_volume_set_value(g_volume_type, value);
+ if (ret < 0)
+ debug_log("mm_sound_volume_set_value 0x%x", ret);
}
- else if(strncmp(cmd, "j", 1) == 0)
- {//set voice volume down
- unsigned int value = 100;
- ret = mm_sound_volume_get_value(VOLUME_TYPE_VOICE, &value);
- if(ret < 0) {
- debug_log("mm_sound_volume_get_value 0x%x\n", ret);
- }
- else {
- if(value != 0) {
- value--;
- }
- ret = mm_sound_volume_set_value(VOLUME_TYPE_VOICE, value);
- if(ret < 0) {
- debug_log("mm_sound_volume_set_value 0x%x\n", ret);
- }else {
- g_print("Current Voice volume is %d\n", value);
- }
- }
- }
- else if(strncmp(cmd, "an", 2) == 0)
- {
- debug_log("volume is %d type, %d\n", g_volume_type, g_volume_value);
- ret = mm_sound_play_sound(g_file_name, g_volume_type, mycallback ,"USERDATA", &handle);
- if(ret < 0)
- debug_log("mm_sound_play_sound() failed with 0x%x\n", ret);
+ } else if (strncmp(cmd, "r", 1) == 0) {
+ unsigned int value = 100;
+ ret = mm_sound_volume_get_value(VOLUME_TYPE_SYSTEM, &value);
+ if (ret < 0) {
+ debug_log("mm_sound_volume_get_value 0x%x", ret);
+ } else {
+ g_print("*** SYSTEM VOLUME : %u ***\n", value);
+ g_volume_value = value;
}
- else if(strncmp(cmd, "as", 2) == 0)
- {
- debug_log("stream %s type, %d\n", "media", g_volume_value);
- ret = mm_sound_play_sound_with_stream_info(g_file_name, "media", -1, 1, mycallback ,"USERDATA", &handle);
- if(ret < 0)
- debug_log("mm_sound_play_sound() failed with 0x%x\n", ret);
+
+ } else if (strncmp(cmd, "y", 1) == 0) {
+ unsigned int value = 100;
+ ret = mm_sound_volume_get_value(VOLUME_TYPE_SYSTEM, &value);
+ if (ret < 0) {
+ debug_log("mm_sound_volume_get_value 0x%x", ret);
+ } else {
+ if (value != 0)
+ value--;
+
+ ret = mm_sound_volume_set_value(VOLUME_TYPE_SYSTEM, value);
+ if (ret < 0)
+ debug_log("mm_sound_volume_set_value 0x%x", ret);
+ else
+ g_print("Current System volume is %d\n", value);
}
- else if(strncmp(cmd, "A", 1) == 0)
- {
- debug_log("volume is %d type, %d\n", g_volume_type, g_volume_value);
- ret = mm_sound_play_loud_solo_sound(g_file_name, g_volume_type, mycallback ,"USERDATA", &handle);
- if(ret < 0)
- debug_log("mm_sound_play_sound_loud_solo() failed with 0x%x\n", ret);
+
+ } else if (strncmp(cmd, "g", 1) == 0) {
+ unsigned int value = 100;
+ ret = mm_sound_volume_get_value(VOLUME_TYPE_VOICE, &value);
+ if (ret < 0) {
+ debug_log("mm_sound_volume_get_value 0x%x", ret);
+ } else {
+ g_print("*** VOICE VOLUME : %u ***\n", value);
+ g_volume_value = value;
}
- else if(strncmp(cmd, "FN", 2) == 0)
- {
- char num = 0;
- char input_string[128] = "";
- char *tok = NULL;
- int tonetime=0;
- double volume=1.0;
- int volume_type = -1;
- bool enable_session = 0;
- MMSoundTone_t tone = MM_SOUND_TONE_DTMF_0;
-
- while(num != 'q') {
- fflush(stdin);
- 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 ");
- if (fgets(input_string, sizeof(input_string)-1, stdin) == NULL) {
- g_print ("### fgets return NULL\n");
- }
- tok = strtok(input_string, " ");
- if(!tok) continue;
- if(tok[0] == 'q') {
- break;
- }
- else if(tok[0] < '0' || tok[0] > '~') {
- if(tok[0] == '*' || tok[0] == '#')
- ;
- else
- continue;
- }
- num = tok[0];
- if(num >= '0' && num <= '9') {
- tone = (MMSoundTone_t)(num - '0');
- }
- else if(num == '*') {
- tone = MM_SOUND_TONE_DTMF_S;
- }
- else if(num == '#') {
- tone =MM_SOUND_TONE_DTMF_P;
- }
- else if(num == 'A') { tone = MM_SOUND_TONE_DTMF_A; }
- else if(num == 'B') { tone = MM_SOUND_TONE_DTMF_B; }
- else if(num == 'C') { tone = MM_SOUND_TONE_DTMF_C; }
- else if(num == 'D') { tone = MM_SOUND_TONE_DTMF_D; }
- else if(num == 'E') { tone = MM_SOUND_TONE_SUP_DIAL; }
- else if(num == 'F') { tone = MM_SOUND_TONE_ANSI_DIAL; }
- else if(num == 'G') { tone = MM_SOUND_TONE_JAPAN_DIAL; }
- else if(num == 'H') { tone = MM_SOUND_TONE_SUP_BUSY; }
- else if(num == 'I') { tone = MM_SOUND_TONE_ANSI_BUSY; }
- else if(num == 'J') { tone = MM_SOUND_TONE_JAPAN_BUSY; }
- else if(num == 'K') { tone = MM_SOUND_TONE_SUP_CONGESTION; }
- else if(num == 'L') { tone = MM_SOUND_TONE_ANSI_CONGESTION; }
- else if(num == 'M') { tone = MM_SOUND_TONE_SUP_RADIO_ACK; }
- else if(num == 'N') { tone = MM_SOUND_TONE_JAPAN_RADIO_ACK; }
- else if(num == 'O') { tone = MM_SOUND_TONE_SUP_RADIO_NOTAVAIL; }
- else if(num == 'P') { tone = MM_SOUND_TONE_SUP_ERROR; }
- else if(num == 'Q') { tone = MM_SOUND_TONE_SUP_CALL_WAITING; }
- else if(num == 'R') { tone = MM_SOUND_TONE_ANSI_CALL_WAITING; }
- else if(num == 'S') { tone = MM_SOUND_TONE_SUP_RINGTONE; }
- else if(num == 'T') { tone = MM_SOUND_TONE_ANSI_RINGTONE; }
- else if(num == 'U') { tone = MM_SOUND_TONE_PROP_BEEP; }
- else if(num == 'V') { tone = MM_SOUND_TONE_PROP_ACK; }
- else if(num == 'W') { tone = MM_SOUND_TONE_PROP_NACK; }
- else if(num == 'X') { tone = MM_SOUND_TONE_PROP_PROMPT; }
- else if(num == 'Y') { tone = MM_SOUND_TONE_PROP_BEEP2; }
- else if(num == 'Z') { tone =MM_SOUND_TONE_CDMA_HIGH_SLS; }
- else if(num == '[') { tone = MM_SOUND_TONE_CDMA_MED_SLS; }
- else if(num == ']') { tone = MM_SOUND_TONE_CDMA_LOW_SLS; }
- else if(num == '^') { tone =MM_SOUND_TONE_CDMA_HIGH_S_X4; }
- else if(num == '_') { tone =MM_SOUND_TONE_CDMA_MED_S_X4; }
- else if(num == 'a') { tone =MM_SOUND_TONE_CDMA_LOW_S_X4; }
- else if(num == 'b') { tone =MM_SOUND_TONE_CDMA_HIGH_PBX_L; }
- else if(num == 'c') { tone =MM_SOUND_TONE_CDMA_MED_PBX_L; }
- else if(num == 'd') { tone =MM_SOUND_TONE_CDMA_LOW_PBX_L; }
- else if(num == 'e') { tone =MM_SOUND_TONE_CDMA_HIGH_PBX_SS; }
- else if(num == 'f') { tone =MM_SOUND_TONE_CDMA_MED_PBX_SS; }
- else if(num == 'g') { tone =MM_SOUND_TONE_CDMA_LOW_PBX_SS; }
- else if(num == 'h') { tone =MM_SOUND_TONE_CDMA_HIGH_PBX_SSL; }
- else if(num == 'i') { tone =MM_SOUND_TONE_CDMA_MED_PBX_SSL; }
- else if(num == 'j') { tone =MM_SOUND_TONE_CDMA_LOW_PBX_SSL; }
- else if(num == 'k') { tone =MM_SOUND_TONE_CDMA_HIGH_PBX_SLS; }
- else if(num == 'l') { tone =MM_SOUND_TONE_CDMA_MED_PBX_SLS; }
- else if(num == 'm') { tone =MM_SOUND_TONE_CDMA_LOW_PBX_SLS; }
- else if(num == 'n') { tone =MM_SOUND_TONE_CDMA_HIGH_PBX_S_X4; }
- else if(num == 'o') { tone =MM_SOUND_TONE_CDMA_MED_PBX_S_X4; }
- else if(num == 'p') { tone =MM_SOUND_TONE_CDMA_LOW_PBX_S_X4; }
- else if(num == 'q') { tone =MM_SOUND_TONE_CDMA_ALERT_NETWORK_LITE; }
- else if(num == 'r') { tone =MM_SOUND_TONE_CDMA_ALERT_AUTOREDIAL_LITE; }
- else if(num == 's') { tone =MM_SOUND_TONE_CDMA_ONE_MIN_BEEP; }
- else if(num == 't') { tone =MM_SOUND_TONE_CDMA_KEYPAD_VOLUME_KEY_LITE; }
- else if(num == 'u') { tone =MM_SOUND_TONE_CDMA_PRESSHOLDKEY_LITE; }
- else if(num == 'v') { tone =MM_SOUND_TONE_CDMA_ALERT_INCALL_LITE; }
- else if(num == 'w') { tone =MM_SOUND_TONE_CDMA_EMERGENCY_RINGBACK; }
- else if(num == 'x') { tone =MM_SOUND_TONE_CDMA_ALERT_CALL_GUARD; }
- else if(num == 'y') { tone =MM_SOUND_TONE_CDMA_SOFT_ERROR_LITE; }
- else if(num == 'z') { tone =MM_SOUND_TONE_CDMA_CALLDROP_LITE; }
- else if(num == '{') { tone =MM_SOUND_TONE_LOW_FRE; }
- else if(num == '}') { tone =MM_SOUND_TONE_MED_FRE; }
- else if(num == '~') { tone =MM_SOUND_TONE_HIGH_FRE; }
- tok = strtok(NULL, " ");
- if(tok) volume_type = (double)atoi(tok);
-
- tok = strtok(NULL, " ");
- if(tok) volume = (double)atof(tok);
-
- tok = strtok(NULL, " ");
- if(tok)
- {
- tonetime = atoi(tok);
- }
- else
- {
- tonetime = MIN_TONE_PLAY_TIME;
- }
- tok = strtok(NULL, " ");
- if(tok) enable_session = (bool)atof(tok);
+ } else if (strncmp(cmd, "j", 1) == 0) {
+ unsigned int value = 100;
+ ret = mm_sound_volume_get_value(VOLUME_TYPE_VOICE, &value);
+ if (ret < 0) {
+ debug_log("mm_sound_volume_get_value 0x%x", ret);
+ } else {
+ if (value != 0)
+ value--;
- debug_log("volume type: %d\t volume is %f\t tonetime: %d\t enable_session %d \n", volume_type, volume, tonetime, enable_session);
- ret = mm_sound_play_tone_ex(tone, volume_type, volume, tonetime, &handle, enable_session);
- if(ret<0)
- debug_log ("[magpie] Play DTMF sound cannot be played ! %d\n", handle);
- }
+ ret = mm_sound_volume_set_value(VOLUME_TYPE_VOICE, value);
+ if (ret < 0)
+ debug_log("mm_sound_volume_set_value 0x%x", ret);
+ else
+ g_print("Current Voice volume is %d\n", value);
}
- else if(strncmp(cmd, "FS", 2) == 0)
- {
- char num = 0;
- char input_string[128] = "";
- char *tok = NULL;
- char *stream_type = NULL;
- int tonetime=0;
- double volume=1.0;
- MMSoundTone_t tone = MM_SOUND_TONE_DTMF_0;
-
- while(num != 'q') {
- fflush(stdin);
- g_print("enter number(0~H exit:q), stream type(media, system, ...), volume(0.0~1.0), time(ms):\t ");
- if (fgets(input_string, sizeof(input_string)-1, stdin) == NULL) {
- g_print ("### fgets return NULL\n");
- }
- tok = strtok(input_string, " ");
- if(!tok) continue;
- if(tok[0] == 'q') {
+
+ } else if (strncmp(cmd, "as", 2) == 0) {
+ debug_log("stream %s type, %d", "media", g_volume_value);
+ ret = mm_sound_play_sound_with_stream_info(g_file_name, "media", -1, 1, mycallback, "USERDATA", &handle);
+ if (ret < 0)
+ debug_log("mm_sound_play_sound() failed with 0x%x", ret);
+
+ } else if (strncmp(cmd, "FS", 2) == 0) {
+ char num = 0;
+ char input_string[128] = "";
+ char *tok = NULL;
+ char *ptr = NULL;
+ char *stream_type = NULL;
+ int tonetime = 0;
+ double volume = 1.0;
+ MMSoundTone_t tone = MM_SOUND_TONE_DTMF_0;
+
+ while (num != 'q') {
+ fflush(stdin);
+ g_print("enter number(0~H exit:q), stream type(media, system, ...), volume(0.0~1.0), time(ms):\t ");
+ if (fgets(input_string, sizeof(input_string)-1, stdin)) {
+ tok = strtok_r(input_string, " ", &ptr);
+ if (!tok)
+ continue;
+ if (tok[0] == 'q') {
break;
- }
- else if(tok[0] < '0' || tok[0] > '~') {
- if(tok[0] == '*' || tok[0] == '#')
- ;
- else
+ } else if (tok[0] < '0' || tok[0] > '~') {
+ if (tok[0] != '*' && tok[0] != '#')
continue;
}
num = tok[0];
- if(num >= '0' && num <= '9') {
+ if (num >= '0' && num <= '9')
tone = (MMSoundTone_t)(num - '0');
- }
- else if(num == '*') {
+ else if (num == '*')
tone = MM_SOUND_TONE_DTMF_S;
- }
- else if(num == '#') {
- tone =MM_SOUND_TONE_DTMF_P;
- }
- else if(num == 'A') { tone = MM_SOUND_TONE_DTMF_A; }
- else if(num == 'B') { tone = MM_SOUND_TONE_DTMF_B; }
- else if(num == 'C') { tone = MM_SOUND_TONE_DTMF_C; }
- else if(num == 'D') { tone = MM_SOUND_TONE_DTMF_D; }
- else if(num == 'E') { tone = MM_SOUND_TONE_SUP_DIAL; }
- else if(num == 'F') { tone = MM_SOUND_TONE_ANSI_DIAL; }
- else if(num == 'G') { tone = MM_SOUND_TONE_JAPAN_DIAL; }
- else if(num == 'H') { tone = MM_SOUND_TONE_SUP_BUSY; }
- else if(num == 'I') { tone = MM_SOUND_TONE_ANSI_BUSY; }
- else if(num == 'J') { tone = MM_SOUND_TONE_JAPAN_BUSY; }
- else if(num == 'K') { tone = MM_SOUND_TONE_SUP_CONGESTION; }
- else if(num == 'L') { tone = MM_SOUND_TONE_ANSI_CONGESTION; }
- else if(num == 'M') { tone = MM_SOUND_TONE_SUP_RADIO_ACK; }
- else if(num == 'N') { tone = MM_SOUND_TONE_JAPAN_RADIO_ACK; }
- else if(num == 'O') { tone = MM_SOUND_TONE_SUP_RADIO_NOTAVAIL; }
- else if(num == 'P') { tone = MM_SOUND_TONE_SUP_ERROR; }
- else if(num == 'Q') { tone = MM_SOUND_TONE_SUP_CALL_WAITING; }
- else if(num == 'R') { tone = MM_SOUND_TONE_ANSI_CALL_WAITING; }
- else if(num == 'S') { tone = MM_SOUND_TONE_SUP_RINGTONE; }
- else if(num == 'T') { tone = MM_SOUND_TONE_ANSI_RINGTONE; }
- else if(num == 'U') { tone = MM_SOUND_TONE_PROP_BEEP; }
- else if(num == 'V') { tone = MM_SOUND_TONE_PROP_ACK; }
- else if(num == 'W') { tone = MM_SOUND_TONE_PROP_NACK; }
- else if(num == 'X') { tone = MM_SOUND_TONE_PROP_PROMPT; }
- else if(num == 'Y') { tone = MM_SOUND_TONE_PROP_BEEP2; }
- else if(num == 'Z') { tone =MM_SOUND_TONE_CDMA_HIGH_SLS; }
- else if(num == '[') { tone = MM_SOUND_TONE_CDMA_MED_SLS; }
- else if(num == ']') { tone = MM_SOUND_TONE_CDMA_LOW_SLS; }
- else if(num == '^') { tone =MM_SOUND_TONE_CDMA_HIGH_S_X4; }
- else if(num == '_') { tone =MM_SOUND_TONE_CDMA_MED_S_X4; }
- else if(num == 'a') { tone =MM_SOUND_TONE_CDMA_LOW_S_X4; }
- else if(num == 'b') { tone =MM_SOUND_TONE_CDMA_HIGH_PBX_L; }
- else if(num == 'c') { tone =MM_SOUND_TONE_CDMA_MED_PBX_L; }
- else if(num == 'd') { tone =MM_SOUND_TONE_CDMA_LOW_PBX_L; }
- else if(num == 'e') { tone =MM_SOUND_TONE_CDMA_HIGH_PBX_SS; }
- else if(num == 'f') { tone =MM_SOUND_TONE_CDMA_MED_PBX_SS; }
- else if(num == 'g') { tone =MM_SOUND_TONE_CDMA_LOW_PBX_SS; }
- else if(num == 'h') { tone =MM_SOUND_TONE_CDMA_HIGH_PBX_SSL; }
- else if(num == 'i') { tone =MM_SOUND_TONE_CDMA_MED_PBX_SSL; }
- else if(num == 'j') { tone =MM_SOUND_TONE_CDMA_LOW_PBX_SSL; }
- else if(num == 'k') { tone =MM_SOUND_TONE_CDMA_HIGH_PBX_SLS; }
- else if(num == 'l') { tone =MM_SOUND_TONE_CDMA_MED_PBX_SLS; }
- else if(num == 'm') { tone =MM_SOUND_TONE_CDMA_LOW_PBX_SLS; }
- else if(num == 'n') { tone =MM_SOUND_TONE_CDMA_HIGH_PBX_S_X4; }
- else if(num == 'o') { tone =MM_SOUND_TONE_CDMA_MED_PBX_S_X4; }
- else if(num == 'p') { tone =MM_SOUND_TONE_CDMA_LOW_PBX_S_X4; }
- else if(num == 'q') { tone =MM_SOUND_TONE_CDMA_ALERT_NETWORK_LITE; }
- else if(num == 'r') { tone =MM_SOUND_TONE_CDMA_ALERT_AUTOREDIAL_LITE; }
- else if(num == 's') { tone =MM_SOUND_TONE_CDMA_ONE_MIN_BEEP; }
- else if(num == 't') { tone =MM_SOUND_TONE_CDMA_KEYPAD_VOLUME_KEY_LITE; }
- else if(num == 'u') { tone =MM_SOUND_TONE_CDMA_PRESSHOLDKEY_LITE; }
- else if(num == 'v') { tone =MM_SOUND_TONE_CDMA_ALERT_INCALL_LITE; }
- else if(num == 'w') { tone =MM_SOUND_TONE_CDMA_EMERGENCY_RINGBACK; }
- else if(num == 'x') { tone =MM_SOUND_TONE_CDMA_ALERT_CALL_GUARD; }
- else if(num == 'y') { tone =MM_SOUND_TONE_CDMA_SOFT_ERROR_LITE; }
- else if(num == 'z') { tone =MM_SOUND_TONE_CDMA_CALLDROP_LITE; }
- else if(num == '{') { tone =MM_SOUND_TONE_LOW_FRE; }
- else if(num == '}') { tone =MM_SOUND_TONE_MED_FRE; }
- else if(num == '~') { tone =MM_SOUND_TONE_HIGH_FRE; }
-
- stream_type = strtok(NULL, " ");
-
- tok = strtok(NULL, " ");
- if(tok) volume = (double)atof(tok);
-
- tok = strtok(NULL, " ");
- if(tok)
- {
+ else if (num == '#')
+ tone = MM_SOUND_TONE_DTMF_P;
+ else if (num == 'A')
+ tone = MM_SOUND_TONE_DTMF_A;
+ else if (num == 'B')
+ tone = MM_SOUND_TONE_DTMF_B;
+ else if (num == 'C')
+ tone = MM_SOUND_TONE_DTMF_C;
+ else if (num == 'D')
+ tone = MM_SOUND_TONE_DTMF_D;
+ else if (num == 'E')
+ tone = MM_SOUND_TONE_SUP_DIAL;
+ else if (num == 'F')
+ tone = MM_SOUND_TONE_ANSI_DIAL;
+ else if (num == 'G')
+ tone = MM_SOUND_TONE_JAPAN_DIAL;
+ else if (num == 'H')
+ tone = MM_SOUND_TONE_SUP_BUSY;
+ else if (num == 'I')
+ tone = MM_SOUND_TONE_ANSI_BUSY;
+ else if (num == 'J')
+ tone = MM_SOUND_TONE_JAPAN_BUSY;
+ else if (num == 'K')
+ tone = MM_SOUND_TONE_SUP_CONGESTION;
+ else if (num == 'L')
+ tone = MM_SOUND_TONE_ANSI_CONGESTION;
+ else if (num == 'M')
+ tone = MM_SOUND_TONE_SUP_RADIO_ACK;
+ else if (num == 'N')
+ tone = MM_SOUND_TONE_JAPAN_RADIO_ACK;
+ else if (num == 'O')
+ tone = MM_SOUND_TONE_SUP_RADIO_NOTAVAIL;
+ else if (num == 'P')
+ tone = MM_SOUND_TONE_SUP_ERROR;
+ else if (num == 'Q')
+ tone = MM_SOUND_TONE_SUP_CALL_WAITING;
+ else if (num == 'R')
+ tone = MM_SOUND_TONE_ANSI_CALL_WAITING;
+ else if (num == 'S')
+ tone = MM_SOUND_TONE_SUP_RINGTONE;
+ else if (num == 'T')
+ tone = MM_SOUND_TONE_ANSI_RINGTONE;
+ else if (num == 'U')
+ tone = MM_SOUND_TONE_PROP_BEEP;
+ else if (num == 'V')
+ tone = MM_SOUND_TONE_PROP_ACK;
+ else if (num == 'W')
+ tone = MM_SOUND_TONE_PROP_NACK;
+ else if (num == 'X')
+ tone = MM_SOUND_TONE_PROP_PROMPT;
+ else if (num == 'Y')
+ tone = MM_SOUND_TONE_PROP_BEEP2;
+ else if (num == 'Z')
+ tone = MM_SOUND_TONE_CDMA_HIGH_SLS;
+ else if (num == '[')
+ tone = MM_SOUND_TONE_CDMA_MED_SLS;
+ else if (num == ']')
+ tone = MM_SOUND_TONE_CDMA_LOW_SLS;
+ else if (num == '^')
+ tone = MM_SOUND_TONE_CDMA_HIGH_S_X4;
+ else if (num == '_')
+ tone = MM_SOUND_TONE_CDMA_MED_S_X4;
+ else if (num == 'a')
+ tone = MM_SOUND_TONE_CDMA_LOW_S_X4;
+ else if (num == 'b')
+ tone = MM_SOUND_TONE_CDMA_HIGH_PBX_L;
+ else if (num == 'c')
+ tone = MM_SOUND_TONE_CDMA_MED_PBX_L;
+ else if (num == 'd')
+ tone = MM_SOUND_TONE_CDMA_LOW_PBX_L;
+ else if (num == 'e')
+ tone = MM_SOUND_TONE_CDMA_HIGH_PBX_SS;
+ else if (num == 'f')
+ tone = MM_SOUND_TONE_CDMA_MED_PBX_SS;
+ else if (num == 'g')
+ tone = MM_SOUND_TONE_CDMA_LOW_PBX_SS;
+ else if (num == 'h')
+ tone = MM_SOUND_TONE_CDMA_HIGH_PBX_SSL;
+ else if (num == 'i')
+ tone = MM_SOUND_TONE_CDMA_MED_PBX_SSL;
+ else if (num == 'j')
+ tone = MM_SOUND_TONE_CDMA_LOW_PBX_SSL;
+ else if (num == 'k')
+ tone = MM_SOUND_TONE_CDMA_HIGH_PBX_SLS;
+ else if (num == 'l')
+ tone = MM_SOUND_TONE_CDMA_MED_PBX_SLS;
+ else if (num == 'm')
+ tone = MM_SOUND_TONE_CDMA_LOW_PBX_SLS;
+ else if (num == 'n')
+ tone = MM_SOUND_TONE_CDMA_HIGH_PBX_S_X4;
+ else if (num == 'o')
+ tone = MM_SOUND_TONE_CDMA_MED_PBX_S_X4;
+ else if (num == 'p')
+ tone = MM_SOUND_TONE_CDMA_LOW_PBX_S_X4;
+ else if (num == 'q')
+ tone = MM_SOUND_TONE_CDMA_ALERT_NETWORK_LITE;
+ else if (num == 'r')
+ tone = MM_SOUND_TONE_CDMA_ALERT_AUTOREDIAL_LITE;
+ else if (num == 's')
+ tone = MM_SOUND_TONE_CDMA_ONE_MIN_BEEP;
+ else if (num == 't')
+ tone = MM_SOUND_TONE_CDMA_KEYPAD_VOLUME_KEY_LITE;
+ else if (num == 'u')
+ tone = MM_SOUND_TONE_CDMA_PRESSHOLDKEY_LITE;
+ else if (num == 'v')
+ tone = MM_SOUND_TONE_CDMA_ALERT_INCALL_LITE;
+ else if (num == 'w')
+ tone = MM_SOUND_TONE_CDMA_EMERGENCY_RINGBACK;
+ else if (num == 'x')
+ tone = MM_SOUND_TONE_CDMA_ALERT_CALL_GUARD;
+ else if (num == 'y')
+ tone = MM_SOUND_TONE_CDMA_SOFT_ERROR_LITE;
+ else if (num == 'z')
+ tone = MM_SOUND_TONE_CDMA_CALLDROP_LITE;
+ else if (num == '{')
+ tone = MM_SOUND_TONE_LOW_FRE;
+ else if (num == '}')
+ tone = MM_SOUND_TONE_MED_FRE;
+ else if (num == '~')
+ tone = MM_SOUND_TONE_HIGH_FRE;
+
+ stream_type = strtok_r(NULL, " ", &ptr);
+
+ tok = strtok_r(NULL, " ", &ptr);
+ if (tok)
+ volume = (double)atof(tok);
+
+ tok = strtok_r(NULL, " ", &ptr);
+ if (tok)
tonetime = atoi(tok);
- }
else
- {
tonetime = MIN_TONE_PLAY_TIME;
- }
- debug_log("stream type: %s\t volume is %f\t tonetime: %d\n", stream_type, volume, tonetime);
+ debug_log("stream type: %s\t volume is %f\t tonetime: %d", stream_type, volume, tonetime);
ret = mm_sound_play_tone_with_stream_info(tone, stream_type, -1, volume, tonetime, &handle);
- if(ret<0)
- debug_log ("[magpie] Play DTMF sound with stream type cannot be played ! %d\n", handle);
+ if (ret < 0)
+ debug_log("failed to mm_sound_play_tone_with_stream_info(), ret[0x%x]", ret);
+ } else {
+ g_print("### fgets return NULL\n");
}
}
- else if (strncmp (cmd, "b",1) == 0)
- {
- DIR *basedir;
- struct dirent *entry;
- struct stat file_stat;
- char fullpath[MAX_PATH_LEN]="";
- struct timespec start_time = {0,};
- struct timespec current_time = {0,};
-
- if(g_dir_name[strlen(g_dir_name)-1] == '/')
- g_dir_name[strlen(g_dir_name)-1] = '\0';
-
- basedir = opendir(g_dir_name);
- if(basedir != NULL)
- {
- while( (entry = readdir(basedir)) != NULL)
- {
- int playfail =0;
- int mywait = 0;
- if(entry->d_name[0] == '.')
- continue;
- memset(fullpath, '\0' ,sizeof(fullpath));
- snprintf(fullpath, sizeof(fullpath)-1,"%s/%s", g_dir_name, entry->d_name);
- debug_log("Try %s\n", fullpath);
- if (lstat(fullpath, &file_stat) == -1)
- continue;
+ } else if (strncmp(cmd, "b", 1) == 0) {
+ DIR *basedir;
+ struct dirent *entry = NULL;
+ struct dirent *prev_entry = NULL;
+ int entry_len;
+ int ret;
+ struct stat file_stat;
+ char fullpath[MAX_PATH_LEN] = "";
+ struct timespec start_time = {0,};
+ struct timespec current_time = {0,};
+
+ if (g_dir_name[strlen(g_dir_name)-1] == '/')
+ g_dir_name[strlen(g_dir_name)-1] = '\0';
+
+ basedir = opendir(g_dir_name);
+ if (basedir != NULL) {
+ entry_len = offsetof(struct dirent, d_name) + fpathconf(dirfd(basedir), MAX_STRING_LEN) + 1;
+ prev_entry = malloc(entry_len);
+
+ while (1) {
+ int playfail = 0;
+ int mywait = 0;
+
+ ret = readdir_r(basedir, prev_entry, &entry);
+ if (ret == 0) {
+ debug_error("error on readdir_r(%p)", basedir);
+ break;
+ }
+ if (entry == NULL)
+ break;
- if(S_ISREG(file_stat.st_mode))
- {
- test_callback_done = 0 ;
- start_time.tv_sec = (long int)(time(NULL));
- start_time.tv_nsec = 0;
- ret = mm_sound_play_sound(fullpath, g_volume_type, test_callback, NULL, &handle);
- if(ret != MM_ERROR_NONE)
- {
- debug_log("Play file error : %s\n", fullpath);
- sleep(4);
- playfail = 1;
- }
- }
- else
- {
- debug_log("this is not regular file : %s\n", fullpath);
+ if (entry->d_name[0] == '.')
+ continue;
+ memset(fullpath, '\0', sizeof(fullpath));
+ snprintf(fullpath, sizeof(fullpath) - 1, "%s/%s", g_dir_name, entry->d_name);
+ debug_log("Try %s", fullpath);
+
+ if (lstat(fullpath, &file_stat) == -1)
+ continue;
+
+ if (S_ISREG(file_stat.st_mode)) {
+ test_callback_done = 0 ;
+ start_time.tv_sec = (long int)(time(NULL));
+ start_time.tv_nsec = 0;
+
+ ret = mm_sound_play_sound_with_stream_info(fullpath, "media", -1, 1, test_callback, "USERDATA", &handle);
+ if (ret != MM_ERROR_NONE) {
+ debug_log("Play file error : %s", fullpath);
+ sleep(4);
playfail = 1;
}
- while((test_callback_done == 0) && (playfail ==0))
- {
- current_time.tv_sec = (long int)(time(NULL));
- current_time.tv_nsec = 0;
- if(current_time.tv_sec - start_time.tv_sec > 200)
- {
- if((++mywait)%5 == 0)
- {
- debug_log("I'm waiting callback for %d seconds after play %s\n",
- (int)(current_time.tv_sec - start_time.tv_sec),
- fullpath);
- }
+ } else {
+ debug_log("this is not regular file : %s", fullpath);
+ playfail = 1;
+ }
+ while ((test_callback_done == 0) && (playfail == 0)) {
+ current_time.tv_sec = (long int)(time(NULL));
+ current_time.tv_nsec = 0;
+ if (current_time.tv_sec - start_time.tv_sec > 200) {
+ if ((++mywait)%5 == 0) {
+ debug_log("I'm waiting callback for %d seconds after play %s",
+ (int)(current_time.tv_sec - start_time.tv_sec), fullpath);
}
- sleep(2);
}
- debug_log("goto next file\n");
+ sleep(2);
}
- closedir(basedir);
- }
- else
- {
- debug_log("Cannot Open such a directory %s\n", g_dir_name);
+ debug_log("goto next file");
}
-
+ free(prev_entry);
+ closedir(basedir);
+ } else {
+ debug_log("Cannot Open such a directory %s", g_dir_name);
}
- else if (strncmp (cmd, "c",1) == 0)
- {
- soundparam.volume = g_volume_value;
- soundparam.loop = -1; /* loop case */
- soundparam.callback = mycallback;
- soundparam.data = NULL;
- soundparam.mem_ptr = NULL;
- soundparam.mem_size = 0;
- soundparam.filename = g_file_name;
- soundparam.volume_config = g_volume_type;
-
- if ((mm_sound_play_sound_ex (&soundparam, &handle))<0)
- debug_log ("Play EX sound cannot be played !\n");
-
- debug_log ("Ex sound is played Handle is [%d]\n", handle);
- }
- else if (strncmp (cmd, "f",1) == 0) {
- g_menu_state=CURRENT_STATUS_FILENAME;
- }
-
- else if (strncmp (cmd, "d",1) == 0) {
- g_menu_state=CURRENT_STATUS_DIRNAME;
- }
- else if (strncmp (cmd, "s",1) == 0) {
- if(mm_sound_stop_sound(handle))
- debug_log (" Cannot stop sound !!! %d \n", handle);
- }
- else if (strncmp (cmd, "1",1) == 0) {
- //ap to spk
- g_print("Not supported - Set path for speaker playback\n");
- }
+ } else if (strncmp(cmd, "f", 1) == 0) {
+ g_menu_state = CURRENT_STATUS_FILENAME;
- else if (strncmp (cmd, "2",1) == 0) {
- //ap to headset
- g_print("Not supported - Set path for headset playback\n");
- }
- else if (strncmp (cmd, "3",1) == 0) {
+ } else if (strncmp(cmd, "d", 1) == 0) {
+ g_menu_state = CURRENT_STATUS_DIRNAME;
- }
- else if (strncmp (cmd, "4",1) == 0) {
- //recording
- g_print("Not supported - Set path for recording with main mic\n");
- }
- else if (strncmp (cmd, "5",1) == 0) {
+ } else if (strncmp(cmd, "s", 1) == 0) {
+ if (mm_sound_stop_sound(handle))
+ debug_log(" Cannot stop sound !!! %d ", handle);
- }
- else if (strncmp (cmd, "6",1) == 0) {
- //voice call
- g_print("Not supported - Set path for voicecall\n");
- }
- else if (strncmp (cmd, "7",1) == 0) {
- //voicecall release
- g_print("Not supported - release path for voicecall\n");
- }
- else if (strncmp (cmd, "8",1) == 0) {
- //voice call
- g_print("Not supported - Set path for VT call\n");
- }
-
- else if (strncmp (cmd, "9",1) == 0) {
- //voicecall release
- g_print("Not supported - release path for VT call\n");
- }
-
- /* -------------------------- Route Test : Starts -------------------------- */
-#if 0
- g_print("==================================================================\n");
- g_print(" Audio route APIs\n");
- g_print("==================================================================\n");
- g_print("u : Foreach Available Routes \t");
- g_print("i : Get Active Devices \n");
- g_print("o : Add Available Routes Callback \t");
- g_print("O : Remove Available Routes Callback \n");
- g_print("p : Add Active Route Callback\t");
- g_print("P : Remove Active Route Callback \n");
- g_print("{ : Get BT A2DP Status\n");
-#endif
- else if(strncmp(cmd, "z", 1) == 0) {
- if(MM_ERROR_NONE != mm_session_init(MM_SESSION_TYPE_CALL))
- {
- g_print("Call session init failed\n");
- }
- }
- else if(strncmp(cmd, "Z", 1) == 0) {
- if(MM_ERROR_NONE != mm_session_init(MM_SESSION_TYPE_VIDEOCALL))
- {
- g_print("VideoCall session init failed\n");
- }
- }
- else if(strncmp(cmd, "N", 1) == 0) {
- if(MM_ERROR_NONE != mm_session_init(MM_SESSION_TYPE_NOTIFY))
- {
- g_print("Notify session init failed\n");
- }
- }
- else if(strncmp(cmd, "n", 1) == 0) {
- if(MM_ERROR_NONE != mm_session_init(MM_SESSION_TYPE_VOIP))
- {
- g_print("VOIP session init failed\n");
- }
- }
- else if(strncmp(cmd, "v", 1) == 0) {
- if(MM_ERROR_NONE != mm_session_finish())
- {
- g_print("Call session finish failed\n");
- }
- }
-
- else if(strncmp(cmd, "L", 1) == 0) {
+ } else if (strncmp(cmd, "L", 1) == 0) {
int ret = 0;
mm_sound_device_flags_e flags = MM_SOUND_DEVICE_ALL_FLAG;
MMSoundDeviceList_t device_list;
char *name = NULL;
MMSoundDevice_t device_h = NULL;
int dret = MM_ERROR_NONE;
+ int product_id = -1, vendor_id = -1;
ret = mm_sound_get_current_device_list(flags, &device_list);
if (ret) {
} else {
g_print("device_list[%p], device_h[%p]\n", device_list, device_h);
do {
- dret = mm_sound_get_next_device (device_list, &device_h);
+ dret = mm_sound_get_next_device(device_list, &device_h);
if (dret) {
debug_error("failed to mm_sound_get_next_device(), dret[0x%x]\n", dret);
} else {
ret = mm_sound_get_device_type(device_h, &device_type);
- if (ret) {
- debug_error("failed to mm_sound_get_device_type()\n");
- }
+ if (ret)
+ debug_error("failed to mm_sound_get_device_type()");
ret = mm_sound_get_device_io_direction(device_h, &io_direction);
- if (ret) {
- debug_error("failed to mm_sound_get_device_io_direction()\n");
- }
+ if (ret)
+ debug_error("failed to mm_sound_get_device_io_direction()");
ret = mm_sound_get_device_state(device_h, &state);
- if (ret) {
- debug_error("failed to mm_sound_get_device_state()\n");
- }
+ if (ret)
+ debug_error("failed to mm_sound_get_device_state()");
ret = mm_sound_get_device_id(device_h, &id);
- if (ret) {
- debug_error("failed to mm_sound_get_device_id()\n");
- }
+ if (ret)
+ debug_error("failed to mm_sound_get_device_id()");
ret = mm_sound_get_device_name(device_h, &name);
- if (ret) {
- debug_error("failed to mm_sound_get_device_name()\n");
- }
- debug_log("*** --- [NEXT DEVICE] type[%d], id[%d], io_direction[%d], state[%d], name[%s]\n", device_type, id, io_direction, state, name);
+ if (ret)
+ debug_error("failed to mm_sound_get_device_name()");
+ ret = mm_sound_get_device_vendor_id(device_h, &vendor_id);
+ if (ret)
+ debug_error("failed to mm_sound_get_device_vendor_id()");
+ ret = mm_sound_get_device_product_id(device_h, &product_id);
+ if (ret)
+ debug_error("failed to mm_sound_get_device_product_id()");
+ debug_log("*** --- [NEXT DEVICE] type[%d], id[%d], io_direction[%d], state[%d], "
+ "name[%s] vendor_id[%04x] product_id[%04x]",
+ device_type, id, io_direction, state, name, vendor_id, product_id);
}
} while (dret == MM_ERROR_NONE);
do {
dret = MM_ERROR_NONE;
- dret = mm_sound_get_prev_device (device_list, &device_h);
+ dret = mm_sound_get_prev_device(device_list, &device_h);
if (dret) {
- debug_error("failed to mm_sound_get_prev_device(), dret[0x%x]\n", dret);
+ debug_error("failed to mm_sound_get_prev_device(), dret[0x%x]", dret);
} else {
ret = mm_sound_get_device_type(device_h, &device_type);
- if (ret) {
- debug_error("failed to mm_sound_get_device_type()\n");
- }
+ if (ret)
+ debug_error("failed to mm_sound_get_device_type()");
ret = mm_sound_get_device_io_direction(device_h, &io_direction);
- if (ret) {
- debug_error("failed to mm_sound_get_device_io_direction()\n");
- }
+ if (ret)
+ debug_error("failed to mm_sound_get_device_io_direction()");
ret = mm_sound_get_device_state(device_h, &state);
- if (ret) {
- debug_error("failed to mm_sound_get_device_state()\n");
- }
+ if (ret)
+ debug_error("failed to mm_sound_get_device_state()");
ret = mm_sound_get_device_id(device_h, &id);
- if (ret) {
- debug_error("failed to mm_sound_get_device_id()\n");
- }
+ if (ret)
+ debug_error("failed to mm_sound_get_device_id()");
ret = mm_sound_get_device_name(device_h, &name);
- if (ret) {
- debug_error("failed to mm_sound_get_device_name()\n");
- }
- debug_log("*** --- [PREV DEVICE] type[%d], id[%d], io_direction[%d], state[%d], name[%s]\n", device_type, id, io_direction, state, name);
+ if (ret)
+ debug_error("failed to mm_sound_get_device_name()");
+ ret = mm_sound_get_device_vendor_id(device_h, &vendor_id);
+ if (ret)
+ debug_error("failed to mm_sound_get_device_vendor_id()");
+ ret = mm_sound_get_device_product_id(device_h, &product_id);
+ if (ret)
+ debug_error("failed to mm_sound_get_device_product_id()");
+ debug_log("*** --- [PREV DEVICE] type[%d], id[%d], io_direction[%d], state[%d], "
+ "name[%s] vendor_id[%04x] product_id[%04x]",
+ device_type, id, io_direction, state, name, vendor_id, product_id);
}
} while (dret == MM_ERROR_NONE);
- mm_sound_free_device_list(device_list);
- debug_log("device list freed\n");
}
- }
- else if(strncmp(cmd, "C", 1) == 0) {
+ } else if (strncmp(cmd, "I", 1) == 0) {
+ int ret = 0;
+ MMSoundDevice_t device_h = NULL;
+ mm_sound_device_type_e device_type = 0;
+ mm_sound_device_io_direction_e io_direction = 0;
+ mm_sound_device_state_e state = 0;
+ char *name;
+ int id = 0, input_id = 0;
+ char input_string[128];
+
+ fflush(stdin);
+ g_print("> Input id : ");
+
+ if (fgets(input_string, sizeof(input_string)-1, stdin)) {
+ input_id = atoi(input_string);
+
+ ret = mm_sound_get_device_by_id(input_id, &device_h);
+ if (ret == MM_ERROR_NONE) {
+ ret = mm_sound_get_device_type(device_h, &device_type);
+ if (ret)
+ g_print("failed to mm_sound_get_device_type()\n");
+ ret = mm_sound_get_device_io_direction(device_h, &io_direction);
+ if (ret)
+ g_print("failed to mm_sound_get_device_io_direction()\n");
+ ret = mm_sound_get_device_state(device_h, &state);
+ if (ret)
+ g_print("failed to mm_sound_get_device_state()\n");
+ ret = mm_sound_get_device_id(device_h, &id);
+ if (ret)
+ g_print("failed to mm_sound_get_device_id()\n");
+ ret = mm_sound_get_device_name(device_h, &name);
+ if (ret)
+ g_print("failed to mm_sound_get_device_name()\n");
+ g_print("*** --- type[%d], id[%d], io_direction[%d], state[%d], name[%s]\n", device_type, id, io_direction, state, name);
+ } else {
+ g_print("failed to mm_sound_get_device_by_id()\n");
+ }
+
+ ret = mm_sound_free_device(device_h);
+ if (ret)
+ g_print("failed to mm_sound_free_device()\n");
+ } else {
+ g_print("### fgets return NULL\n");
+ }
+
+ } else if (strncmp(cmd, "C", 1) == 0) {
int ret = 0;
char input_string[128];
mm_sound_device_flags_e device_flag_1 = MM_SOUND_DEVICE_ALL_FLAG;
char flag_1, flag_2, flag_3;
fflush(stdin);
- g_print ("1. IO_DIRECTION_IN_FLAG\n");
- g_print ("2. IO_DIRECTION_OUT_FLAG\n");
- g_print ("3. IO_DIRECTION_BOTH_FLAG\n");
- g_print ("4. TYPE_INTERNAL_FLAG\n");
- g_print ("5. TYPE_EXTERNAL_FLAG\n");
- g_print ("6. STATE_DEACTIVATED_FLAG\n");
- g_print ("7. STATE_ACTIVATED_FLAG\n");
- g_print ("8. ALL_FLAG\n");
+ g_print("1. IO_DIRECTION_IN_FLAG\n");
+ g_print("2. IO_DIRECTION_OUT_FLAG\n");
+ g_print("3. IO_DIRECTION_BOTH_FLAG\n");
+ g_print("4. TYPE_INTERNAL_FLAG\n");
+ g_print("5. TYPE_EXTERNAL_FLAG\n");
+ g_print("6. STATE_DEACTIVATED_FLAG\n");
+ g_print("7. STATE_ACTIVATED_FLAG\n");
+ g_print("8. ALL_FLAG\n");
g_print("> select flag numbers (total 3): (eg. 2 5 7)");
if (fgets(input_string, sizeof(input_string)-1, stdin)) {
- g_print ("### fgets return NULL\n");
- }
- flag_1 = input_string[0];
- flag_2 = input_string[2];
- flag_3 = input_string[4];
-
- if(flag_1 == '1') { device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG; }
- else if(flag_1 == '2') { device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG; }
- else if(flag_1 == '3') { device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG; }
- else if(flag_1 == '4') { device_flag_1 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG; }
- else if(flag_1 == '5') { device_flag_1 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG; }
- else if(flag_1 == '6') { device_flag_1 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG; }
- else if(flag_1 == '7') { device_flag_1 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG; }
- else if(flag_1 == '8') { device_flag_1 = MM_SOUND_DEVICE_ALL_FLAG; }
- if(flag_2 == '1') { device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG; }
- else if(flag_2 == '2') { device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG; }
- else if(flag_2 == '3') { device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG; }
- else if(flag_2 == '4') { device_flag_2 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG; }
- else if(flag_2 == '5') { device_flag_2 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG; }
- else if(flag_2 == '6') { device_flag_2 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG; }
- else if(flag_2 == '7') { device_flag_2 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG; }
- else if(flag_2 == '8') { device_flag_2 = MM_SOUND_DEVICE_ALL_FLAG; }
- if(flag_3 == '1') { device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG; }
- else if(flag_3 == '2') { device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG; }
- else if(flag_3 == '3') { device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG; }
- else if(flag_3 == '4') { device_flag_3 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG; }
- else if(flag_3 == '5') { device_flag_3 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG; }
- else if(flag_3 == '6') { device_flag_3 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG; }
- else if(flag_3 == '7') { device_flag_3 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG; }
- else if(flag_3 == '8') { device_flag_3 = MM_SOUND_DEVICE_ALL_FLAG; }
- g_print("device_connected_callback");
- 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);
- if (ret) {
- g_print("failed to mm_sound_add_device_connected_callback(), ret[0x%x]\n", ret);
+ flag_1 = input_string[0];
+ flag_2 = input_string[2];
+ flag_3 = input_string[4];
+
+ if (flag_1 == '1')
+ device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG;
+ else if (flag_1 == '2')
+ device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG;
+ else if (flag_1 == '3')
+ device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG;
+ else if (flag_1 == '4')
+ device_flag_1 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG;
+ else if (flag_1 == '5')
+ device_flag_1 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG;
+ else if (flag_1 == '6')
+ device_flag_1 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG;
+ else if (flag_1 == '7')
+ device_flag_1 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG;
+ else if (flag_1 == '8')
+ device_flag_1 = MM_SOUND_DEVICE_ALL_FLAG;
+
+ if (flag_2 == '1')device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG;
+ else if (flag_2 == '2')
+ device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG;
+ else if (flag_2 == '3')
+ device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG;
+ else if (flag_2 == '4')
+ device_flag_2 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG;
+ else if (flag_2 == '5')
+ device_flag_2 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG;
+ else if (flag_2 == '6')
+ device_flag_2 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG;
+ else if (flag_2 == '7')
+ device_flag_2 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG;
+ else if (flag_2 == '8')
+ device_flag_2 = MM_SOUND_DEVICE_ALL_FLAG;
+
+ if (flag_3 == '1')
+ device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG;
+ else if (flag_3 == '2')
+ device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG;
+ else if (flag_3 == '3')
+ device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG;
+ else if (flag_3 == '4')
+ device_flag_3 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG;
+ else if (flag_3 == '5')
+ device_flag_3 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG;
+ else if (flag_3 == '6')
+ device_flag_3 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG;
+ else if (flag_3 == '7')
+ device_flag_3 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG;
+ else if (flag_3 == '8')
+ device_flag_3 = MM_SOUND_DEVICE_ALL_FLAG;
+
+ g_print("device_connected_callback");
+ 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);
+ if (ret)
+ g_print("failed to mm_sound_add_device_connected_callback(), ret[0x%x]\n", ret);
+ else
+ 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);
} else {
- 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);
+ g_print("### fgets return NULL\n");
}
- }
- else if(strncmp(cmd, "D", 1) == 0) {
+ } else if (strncmp(cmd, "D", 1) == 0) {
int ret = 0;
ret = mm_sound_remove_device_connected_callback(g_subs_id_device_conn);
- if (ret) {
+ if (ret)
g_print("failed to mm_sound_remove_device_connected_callback(), ret[0x%x]\n", ret);
- }
- }
- else if(strncmp(cmd, "Q", 1) == 0) {
+
+ } else if (strncmp(cmd, "Q", 1) == 0) {
int ret = 0;
char input_string[128];
mm_sound_device_flags_e device_flag_1 = MM_SOUND_DEVICE_ALL_FLAG;
char flag_1, flag_2, flag_3;
fflush(stdin);
- g_print ("1. IO_DIRECTION_IN_FLAG\n");
- g_print ("2. IO_DIRECTION_OUT_FLAG\n");
- g_print ("3. IO_DIRECTION_BOTH_FLAG\n");
- g_print ("4. TYPE_INTERNAL_FLAG\n");
- g_print ("5. TYPE_EXTERNAL_FLAG\n");
- g_print ("6. STATE_DEACTIVATED_FLAG\n");
- g_print ("7. STATE_ACTIVATED_FLAG\n");
- g_print ("8. ALL_FLAG\n");
+ g_print("1. IO_DIRECTION_IN_FLAG\n");
+ g_print("2. IO_DIRECTION_OUT_FLAG\n");
+ g_print("3. IO_DIRECTION_BOTH_FLAG\n");
+ g_print("4. TYPE_INTERNAL_FLAG\n");
+ g_print("5. TYPE_EXTERNAL_FLAG\n");
+ g_print("6. STATE_DEACTIVATED_FLAG\n");
+ g_print("7. STATE_ACTIVATED_FLAG\n");
+ g_print("8. ALL_FLAG\n");
g_print("> select flag numbers (total 3): (eg. 2 5 7)");
if (fgets(input_string, sizeof(input_string)-1, stdin)) {
- g_print ("### fgets return NULL\n");
- }
- flag_1 = input_string[0];
- flag_2 = input_string[2];
- flag_3 = input_string[4];
-
- if(flag_1 == '1') { device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG; }
- else if(flag_1 == '2') { device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG; }
- else if(flag_1 == '3') { device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG; }
- else if(flag_1 == '4') { device_flag_1 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG; }
- else if(flag_1 == '5') { device_flag_1 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG; }
- else if(flag_1 == '6') { device_flag_1 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG; }
- else if(flag_1 == '7') { device_flag_1 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG; }
- else if(flag_1 == '8') { device_flag_1 = MM_SOUND_DEVICE_ALL_FLAG; }
- if(flag_2 == '1') { device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG; }
- else if(flag_2 == '2') { device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG; }
- else if(flag_2 == '3') { device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG; }
- else if(flag_2 == '4') { device_flag_2 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG; }
- else if(flag_2 == '5') { device_flag_2 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG; }
- else if(flag_2 == '6') { device_flag_2 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG; }
- else if(flag_2 == '7') { device_flag_2 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG; }
- else if(flag_2 == '8') { device_flag_2 = MM_SOUND_DEVICE_ALL_FLAG; }
- if(flag_3 == '1') { device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG; }
- else if(flag_3 == '2') { device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG; }
- else if(flag_3 == '3') { device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG; }
- else if(flag_3 == '4') { device_flag_3 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG; }
- else if(flag_3 == '5') { device_flag_3 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG; }
- else if(flag_3 == '6') { device_flag_3 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG; }
- else if(flag_3 == '7') { device_flag_3 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG; }
- else if(flag_3 == '8') { device_flag_3 = MM_SOUND_DEVICE_ALL_FLAG; }
- g_print("add_device_info_changed");
- 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);
- if (ret) {
- g_print("failed to mm_sound_add_device_information_changed_callback(), ret[0x%x]\n", ret);
+ flag_1 = input_string[0];
+ flag_2 = input_string[2];
+ flag_3 = input_string[4];
+
+ if (flag_1 == '1')
+ device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG;
+ else if (flag_1 == '2')
+ device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG;
+ else if (flag_1 == '3')
+ device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG;
+ else if (flag_1 == '4')
+ device_flag_1 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG;
+ else if (flag_1 == '5')
+ device_flag_1 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG;
+ else if (flag_1 == '6')
+ device_flag_1 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG;
+ else if (flag_1 == '7')
+ device_flag_1 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG;
+ else if (flag_1 == '8')
+ device_flag_1 = MM_SOUND_DEVICE_ALL_FLAG;
+
+ if (flag_2 == '1')
+ device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG;
+ else if (flag_2 == '2')
+ device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG;
+ else if (flag_2 == '3')
+ device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG;
+ else if (flag_2 == '4')
+ device_flag_2 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG;
+ else if (flag_2 == '5')
+ device_flag_2 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG;
+ else if (flag_2 == '6')
+ device_flag_2 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG;
+ else if (flag_2 == '7')
+ device_flag_2 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG;
+ else if (flag_2 == '8')
+ device_flag_2 = MM_SOUND_DEVICE_ALL_FLAG;
+
+ if (flag_3 == '1')
+ device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG;
+ else if (flag_3 == '2')
+ device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG;
+ else if (flag_3 == '3')
+ device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG;
+ else if (flag_3 == '4')
+ device_flag_3 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG;
+ else if (flag_3 == '5')
+ device_flag_3 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG;
+ else if (flag_3 == '6')
+ device_flag_3 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG;
+ else if (flag_3 == '7')
+ device_flag_3 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG;
+ else if (flag_3 == '8')
+ device_flag_3 = MM_SOUND_DEVICE_ALL_FLAG;
+
+ g_print("add_device_state_changed");
+ ret = mm_sound_add_device_state_changed_callback(device_flag_1 | device_flag_2 | device_flag_3, device_state_changed_cb, NULL, &g_subs_id_device_state);
+ if (ret)
+ g_print("failed to mm_sound_add_device_state_changed_callback(), ret[0x%x]\n", ret);
+ else
+ g_print("device_flags[0x%x], callback fun[%p], subs_id[%u]\n", device_flag_1|device_flag_2|device_flag_3, device_state_changed_cb, g_subs_id_device_state);
+
} else {
- 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);
+ g_print("### fgets return NULL\n");
}
- }
- else if(strncmp(cmd, "W", 1) == 0) {
+ } else if (strncmp(cmd, "W", 1) == 0) {
int ret = 0;
- ret = mm_sound_remove_device_information_changed_callback(g_subs_id_device_info);
- if (ret) {
- g_print("failed to mm_sound_remove_device_information_changed_callback(), ret[0x%x]\n", ret);
- }
- }
+ ret = mm_sound_remove_device_state_changed_callback(g_subs_id_device_state);
+ if (ret)
+ g_print("failed to mm_sound_remove_device_state_changed_callback(), ret[0x%x]\n", ret);
- else if (strncmp(cmd, "x", 1) == 0) {
+ } else if (strncmp(cmd, "x", 1) == 0) {
quit_program();
}
break;
case CURRENT_STATUS_FILENAME:
input_filename(cmd);
- g_menu_state=CURRENT_STATUS_MAINMENU;
+ g_menu_state = CURRENT_STATUS_MAINMENU;
break;
case CURRENT_STATUS_DIRNAME:
input_dirname(cmd);
- g_menu_state=CURRENT_STATUS_MAINMENU;
+ g_menu_state = CURRENT_STATUS_MAINMENU;
break;
+
case CURRENT_STATUS_POSITION:
break;
+
}
- //g_timeout_add(100, timeout_menu_display, 0);
}
void volume_change_callback(volume_type_t type, unsigned int volume, void *user_data)
stdin_channel = g_io_channel_unix_new(0);
g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc)input, NULL);
- g_loop = g_main_loop_new (NULL, 1);
+ g_loop = g_main_loop_new(NULL, 1);
MMSOUND_STRNCPY(g_file_name, POWERON_FILE, MAX_STRING_LEN);
- g_print("\nThe input filename is '%s' \n\n",g_file_name);
+ g_print("\nThe input filename is '%s' \n\n", g_file_name);
/* test volume changed callback */
g_print("callback function addr :: %p\n", volume_change_callback);
g_volume_type = VOLUME_TYPE_MEDIA;
ret = mm_sound_volume_get_value(g_volume_type, &g_volume_value);
- if(ret < 0) {
+ if (ret < 0)
g_print("mm_sound_volume_get_value 0x%x\n", ret);
- }
+
mm_sound_add_volume_changed_callback(volume_change_callback, (void*) &g_volume_type, &g_subs_id_volume);
displaymenu();
- g_main_loop_run (g_loop);
+ g_main_loop_run(g_loop);
return 0;
}
-