int mm_sound_get_device_id(MMSoundDevice_t device_h, int *id);
int mm_sound_get_device_state(MMSoundDevice_t device_h, mm_sound_device_state_e *state);
int mm_sound_get_device_name(MMSoundDevice_t device_h, char **name);
+int mm_sound_get_device_vendor_id(MMSoundDevice_t device_h, int *vendor_id);
+int mm_sound_get_device_product_id(MMSoundDevice_t device_h, int *product_id);
/**
* Active device changed callback function type.
typedef void (*mm_sound_volume_changed_wrapper_cb)(const char *direction, const char *volume_type_str, int volume_level, void *userdata);
typedef void (*mm_sound_device_connected_wrapper_cb)(int device_id, const char *device_type, int io_direction, int state,
- const char *name, int *stream_id, int stream_num, gboolean is_connected, void *userdata);
+ const char *name, int *vendor_id, int *product_id, int *stream_id, int stream_num, gboolean is_connected, void *userdata);
typedef void (*mm_sound_device_info_changed_wrapper_cb)(int device_id, const char *device_type, int io_direction, int state,
- const char *name, int *stream_id, int stream_num, int changed_device_info_type, void *userdata);
+ const char *name, int *vendor_id, int *product_id, int *stream_id, int stream_num, int changed_device_info_type, void *userdata);
typedef void (*mm_sound_device_state_changed_wrapper_cb)(int device_id, const char *device_type, int io_direction, int state,
- const char *name, int *stream_id, int stream_num, void *userdata);
+ const char *name, int *vendor_id, int *product_id, int *stream_id, int stream_num, void *userdata);
typedef void (*mm_sound_stop_callback_wrapper_func)(int id, void *userdata);
#endif /* __MM_SOUND_CLIENT_H__ */
int stream_id[MAX_STREAM_ON_DEVICE];
/* When this value is less than 0, should query to server-side */
int stream_num;
+
+ /* For USB device from udev, if not -1 */
+ int vendor_id;
+ int product_id;
} mm_sound_device_t;
typedef struct {
}
static int _fill_sound_device(mm_sound_device_t *device_h, int device_id, const char *device_type,
- int direction, int state, const char *name, int *stream_id, int stream_num)
+ int direction, int state, const char *name, int vendor_id, int product_id,
+ int *stream_id, int stream_num)
{
int i;
device_h->state = state;
MMSOUND_STRNCPY(device_h->name, name, MAX_DEVICE_NAME_NUM);
MMSOUND_STRNCPY(device_h->type, device_type, MAX_DEVICE_TYPE_STR_LEN);
+ device_h->vendor_id = vendor_id;
+ device_h->product_id = product_id;
if (stream_num > 0) {
device_h->stream_num = stream_num;
}
static void _mm_sound_device_connected_callback_wrapper_func(int device_id, const char *device_type, int io_direction,
- int state, const char *name, int *stream_id, int stream_num,
- gboolean is_connected, void *userdata)
+ int state, const char *name, int vendor_id, int product_id, int *stream_id, int stream_num,
+ gboolean is_connected, void *userdata)
{
mm_sound_device_t device_h;
struct callback_data *cb_data = (struct callback_data*) userdata;
int device_flags;
- debug_log("[Device %s] id(%d) type(%s) direction(%d) state(%d) name(%s)",
+ debug_log("[Device %s] id(%d) type(%s) direction(%d) state(%d) name(%s) vendor-id(%04x) product-id(%04x)",
is_connected ? "Connected" : "Disconnected", device_id, device_type, io_direction,
- state, name, is_connected);
+ state, name, vendor_id, product_id, is_connected);
if (cb_data == NULL) {
debug_warning("device connected changed callback data null");
if (!device_is_match_with_mask(device_type, io_direction, state, device_flags))
return;
- if (_fill_sound_device(&device_h, device_id, device_type, io_direction, state, name, stream_id, stream_num) < 0) {
+ if (_fill_sound_device(&device_h, device_id, device_type, io_direction, state, name,
+ vendor_id, product_id, stream_id, stream_num) < 0) {
debug_error("Failed to fill sound device");
return;
}
}
static void _mm_sound_device_info_changed_callback_wrapper_func(int device_id, const char *device_type, int io_direction,
- int state, const char *name, int *stream_id, int stream_num,
- int changed_device_info_type, void *userdata)
+ int state, const char *name, int vendor_id, int product_id, int *stream_id, int stream_num,
+ int changed_device_info_type, void *userdata)
{
mm_sound_device_t device_h;
struct callback_data *cb_data = (struct callback_data*) userdata;
int device_flags;
- debug_log("[Device Info Changed] id(%d) type(%s) direction(%d) state(%d) name(%s) changed_info_type(%d)",
- device_id, device_type, io_direction, state, name, changed_device_info_type);
+ debug_log("[Device Info Changed] id(%d) type(%s) direction(%d) state(%d) name(%s) "
+ "vendor-id(%04x) product-id(%04x) changed_info_type(%d)",
+ device_id, device_type, io_direction, state, name, vendor_id, product_id, changed_device_info_type);
if (cb_data == NULL) {
debug_warning("device info changed callback data null");
if (!device_is_match_with_mask(device_type, io_direction, state, device_flags))
return;
- if (_fill_sound_device(&device_h, device_id, device_type, io_direction, state, name, stream_id, stream_num) < 0) {
+ if (_fill_sound_device(&device_h, device_id, device_type, io_direction, state, name,
+ vendor_id, product_id, stream_id, stream_num) < 0) {
debug_error("Failed to fill sound device");
return;
}
}
static void _mm_sound_device_state_changed_callback_wrapper_func(int device_id, const char *device_type,
- int io_direction, int state, const char *name,
- int *stream_id, int stream_num, void *userdata)
+ int io_direction, int state, const char *name, int vendor_id, int product_id,
+ int *stream_id, int stream_num, void *userdata)
{
mm_sound_device_t device_h;
struct callback_data *cb_data = (struct callback_data*) userdata;
int device_flags;
- debug_log("[Device State Changed] id(%d) type(%s) direction(%d) state(%d) name(%s)",
- device_id, device_type, io_direction, state, name);
+ debug_log("[Device State Changed] id(%d) type(%s) direction(%d) state(%d) name(%s)"
+ "vendor-id(%04x), product-id(%04x)",
+ device_id, device_type, io_direction, state, name, vendor_id, product_id);
if (cb_data == NULL) {
debug_warning("device state changed callback data null");
if (!device_is_match_with_mask(device_type, io_direction, state, device_flags))
return;
- if (_fill_sound_device(&device_h, device_id, device_type, io_direction, state, name, stream_id, stream_num) < 0) {
+ if (_fill_sound_device(&device_h, device_id, device_type, io_direction, state, name,
+ vendor_id, product_id, stream_id, stream_num) < 0) {
debug_error("Failed to fill sound device");
return;
}
}
EXPORT_API
+int mm_sound_get_device_vendor_id(MMSoundDevice_t device_h, int *vendor_id)
+{
+ mm_sound_device_t *device = (mm_sound_device_t*)device_h;
+ if(!device) {
+ debug_error("invalid handle\n");
+ return MM_ERROR_INVALID_ARGUMENT;
+ }
+ *vendor_id = device->vendor_id;
+ debug_log("device_handle:0x%x, vendor id:%04x\n", device, *vendor_id);
+
+ return MM_ERROR_NONE;
+}
+
+EXPORT_API
+int mm_sound_get_device_product_id(MMSoundDevice_t device_h, int *product_id)
+{
+ mm_sound_device_t *device = (mm_sound_device_t*)device_h;
+ if(!device) {
+ debug_error("invalid handle\n");
+ return MM_ERROR_INVALID_ARGUMENT;
+ }
+ *product_id = device->product_id;
+ debug_log("device_handle:0x%x, product id:%04x\n", device, *product_id);
+
+ return MM_ERROR_NONE;
+}
+
+EXPORT_API
int mm_sound_is_stream_on_device(int stream_id, MMSoundDevice_t device_h, bool *is_on)
{
int ret = MM_ERROR_NONE;
}
static int parse_device_variant(GVariant *v, int *device_id, const char **device_type, int *direction, int *state,
- const char **device_name, int *stream_id, int *stream_num)
+ const char **device_name, int *vendor_id, int *product_id, int *stream_id, int *stream_num)
{
const char *v_type;
GVariant *array_v;
}
v_type = g_variant_get_type_string(v);
- if (g_variant_type_equal(v_type, "(isiisai)") == FALSE) {
+ if (g_variant_type_equal(v_type, "(isiisiiai)") == FALSE) {
debug_error("device variant type not matching '%s'", v_type);
return MM_ERROR_NONE;
}
g_variant_iter_next(&iter, "i", direction);
g_variant_iter_next(&iter, "i", state);
g_variant_iter_next(&iter, "&s", device_name);
+ g_variant_iter_next(&iter, "i", vendor_id);
+ g_variant_iter_next(&iter, "i", product_id);
array_v = g_variant_iter_next_value(&iter);
*stream_num = g_variant_iter_init(&array_iter, array_v);
GVariant *device_v;
int stream_id[MAX_STREAM_ON_DEVICE];
int stream_num;
+ int vendor_id, product_id;
v_type = g_variant_get_type_string(params);
} else if (event == AUDIO_EVENT_DEVICE_CONNECTED) {
gboolean is_connected = FALSE;
- if (g_variant_type_equal(v_type, "(u(isiisai)b)") == FALSE) {
+ if (g_variant_type_equal(v_type, "(u(isiisiiai)b)") == FALSE) {
debug_error("Device connection changed signature not matching : %s", v_type);
return ;
}
g_variant_iter_next(&iter, "u", &event_id);
device_v = g_variant_iter_next_value(&iter);
if (parse_device_variant(device_v, &device_id, &device_type, &direction, &state,
- &name, stream_id, &stream_num) < 0) {
+ &name, &vendor_id, &product_id, stream_id, &stream_num) < 0) {
debug_error("Failed to parse device variant");
return ;
}
g_variant_iter_next(&iter, "b", &is_connected);
((mm_sound_device_connected_wrapper_cb)(cb_data->user_cb))(device_id, device_type, direction,
- state, name, stream_id, stream_num, is_connected, cb_data->user_data);
+ state, name, vendor_id, product_id, stream_id, stream_num, is_connected, cb_data->user_data);
_notify_signal_handled(event, event_id, cb_data->subs_id, g_variant_new("(ib)", device_id, is_connected));
} else if (event == AUDIO_EVENT_DEVICE_INFO_CHANGED) {
int changed_device_info_type = 0;
- if (g_variant_type_equal(v_type, "(u(isiisai)i)") == FALSE) {
+ if (g_variant_type_equal(v_type, "(u(isiisiiai)i)") == FALSE) {
debug_error("Device information changed signature not matching : %s", v_type);
return ;
}
g_variant_iter_next(&iter, "u", &event_id);
device_v = g_variant_iter_next_value(&iter);
if (parse_device_variant(device_v, &device_id, &device_type, &direction, &state,
- &name, stream_id, &stream_num) < 0) {
+ &name, &vendor_id, &product_id, stream_id, &stream_num) < 0) {
debug_error("Failed to parse device variant");
return ;
}
g_variant_iter_next(&iter, "i", &changed_device_info_type);
((mm_sound_device_info_changed_wrapper_cb)(cb_data->user_cb))(device_id, device_type, direction,
- state, name, stream_id, stream_num, changed_device_info_type, cb_data->user_data);
+ state, name, vendor_id, product_id, stream_id, stream_num, changed_device_info_type, cb_data->user_data);
} else if (event == AUDIO_EVENT_DEVICE_STATE_CHANGED) {
- if (g_variant_type_equal(v_type, "(u(isiisai))") == FALSE) {
+ if (g_variant_type_equal(v_type, "(u(isiisiiai))") == FALSE) {
debug_error("Device state changed signature not matching : %s", v_type);
return ;
}
g_variant_iter_next(&iter, "u", &event_id);
device_v = g_variant_iter_next_value(&iter);
if (parse_device_variant(device_v, &device_id, &device_type, &direction, &state,
- &name, stream_id, &stream_num) < 0) {
+ &name, &vendor_id, &product_id, stream_id, &stream_num) < 0) {
debug_error("Failed to parse device variant");
return ;
}
((mm_sound_device_state_changed_wrapper_cb)(cb_data->user_cb))(device_id, device_type, direction,
- state, name, stream_id, stream_num, cb_data->user_data);
+ state, name, vendor_id, product_id, stream_id, stream_num, cb_data->user_data);
} else if (event == AUDIO_EVENT_FOCUS_CHANGED) {
} else if (event == AUDIO_EVENT_FOCUS_WATCH) {
} else if (event == AUDIO_EVENT_TEST) {
g_variant_iter_init(&iter, child);
while (1) {
device_item = g_malloc0(sizeof(mm_sound_device_t));
- if (device_item && g_variant_iter_loop(&iter, "(i&sii&s)",
+ if (device_item && g_variant_iter_loop(&iter, "(i&sii&sii)",
&device_item->id, &device_type_tmp, &device_item->io_direction, &device_item->state,
- &device_name_tmp)) {
+ &device_name_tmp, &device_item->vendor_id, &device_item->product_id)) {
MMSOUND_STRNCPY(device_item->name, device_name_tmp, MAX_DEVICE_NAME_NUM);
MMSOUND_STRNCPY(device_item->type, device_type_tmp, MAX_DEVICE_TYPE_STR_LEN);
*device_list = g_list_append(*device_list, device_item);
- debug_log("Added device id(%d) type(%17s) direction(%d) state(%d) name(%s)",
+ debug_log("Added device id(%d) type(%17s) direction(%d) state(%d) name(%s) vendor-id(%04x), product-id(%04x)",
device_item->id, device_item->type,device_item->io_direction, device_item->state,
- device_item->name);
+ device_item->name, device_item->vendor_id, device_item->product_id);
device_item->stream_num = -1;
} else {
if (device_item)
goto cleanup;
}
- g_variant_get(result, "(i&sii&s)",
+ g_variant_get(result, "(i&sii&sii)",
&device_item->id, &device_type_tmp, &device_item->io_direction,
- &device_item->state, &device_name_tmp);
+ &device_item->state, &device_name_tmp,
+ &device_item->vendor_id, &device_item->product_id);
MMSOUND_STRNCPY(device_item->name, device_name_tmp, MAX_DEVICE_NAME_NUM);
MMSOUND_STRNCPY(device_item->type, device_type_tmp, MAX_DEVICE_TYPE_STR_LEN);
- debug_log("Get device id(%d) type(%17s) direction(%d) state(%d) name(%s)",
+ debug_log("Get device id(%d) type(%17s) direction(%d) state(%d) name(%s) vendor-id(%04x) product-id(%04x)",
device_item->id, device_item->type, device_item->io_direction,
- device_item->state, device_item->name);
+ device_item->state, device_item->name,
+ device_item->vendor_id, device_item->product_id);
device_item->stream_num = -1;
*device = device_item;
} else {
Name: libmm-sound
Summary: MMSound Package contains client lib and sound_server binary
-Version: 0.11.5
+Version: 0.11.6
Release: 0
Group: System/Libraries
License: Apache-2.0
#endif
GMainLoop* g_loop;
-unsigned int g_subs_id_test, g_subs_id_volume, g_subs_id_device_conn, g_subs_id_device_info;
+unsigned int g_subs_id_test, g_subs_id_volume, g_subs_id_device_conn, g_subs_id_device_state;
// Function
static void interpret (char *buf);
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]\n", device_h, is_connected, user_data);
ret = mm_sound_get_device_type(device_h, &device_type);
- if (ret) {
+ if (ret)
debug_error("failed to mm_sound_get_device_type()\n");
- }
ret = mm_sound_get_device_io_direction(device_h, &io_direction);
- if (ret) {
+ if (ret)
debug_error("failed to mm_sound_get_device_io_direction()\n");
- }
ret = mm_sound_get_device_state(device_h, &state);
- if (ret) {
+ if (ret)
debug_error("failed to mm_sound_get_device_state()\n");
- }
ret = mm_sound_get_device_id(device_h, &id);
- if (ret) {
+ if (ret)
debug_error("failed to mm_sound_get_device_id()\n");
- }
ret = mm_sound_get_device_name(device_h, &name);
- if (ret) {
+ 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);
+ ret = mm_sound_get_device_vendor_id(device_h, &vendor_id);
+ if (ret)
+ debug_error("failed to mm_sound_get_device_vendor_id()\n");
+ ret = mm_sound_get_device_product_id(device_h, &product_id);
+ if (ret)
+ debug_error("failed to mm_sound_get_device_produt_id()\n");
+ debug_log("*** --- type[%d], id[%d], io_direction[%d], state[%d], name[%s], "
+ "vendor-id(%04x) product-id(%04x)\n",
+ 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]\n", device_h, new_state, user_data);
ret = mm_sound_get_device_type(device_h, &device_type);
- if (ret) {
+ if (ret)
debug_error("failed to mm_sound_get_device_type()\n");
- }
ret = mm_sound_get_device_io_direction(device_h, &io_direction);
- if (ret) {
+ if (ret)
debug_error("failed to mm_sound_get_device_io_direction()\n");
- }
ret = mm_sound_get_device_state(device_h, &state);
- if (ret) {
+ if (ret)
debug_error("failed to mm_sound_get_device_state()\n");
- }
ret = mm_sound_get_device_id(device_h, &id);
- if (ret) {
+ if (ret)
debug_error("failed to mm_sound_get_device_id()\n");
- }
ret = mm_sound_get_device_name(device_h, &name);
- if (ret) {
+ 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);
+ ret = mm_sound_get_device_vendor_id(device_h, &vendor_id);
+ if (ret)
+ debug_error("failed to mm_sound_get_device_vendor_id()\n");
+ ret = mm_sound_get_device_product_id(device_h, &product_id);
+ if (ret)
+ debug_error("failed to mm_sound_get_device_produt_id()\n");
+ debug_log("*** --- type[%d], id[%d], io_direction[%d], state[%d], name[%s], "
+ "vendor-id(%04x) product-id(%04x)\n",
+ device_type, id, io_direction, state, name, vendor_id, product_id);
}
#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, int option, const char *ext_info, void *user_data)
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");
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) {
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);
+ ret = mm_sound_get_device_vendor_id(device_h, &vendor_id);
+ if (ret)
+ debug_error("failed to mm_sound_get_device_vendor_id()\n");
+ ret = mm_sound_get_device_product_id(device_h, &product_id);
+ if (ret)
+ debug_error("failed to mm_sound_get_device_product_id()\n");
+ debug_log("*** --- [NEXT DEVICE] type[%d], id[%d], io_direction[%d], state[%d], "
+ "name[%s] vendor_id[%04x] product_id[%04x]\n",
+ device_type, id, io_direction, state, name, vendor_id, product_id);
}
} while (dret == MM_ERROR_NONE);
do {
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);
+ ret = mm_sound_get_device_vendor_id(device_h, &vendor_id);
+ if (ret)
+ debug_error("failed to mm_sound_get_device_vendor_id()\n");
+ ret = mm_sound_get_device_product_id(device_h, &product_id);
+ if (ret)
+ debug_error("failed to mm_sound_get_device_product_id()\n");
+ debug_log("*** --- [PREV DEVICE] type[%d], id[%d], io_direction[%d], state[%d], "
+ "name[%s] vendor_id[%04x] product_id[%04x]\n",
+ device_type, id, io_direction, state, name, vendor_id, product_id);
}
} while (dret == MM_ERROR_NONE);
}
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);
+ 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_information_changed_callback(), ret[0x%x]\n", 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_info_changed_cb, g_subs_id_device_info);
+ 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 ("### fgets return NULL\n");
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) {