return ret;
}
+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 *v_type;
+ GVariant *array_v;
+ GVariantIter iter, array_iter;
+ int i = 0;
+ int ret = MM_ERROR_NONE;
+
+ if (v == NULL) {
+ debug_error("Variant NULL");
+ return MM_ERROR_NONE;
+ }
+
+ v_type = g_variant_get_type_string(v);
+ if (g_variant_type_equal(v_type, "(isiisai)") == FALSE) {
+ debug_error("device variant type not matching '%s'", v_type);
+ return MM_ERROR_NONE;
+ }
+
+ g_variant_iter_init(&iter, v);
+ g_variant_iter_next(&iter, "i", device_id);
+ g_variant_iter_next(&iter, "&s", device_type);
+ g_variant_iter_next(&iter, "i", direction);
+ g_variant_iter_next(&iter, "i", state);
+ g_variant_iter_next(&iter, "&s", device_name);
+
+ array_v = g_variant_iter_next_value(&iter);
+ *stream_num = g_variant_iter_init(&array_iter, array_v);
+ if (*stream_num > MAX_STREAM_ON_DEVICE) {
+ debug_error("too many streams on device %d", *stream_num);
+ ret = MM_ERROR_SOUND_INTERNAL;
+ goto finish;
+ }
+
+ while (g_variant_iter_loop(&array_iter, "i", &stream_id[i++])) ;
+finish:
+ g_variant_unref(array_v);
+
+ return ret;
+}
+
/* This callback unmarshall general-formed paramters to subject specific parameters,
* and call proper callback */
static void dbus_callback(audio_event_t event, GVariant *params, void *userdata)
{
struct callback_data *cb_data = (struct callback_data*) userdata;
uint32_t event_id;
+ const char *name = NULL, *device_type = NULL;
+ int device_id, direction, state;
+ const gchar *v_type;
+ GVariantIter iter;
+ GVariant *device_v;
+ int stream_id[MAX_STREAM_ON_DEVICE];
+ int stream_num;
+
+ v_type = g_variant_get_type_string(params);
if (event == AUDIO_EVENT_VOLUME_CHANGED) {
char *volume_type_str = NULL, *direction = NULL;
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) {
- const char *name = NULL, *device_type = NULL;
gboolean is_connected = FALSE;
- int device_id, io_direction, state;
- g_variant_get(params, "(u(i&sii&s)b)", &event_id, &device_id, &device_type, &io_direction,
- &state, &name, &is_connected);
- ((mm_sound_device_connected_wrapper_cb)(cb_data->user_cb))(device_id, device_type, io_direction,
- state, name, is_connected, cb_data->user_data);
+ if (g_variant_type_equal(v_type, "(u(isiisai)b)") == FALSE) {
+ debug_error("Device connection 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, 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);
_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) {
- const char *name = NULL, *device_type = NULL;
int changed_device_info_type = 0;
- int device_id, io_direction, state;
- g_variant_get(params, "(u(i&sii&s)i)", &event_id, &device_id, &device_type, &io_direction,
- &state, &name, &changed_device_info_type);
- ((mm_sound_device_info_changed_wrapper_cb)(cb_data->user_cb))(device_id, device_type, io_direction,
- state, name, changed_device_info_type, cb_data->user_data);
+ if (g_variant_type_equal(v_type, "(u(isiisai)i)") == FALSE) {
+ debug_error("Device information 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, 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);
} else if (event == AUDIO_EVENT_DEVICE_STATE_CHANGED) {
- const char *name = NULL, *device_type = NULL;
- int device_id, io_direction, state;
- g_variant_get(params, "(u(i&sii&s))", &event_id, &device_id, &device_type, &io_direction,
- &state, &name);
- ((mm_sound_device_state_changed_wrapper_cb)(cb_data->user_cb))(device_id, device_type, io_direction,
- state, name, cb_data->user_data);
+ if (g_variant_type_equal(v_type, "(u(isiisai))") == 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, 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);
} else if (event == AUDIO_EVENT_FOCUS_CHANGED) {
} else if (event == AUDIO_EVENT_FOCUS_WATCH) {
} else if (event == AUDIO_EVENT_TEST) {
return ret;
}
+int mm_sound_proxy_is_stream_on_device(int stream_id, int device_id, bool *is_on)
+{
+ int ret = MM_ERROR_NONE;
+ GVariant *params, *result;
+ gboolean _is_on;
+
+ debug_fenter();
+
+ if (!is_on) {
+ debug_error("Invalid Parameter, is_on null");
+ return MM_ERROR_INVALID_ARGUMENT;
+ }
+
+ if ((params = g_variant_new("(ii)", stream_id, device_id)) == NULL) {
+ debug_error("Construct Param for query is stream on device failed");
+ return MM_ERROR_SOUND_INTERNAL;
+ }
+
+ if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_DEVICE_MANAGER, AUDIO_METHOD_IS_STREAM_ON_DEVICE, params, &result)) != MM_ERROR_NONE) {
+ debug_error("is stream on device failed");
+ goto cleanup;
+ }
+
+ if (result) {
+ g_variant_get(result, "(b)", &_is_on);
+ debug_log("is_on : %d", _is_on);
+ *is_on = (bool)_is_on;
+ } else {
+ debug_error("reply null");
+ ret = MM_ERROR_SOUND_INTERNAL;
+ }
+
+cleanup:
+ if (params)
+ g_variant_unref(params);
+ if (result)
+ g_variant_unref(result);
+
+ debug_fleave();
+ return ret;
+}
+
int mm_sound_proxy_get_current_connected_device_list(int device_flags, GList** device_list)
{
int ret = MM_ERROR_NONE;
debug_log("Added device id(%d) type(%17s) direction(%d) state(%d) name(%s)",
device_item->id, device_item->type,device_item->io_direction, device_item->state,
device_item->name);
+ device_item->stream_num = -1;
} else {
if (device_item)
g_free(device_item);
debug_fenter();
- params = g_variant_new("(iiiiiiibsi)", tone, repeat, volume,
- volume_config, session_type, session_options, client_pid , _enable_session, stream_type, stream_index);
+ params = g_variant_new("(iiiiiiibsi)", tone, repeat, volume, volume_config, session_type,
+ session_options, client_pid , _enable_session, stream_type, stream_index);
if (params) {
if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_SOUND_SERVER, AUDIO_METHOD_PLAY_DTMF, params, &result)) != MM_ERROR_NONE) {
debug_error("dbus play tone failed");
}
int mm_sound_proxy_play_sound(const char* filename, int tone, int repeat, int volume, int volume_config,
- int priority, int session_type, int session_options, int client_pid, int handle_route,
- bool enable_session, int *codechandle, char *stream_type, int stream_index)
+ int session_type, int session_options, int client_pid, bool enable_session, int *codechandle,
+ char *stream_type, int stream_index)
{
int ret = MM_ERROR_NONE;
int handle = 0;
debug_fenter();
- params = g_variant_new("(siiiiiiiiibsi)", filename, tone, repeat, volume,
- volume_config, priority, session_type, session_options, client_pid, handle_route, _enable_session, stream_type, stream_index);
+ params = g_variant_new("(siiiiiiibsi)", filename, tone, repeat, volume,
+ volume_config, session_type, session_options, client_pid, _enable_session, stream_type, stream_index);
if (params) {
if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_SOUND_SERVER, AUDIO_METHOD_PLAY_FILE_START, params, &result)) != MM_ERROR_NONE) {
debug_error("dbus play file failed");
}
int mm_sound_proxy_play_sound_with_stream_info(const char* filename, int repeat, int volume,
- int priority, int client_pid, int handle_route, int *codechandle, char *stream_type, int stream_index)
+ int client_pid, int *codechandle, char *stream_type, int stream_index)
{
int ret = MM_ERROR_NONE;
int handle = 0;
debug_fenter();
- params = g_variant_new("(siiiiisi)", filename, repeat, volume,
- priority, client_pid, handle_route, stream_type, stream_index);
+ params = g_variant_new("(siiisi)", filename, repeat, volume, client_pid, stream_type, stream_index);
if (params) {
if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_SOUND_SERVER, AUDIO_METHOD_PLAY_FILE_START_WITH_STREAM_INFO, params, &result)) != MM_ERROR_NONE) {
debug_error("dbus play file failed");