gboolean timeout_quit_program(void *data);
gboolean input(GIOChannel *channel);
+static void print_device_info(MMSoundDevice_t device_h)
+{
+ 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 ret = 0;
+ int id = 0;
+ int vendor_id = -1, product_id = -1;
+ char vendor_string[MAX_STRING_LEN], product_string[MAX_STRING_LEN];
+ char *name = NULL;
+
+ ret = mm_sound_get_device_type(device_h, &device_type);
+ if (ret != MM_ERROR_NONE)
+ debug_error("failed to mm_sound_get_device_type(). ret:0x%x", ret);
+ ret = mm_sound_get_device_io_direction(device_h, &io_direction);
+ if (ret != MM_ERROR_NONE)
+ debug_error("failed to mm_sound_get_device_io_direction(). ret:0x%x", ret);
+ ret = mm_sound_get_device_state(device_h, &state);
+ if (ret != MM_ERROR_NONE)
+ debug_error("failed to mm_sound_get_device_state(). ret:0x%x", ret);
+ ret = mm_sound_get_device_id(device_h, &id);
+ if (ret != MM_ERROR_NONE)
+ debug_error("failed to mm_sound_get_device_id(). ret:0x%x", ret);
+ ret = mm_sound_get_device_name(device_h, &name);
+ if (ret != MM_ERROR_NONE)
+ debug_error("failed to mm_sound_get_device_name(). ret:0x%x", ret);
+ ret = mm_sound_get_device_vendor_id(device_h, &vendor_id);
+ if (ret != MM_ERROR_NONE)
+ debug_error("failed to mm_sound_get_device_vendor_id(). ret:0x%x", ret);
+ ret = mm_sound_get_device_product_id(device_h, &product_id);
+ if (ret != MM_ERROR_NONE)
+ debug_error("failed to mm_sound_get_device_product_id(). ret:0x%x", ret);
+
+ if(vendor_id == -1)
+ snprintf(vendor_string, MAX_STRING_LEN, "NO ID");
+ else
+ snprintf(vendor_string, MAX_STRING_LEN, "%d", vendor_id);
+
+ if(product_id == -1)
+ snprintf(product_string, MAX_STRING_LEN, "NO ID");
+ else
+ snprintf(product_string, MAX_STRING_LEN, "%d", product_id);
+
+ debug_log("[DEVICE INFO]--------------------------- \n"
+ "type : %d\n"
+ "id : %d\n"
+ "io_direction : %d\n"
+ "state : %d\n"
+ "name : %s\n"
+ "vendor id : %s\n"
+ "product id : %s\n",
+ device_type, id, io_direction, state, name, vendor_string, product_string);
+}
+
void mycallback(void *data, int id)
{
char *str = (char*)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_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()");
- ret = mm_sound_get_device_io_direction(device_h, &io_direction);
- 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()");
- ret = mm_sound_get_device_id(device_h, &id);
- 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()");
- 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);
+ print_device_info(device_h);
}
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_io_direction_e io_direction = 0;
- mm_sound_device_state_e state = 0;
- int id = 0;
- char *name = NULL;
- 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()");
- ret = mm_sound_get_device_io_direction(device_h, &io_direction);
- 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()");
- ret = mm_sound_get_device_id(device_h, &id);
- 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()");
- 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);
+ print_device_info(device_h);
}
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)
int ret = 0;
mm_sound_device_flags_e flags = MM_SOUND_DEVICE_ALL_FLAG;
MMSoundDeviceList_t device_list;
- 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;
- 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) {
g_print("device_list[%p], device_h[%p]\n", device_list, device_h);
do {
dret = mm_sound_get_next_device(device_list, &device_h);
- if (dret) {
+ if (dret == MM_ERROR_NONE) {
+ print_device_info(device_h);
+ } else if (dret != MM_ERROR_SOUND_NO_DATA){
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()");
- ret = mm_sound_get_device_io_direction(device_h, &io_direction);
- 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()");
- ret = mm_sound_get_device_id(device_h, &id);
- 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()");
- 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);
- if (dret) {
+ if (dret == MM_ERROR_NONE) {
+ print_device_info(device_h);
+ } else if (dret != MM_ERROR_SOUND_NO_DATA){
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()");
- ret = mm_sound_get_device_io_direction(device_h, &io_direction);
- 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()");
- ret = mm_sound_get_device_id(device_h, &id);
- 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()");
- 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);
}
} 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;
+ int input_id = 0;
char input_string[128];
fflush(stdin);
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);
+ print_device_info(device_h);
} else {
g_print("failed to mm_sound_get_device_by_id()\n");
}