}
static int parse_device_variant(GVariant *v, int *device_id, const char **device_type, int *direction, int *state,
- const char **device_name, int *vendor_id, int *product_id, int *stream_id, int *stream_num)
+ const char **device_name, int *vendor_id, int *product_id, bool *is_running, 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, "(isiisiiai)") == FALSE) {
+ if (g_variant_type_equal(v_type, "(isiisiibai)") == FALSE) {
debug_error("device variant type not matching '%s'", v_type);
return MM_ERROR_NONE;
}
g_variant_iter_next(&iter, "&s", device_name);
g_variant_iter_next(&iter, "i", vendor_id);
g_variant_iter_next(&iter, "i", product_id);
+ g_variant_iter_next(&iter, "b", is_running);
array_v = g_variant_iter_next_value(&iter);
*stream_num = g_variant_iter_init(&array_iter, array_v);
int stream_id[MAX_STREAM_ON_DEVICE];
int stream_num;
int vendor_id, product_id;
+ bool is_running = FALSE;
v_type = g_variant_get_type_string(params);
g_variant_get(params, "(&s&su)", &direction, &volume_type_str, &volume_level);
((mm_sound_volume_changed_wrapper_cb)(cb_data->user_cb))(direction, volume_type_str, volume_level, cb_data->user_data);
} else if (event == AUDIO_EVENT_DEVICE_CONNECTED) {
- gboolean is_connected = FALSE;
+ bool is_connected = false;
- if (g_variant_type_equal(v_type, "(u(isiisiiai)b)") == FALSE) {
+ if (g_variant_type_equal(v_type, "(u(isiisiibai)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, &vendor_id, &product_id, stream_id, &stream_num) < 0) {
+ &name, &vendor_id, &product_id, &is_running, 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, vendor_id, product_id, stream_id, stream_num, is_connected, cb_data->user_data);
+ state, name, vendor_id, product_id, is_running, 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(isiisiiai)i)") == FALSE) {
+ if (g_variant_type_equal(v_type, "(u(isiisiibai)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, &vendor_id, &product_id, stream_id, &stream_num) < 0) {
+ &name, &vendor_id, &product_id, &is_running, 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, vendor_id, product_id, stream_id, stream_num, changed_device_info_type, cb_data->user_data);
+ state, name, vendor_id, product_id, is_running, 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(isiisiiai))") == FALSE) {
+ if (g_variant_type_equal(v_type, "(u(isiisiibai))") == 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, &vendor_id, &product_id, stream_id, &stream_num) < 0) {
+ &name, &vendor_id, &product_id, &is_running, 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, vendor_id, product_id, stream_id, stream_num, cb_data->user_data);
+ state, name, vendor_id, product_id, is_running, stream_id, stream_num, cb_data->user_data);
+ } else if (event == AUDIO_EVENT_DEVICE_RUNNING_CHANGED) {
+
+ if (g_variant_type_equal(v_type, "(u(isiisiibai))") == FALSE) {
+ debug_error("Device state changed signature not matching : %s", v_type);
+ return ;
+ }
+
+ g_variant_iter_init(&iter, params);
+ 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, &vendor_id, &product_id, &is_running, stream_id, &stream_num) < 0) {
+ debug_error("Failed to parse device variant");
+ return ;
+ }
+
+ ((mm_sound_device_running_changed_wrapper_cb)(cb_data->user_cb))(device_id, device_type, direction,
+ state, name, vendor_id, product_id, is_running, 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&sii)",
+ if (device_item && g_variant_iter_loop(&iter, "(i&sii&siib)",
&device_item->id, &device_type_tmp, &device_item->io_direction, &device_item->state,
- &device_name_tmp, &device_item->vendor_id, &device_item->product_id)) {
+ &device_name_tmp, &device_item->vendor_id, &device_item->product_id, &device_item->is_running)) {
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) vendor-id(%04x) product-id(%04x)",
+ debug_log("Added device id(%d) type(%17s) direction(%d) state(%d) name(%s) vendor-id(%04x) product-id(%04x) is_running(%d)",
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->name, device_item->vendor_id, device_item->product_id, device_item->is_running);
device_item->stream_num = -1;
} else {
if (device_item)
return ret;
}
+int mm_sound_proxy_add_device_running_changed_callback(int device_flags, mm_sound_device_running_changed_wrapper_cb func, void* userdata, mm_sound_proxy_userdata_free freefunc, unsigned *subs_id)
+{
+ int ret = MM_ERROR_NONE;
+ struct callback_data *cb_data;
+
+ debug_fenter();
+
+ CB_DATA_NEW(cb_data, func, userdata, freefunc);
+
+ if ((ret = mm_sound_dbus_signal_subscribe_to(AUDIO_PROVIDER_DEVICE_MANAGER, AUDIO_EVENT_DEVICE_RUNNING_CHANGED, dbus_callback, cb_data, simple_callback_data_free_func, &cb_data->subs_id)) != MM_ERROR_NONE)
+ debug_error("Add device running changed callback failed");
+ else
+ *subs_id = cb_data->subs_id;
+
+ debug_fleave();
+ return ret;
+}
+
+int mm_sound_proxy_remove_device_running_changed_callback(unsigned subs_id)
+{
+ int ret = MM_ERROR_NONE;
+ debug_fenter();
+
+ if ((ret = mm_sound_dbus_signal_unsubscribe(subs_id)) != MM_ERROR_NONE)
+ debug_error("remove device running changed callback failed");
+
+ debug_fleave();
+ return ret;
+}
+
int mm_sound_proxy_set_volume_by_type(const char *volume_type, const unsigned volume_level)
{
int ret = MM_ERROR_NONE;