}
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)
return ret;
}
+int mm_sound_proxy_get_device_by_id(int device_id, mm_sound_device_t **device)
+{
+ int ret = MM_ERROR_NONE;
+ GVariant *params = NULL, *result = NULL;
+ mm_sound_device_t* device_item = NULL;
+ const gchar *device_name_tmp = NULL, *device_type_tmp = NULL;
+
+ debug_fenter();
+
+ if (!device || device_id < 1) {
+ debug_error("Invalid Parameter, device null or improper device id");
+ return MM_ERROR_INVALID_ARGUMENT;
+ }
+
+ if ((params = g_variant_new("(i)", device_id)) == NULL) {
+ debug_error("Construct Param for get device by id failed");
+ return MM_ERROR_SOUND_INTERNAL;
+ }
+
+ if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_DEVICE_MANAGER, AUDIO_METHOD_GET_DEVICE_BY_ID, params, &result)) != MM_ERROR_NONE) {
+ debug_error("get device by id failed");
+ ret = MM_ERROR_SOUND_NO_DATA;
+ goto cleanup;
+ }
+
+ if (result) {
+ if ((device_item = g_malloc0(sizeof(mm_sound_device_t))) == NULL) {
+ debug_error("Alloc device handle failed");
+ ret = MM_ERROR_SOUND_INTERNAL;
+ goto cleanup;
+ }
+
+ 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->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) vendor-id(%04x) product-id(%04x)",
+ device_item->id, device_item->type, device_item->io_direction,
+ device_item->state, device_item->name,
+ device_item->vendor_id, device_item->product_id);
+ device_item->stream_num = -1;
+ *device = device_item;
+ } else {
+ debug_error("reply null");
+ ret = MM_ERROR_SOUND_INTERNAL;
+ }
+
+cleanup:
+ if (result)
+ g_variant_unref(result);
+
+ debug_fleave();
+ return ret;
+}
+
int mm_sound_proxy_add_device_connected_callback(int device_flags, mm_sound_device_connected_wrapper_cb func, void *userdata, mm_sound_proxy_userdata_free freefunc, unsigned *subs_id)
{
int ret = MM_ERROR_NONE;
if (params) {
if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_STREAM_MANAGER, AUDIO_METHOD_UPDATE_STREAM_FOCUS_STATUS, params, &result)) != MM_ERROR_NONE) {
debug_error("dbus set volume by type failed");
- goto cleanup;
+ if (result) {
+ g_variant_get(result, "(&s)", &reply);
+ debug_log("reply : %s", reply);
+ if (!strcmp(reply, "STREAM_MANAGER_RETURN_ERROR"))
+ ret = MM_ERROR_SOUND_INTERNAL;
+ }
}
} else {
debug_error("Construct Param for method call failed");
return MM_ERROR_SOUND_INTERNAL;
}
- if (result) {
- g_variant_get(result, "(&s)", &reply);
- debug_log("reply : %s", reply);
- if (!strcmp(reply, "STREAM_MANAGER_RETURN_ERROR"))
- ret = MM_ERROR_SOUND_INTERNAL;
+ if (result)
+ g_variant_unref(result);
+
+ debug_fleave();
+ return ret;
+}
+
+int mm_sound_proxy_deliver_focus(int pid, int src_id, int dst_id, mm_sound_focus_type_e focus_type)
+{
+ int ret = MM_ERROR_NONE;
+ char *reply = NULL;
+ GVariant *params = NULL, *result = NULL;
+
+ debug_fenter();
+
+ params = g_variant_new("(iiii)", pid, src_id, dst_id, focus_type);
+ if (params) {
+ if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_FOCUS_SERVER, AUDIO_METHOD_DELIVER_FOCUS, params, &result)) != MM_ERROR_NONE) {
+ debug_error("dbus deliver focus failed");
+ if (result) {
+ g_variant_get(result, "(&s)", &reply);
+ debug_log("reply : %s", reply);
+ if (!strcmp(reply, "STREAM_MANAGER_RETURN_ERROR"))
+ ret = MM_ERROR_SOUND_INTERNAL;
+ }
+ }
} else {
- debug_error("reply null");
+ debug_error("Construct Param for method call failed");
+ return MM_ERROR_SOUND_INTERNAL;
}
-cleanup:
if (result)
g_variant_unref(result);