7 #include "include/mm_sound_proxy.h"
8 #include "include/mm_sound_common.h"
9 #include "include/mm_sound_dbus.h"
10 #include "include/mm_sound_intf.h"
12 struct callback_data {
15 mm_sound_proxy_userdata_free free_func;
19 #define CB_DATA_NEW(_cb_data, _func, _userdata, _freefunc) \
21 _cb_data = (struct callback_data*) g_malloc0(sizeof(struct callback_data)); \
22 _cb_data->user_cb = _func; \
23 _cb_data->user_data = _userdata; \
24 _cb_data->free_func = _freefunc; \
25 _cb_data->subs_id = 0; \
28 /* subscribe is true when add callback,
29 * false when remove callback */
30 static int _notify_subscription(audio_event_t event, uint32_t subs_id, gboolean subscribe)
32 int ret = MM_ERROR_NONE;
33 GVariant *params = NULL;
34 const char *event_name = NULL;
38 if ((ret = mm_sound_dbus_get_event_name(event, &event_name) != MM_ERROR_NONE)) {
39 debug_error("Failed to get event name");
40 return MM_ERROR_SOUND_INTERNAL;
43 if (!(params = g_variant_new("(sub)", event_name, subs_id, subscribe))) {
44 debug_error("Construct Param failed");
45 return MM_ERROR_SOUND_INTERNAL;
48 if ((ret = mm_sound_dbus_emit_signal(AUDIO_PROVIDER_AUDIO_CLIENT, AUDIO_EVENT_CLIENT_SUBSCRIBED, params))) {
49 debug_error("dbus send signal for client subscribed failed");
56 static int _notify_signal_handled(audio_event_t event, uint32_t event_id, uint32_t subs_id, GVariant *signal_params)
58 int ret = MM_ERROR_NONE;
59 GVariant *params = NULL;
60 const char *event_name = NULL;
64 if ((ret = mm_sound_dbus_get_event_name(event, &event_name) != MM_ERROR_NONE)) {
65 debug_error("Failed to get event name");
66 return MM_ERROR_SOUND_INTERNAL;
69 if (!(params = g_variant_new("(usuv)", event_id, event_name, subs_id, signal_params))) {
70 debug_error("Construct Param failed");
71 return MM_ERROR_SOUND_INTERNAL;
74 if ((ret = mm_sound_dbus_emit_signal(AUDIO_PROVIDER_AUDIO_CLIENT, AUDIO_EVENT_CLIENT_HANDLED, params))) {
75 debug_error("dbus send signal for client handled failed");
82 /* This callback unmarshall general-formed paramters to subject specific parameters,
83 * and call proper callback */
84 static void dbus_callback(audio_event_t event, GVariant *params, void *userdata)
86 struct callback_data *cb_data = (struct callback_data*) userdata;
89 if (event == AUDIO_EVENT_VOLUME_CHANGED) {
90 char *volume_type_str = NULL, *direction = NULL;
91 unsigned volume_level;
93 g_variant_get(params, "(&s&su)", &direction, &volume_type_str, &volume_level);
94 ((mm_sound_volume_changed_wrapper_cb)(cb_data->user_cb))(direction, volume_type_str, volume_level, cb_data->user_data);
95 } else if (event == AUDIO_EVENT_DEVICE_CONNECTED) {
96 const char *name = NULL, *device_type = NULL;
97 gboolean is_connected = FALSE;
98 int device_id, io_direction, state;
100 g_variant_get(params, "(u(i&sii&s)b)", &event_id, &device_id, &device_type, &io_direction,
101 &state, &name, &is_connected);
102 ((mm_sound_device_connected_wrapper_cb)(cb_data->user_cb))(device_id, device_type, io_direction, state, name, is_connected, cb_data->user_data);
103 _notify_signal_handled(event, event_id, cb_data->subs_id, g_variant_new("(ib)", device_id, is_connected));
104 } else if (event == AUDIO_EVENT_DEVICE_INFO_CHANGED) {
105 const char *name = NULL, *device_type = NULL;
106 int changed_device_info_type = 0;
107 int device_id, io_direction, state;
109 g_variant_get(params, "(u(i&sii&s)i)", &event_id, &device_id, &device_type, &io_direction,
110 &state, &name, &changed_device_info_type);
111 ((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);
112 } else if (event == AUDIO_EVENT_FOCUS_CHANGED) {
113 } else if (event == AUDIO_EVENT_FOCUS_WATCH) {
114 } else if (event == AUDIO_EVENT_TEST) {
116 g_variant_get(params, "(i)", &test_var);
117 ((mm_sound_test_cb)(cb_data->user_cb))(test_var, cb_data->user_data);
118 } else if (event == AUDIO_EVENT_PLAY_FILE_END) {
119 int ended_handle = 0;
120 g_variant_get(params, "(i)", &ended_handle);
121 ((mm_sound_stop_callback_wrapper_func)(cb_data->user_cb))(ended_handle, cb_data->user_data);
125 static void simple_callback_data_free_func(void *data)
127 struct callback_data *cb_data = (struct callback_data*) data;
130 if (cb_data->free_func)
131 cb_data->free_func(cb_data->user_data);
136 int mm_sound_proxy_add_test_callback(mm_sound_test_cb func, void *userdata, mm_sound_proxy_userdata_free freefunc, unsigned *subs_id)
138 int ret = MM_ERROR_NONE;
139 struct callback_data *cb_data;
143 CB_DATA_NEW(cb_data, func, userdata, freefunc);
145 if ((ret = mm_sound_dbus_signal_subscribe_to(AUDIO_PROVIDER_SOUND_SERVER, AUDIO_EVENT_TEST, dbus_callback, cb_data, simple_callback_data_free_func, &cb_data->subs_id)) != MM_ERROR_NONE)
146 debug_error("add test callback failed");
148 *subs_id = cb_data->subs_id;
154 int mm_sound_proxy_remove_test_callback(unsigned subs_id)
156 int ret = MM_ERROR_NONE;
159 if ((ret = mm_sound_dbus_signal_unsubscribe(subs_id)) != MM_ERROR_NONE) {
160 debug_error("remove test callback failed");
167 int mm_sound_proxy_test(int a, int b, int *get)
169 int ret = MM_ERROR_NONE;
171 GVariant *params = NULL, *result = NULL;
175 params = g_variant_new("(ii)", a, b);
177 if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_SOUND_SERVER, AUDIO_METHOD_TEST, params, &result)) != MM_ERROR_NONE) {
178 debug_error("dbus test call failed");
182 debug_error("Construct Param for method call failed");
183 return MM_ERROR_SOUND_INTERNAL;
187 g_variant_get(result, "(i)", &reply);
188 debug_log("reply : %d", reply);
191 debug_error("reply null");
196 g_variant_unref(result);
202 int mm_sound_proxy_get_current_connected_device_list(int device_flags, GList** device_list)
204 int ret = MM_ERROR_NONE;
205 GVariant *result = NULL, *child = NULL;
206 GVariant *params = NULL;
208 mm_sound_device_t* device_item;
209 const gchar *device_name_tmp = NULL, *device_type_tmp = NULL;
214 debug_error("Invalid Parameter, device_list null");
215 ret = MM_ERROR_INVALID_ARGUMENT;
219 params = g_variant_new("(i)", device_flags);
222 if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_DEVICE_MANAGER, AUDIO_METHOD_GET_CONNECTED_DEVICE_LIST, params, &result)) != MM_ERROR_NONE) {
223 debug_error("Get current connected device list failed");
227 debug_error("Construct Param for get current connected device failed");
228 return MM_ERROR_SOUND_INTERNAL;
231 child = g_variant_get_child_value(result, 0);
232 g_variant_iter_init(&iter, child);
234 device_item = g_malloc0(sizeof(mm_sound_device_t));
235 if (device_item && g_variant_iter_loop(&iter, "(i&sii&s)", &device_item->id, &device_type_tmp, &device_item->io_direction, &device_item->state, &device_name_tmp)) {
236 MMSOUND_STRNCPY(device_item->name, device_name_tmp, MAX_DEVICE_NAME_NUM);
237 MMSOUND_STRNCPY(device_item->type, device_type_tmp, MAX_DEVICE_TYPE_STR_LEN);
238 *device_list = g_list_append(*device_list, device_item);
239 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);
249 g_variant_unref(result);
255 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)
257 int ret = MM_ERROR_NONE;
258 struct callback_data *cb_data;
262 CB_DATA_NEW(cb_data, func, userdata, freefunc);
264 if ((ret = mm_sound_dbus_signal_subscribe_to(AUDIO_PROVIDER_DEVICE_MANAGER, AUDIO_EVENT_DEVICE_CONNECTED, dbus_callback, cb_data, simple_callback_data_free_func, &cb_data->subs_id)) != MM_ERROR_NONE) {
265 debug_error("add device connected callback failed");
269 if ((ret = _notify_subscription(AUDIO_EVENT_DEVICE_CONNECTED, cb_data->subs_id, TRUE)) != MM_ERROR_NONE) {
270 debug_error("failed to notify subscription of device connected event");
274 *subs_id = cb_data->subs_id;
281 int mm_sound_proxy_remove_device_connected_callback(unsigned subs_id)
283 int ret = MM_ERROR_NONE;
286 if ((ret = mm_sound_dbus_signal_unsubscribe(subs_id)) != MM_ERROR_NONE) {
287 debug_error("remove device connected callback failed");
291 if ((ret = _notify_subscription(AUDIO_EVENT_DEVICE_CONNECTED, subs_id, FALSE)) != MM_ERROR_NONE)
292 debug_error("failed to notify unsubscription of device connected event");
299 int mm_sound_proxy_add_device_info_changed_callback(int device_flags, mm_sound_device_info_changed_wrapper_cb func, void* userdata, mm_sound_proxy_userdata_free freefunc, unsigned *subs_id)
301 int ret = MM_ERROR_NONE;
302 struct callback_data *cb_data;
306 CB_DATA_NEW(cb_data, func, userdata, freefunc);
308 if ((ret = mm_sound_dbus_signal_subscribe_to(AUDIO_PROVIDER_DEVICE_MANAGER, AUDIO_EVENT_DEVICE_INFO_CHANGED, dbus_callback, cb_data, simple_callback_data_free_func, &cb_data->subs_id)) != MM_ERROR_NONE)
309 debug_error("Add device info changed callback failed");
311 *subs_id = cb_data->subs_id;
317 int mm_sound_proxy_remove_device_info_changed_callback(unsigned subs_id)
319 int ret = MM_ERROR_NONE;
322 if ((ret = mm_sound_dbus_signal_unsubscribe(subs_id)) != MM_ERROR_NONE) {
323 debug_error("remove device info changed callback failed");
330 int mm_sound_proxy_set_volume_by_type(const char *volume_type, const unsigned volume_level)
332 int ret = MM_ERROR_NONE;
333 char *reply = NULL, *direction = "out";
334 GVariant *params = NULL, *result = NULL;
338 params = g_variant_new("(ssu)", direction, volume_type, volume_level);
340 if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_STREAM_MANAGER, AUDIO_METHOD_SET_VOLUME_LEVEL, params, &result)) != MM_ERROR_NONE) {
341 debug_error("dbus set volume by type failed");
345 debug_error("Construct Param for method call failed");
346 return MM_ERROR_SOUND_INTERNAL;
350 g_variant_get(result, "(&s)", &reply);
351 debug_log("reply : %s", reply);
352 if (!strcmp(reply, "STREAM_MANAGER_RETURN_ERROR"))
353 ret = MM_ERROR_SOUND_INTERNAL;
355 debug_error("reply null");
360 g_variant_unref(result);
366 int mm_sound_proxy_add_volume_changed_callback(mm_sound_volume_changed_wrapper_cb func, void* userdata, mm_sound_proxy_userdata_free freefunc, unsigned *subs_id)
368 int ret = MM_ERROR_NONE;
369 struct callback_data *cb_data;
373 CB_DATA_NEW(cb_data, func, userdata, freefunc);
375 if ((ret = mm_sound_dbus_signal_subscribe_to(AUDIO_PROVIDER_STREAM_MANAGER, AUDIO_EVENT_VOLUME_CHANGED, dbus_callback, cb_data, simple_callback_data_free_func, &cb_data->subs_id)) != MM_ERROR_NONE)
376 debug_error("Add Volume changed callback failed");
378 *subs_id = cb_data->subs_id;
386 int mm_sound_proxy_remove_volume_changed_callback(unsigned subs_id)
388 int ret = MM_ERROR_NONE;
391 if ((ret = mm_sound_dbus_signal_unsubscribe(subs_id)) != MM_ERROR_NONE) {
392 debug_error("Remove Volume changed callback failed");
399 int mm_sound_proxy_play_tone(int tone, int repeat, int volume, int volume_config,
400 int session_type, int session_options, int client_pid,
401 bool enable_session, int *codechandle, char *stream_type, int stream_index)
403 int ret = MM_ERROR_NONE;
405 GVariant *params = NULL, *result = NULL;
406 gboolean _enable_session = enable_session;
409 debug_error("Param for play is null");
410 return MM_ERROR_INVALID_ARGUMENT;
415 params = g_variant_new("(iiiiiiibsi)", tone, repeat, volume,
416 volume_config, session_type, session_options, client_pid , _enable_session, stream_type, stream_index);
418 if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_SOUND_SERVER, AUDIO_METHOD_PLAY_DTMF, params, &result)) != MM_ERROR_NONE) {
419 debug_error("dbus play tone failed");
423 debug_error("Construct Param for method call failed");
427 g_variant_get(result, "(i)", &handle);
428 debug_log("handle : %d", handle);
429 *codechandle = handle;
431 debug_error("reply null");
436 g_variant_unref(result);
442 int mm_sound_proxy_play_tone_with_stream_info(int client_pid, int tone, char *stream_type, int stream_index, int volume, int repeat, int *codechandle)
444 int ret = MM_ERROR_NONE;
446 GVariant *params = NULL, *result = NULL;
451 debug_error("Param for play is null");
452 return MM_ERROR_INVALID_ARGUMENT;
455 params = g_variant_new("(iiiisi)", tone, repeat, volume, client_pid, stream_type, stream_index);
457 if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_SOUND_SERVER, AUDIO_METHOD_PLAY_DTMF_WITH_STREAM_INFO, params, &result)) != MM_ERROR_NONE) {
458 debug_error("dbus play tone failed");
462 debug_error("Construct Param for method call failed");
466 g_variant_get(result, "(i)", &handle);
467 debug_log("handle : %d", handle);
468 *codechandle = handle;
470 debug_error("reply null");
475 g_variant_unref(result);
481 int mm_sound_proxy_play_sound(const char* filename, int tone, int repeat, int volume, int volume_config,
482 int priority, int session_type, int session_options, int client_pid, int handle_route,
483 bool enable_session, int *codechandle, char *stream_type, int stream_index)
485 int ret = MM_ERROR_NONE;
487 GVariant *params = NULL, *result = NULL;
488 gboolean _enable_session = enable_session;
490 if (!filename || !codechandle) {
491 debug_error("Param for play is null");
492 return MM_ERROR_INVALID_ARGUMENT;
497 params = g_variant_new("(siiiiiiiiibsi)", filename, tone, repeat, volume,
498 volume_config, priority, session_type, session_options, client_pid, handle_route, _enable_session, stream_type, stream_index);
500 if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_SOUND_SERVER, AUDIO_METHOD_PLAY_FILE_START, params, &result)) != MM_ERROR_NONE) {
501 debug_error("dbus play file failed");
505 debug_error("Construct Param for method call failed");
509 g_variant_get(result, "(i)", &handle);
510 debug_log("handle : %d", handle);
511 *codechandle = handle;
513 debug_error("reply null");
518 g_variant_unref(result);
524 int mm_sound_proxy_play_sound_with_stream_info(const char* filename, int repeat, int volume,
525 int priority, int client_pid, int handle_route, int *codechandle, char *stream_type, int stream_index)
527 int ret = MM_ERROR_NONE;
529 GVariant *params = NULL, *result = NULL;
531 if (!filename || !codechandle) {
532 debug_error("Param for play is null");
533 return MM_ERROR_INVALID_ARGUMENT;
538 params = g_variant_new("(siiiiisi)", filename, repeat, volume,
539 priority, client_pid, handle_route, stream_type, stream_index);
541 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) {
542 debug_error("dbus play file failed");
546 debug_error("Construct Param for method call failed");
550 g_variant_get(result, "(i)", &handle);
551 debug_log("handle : %d", handle);
552 *codechandle = handle;
554 debug_error("reply null");
559 g_variant_unref(result);
567 int mm_sound_proxy_stop_sound(int handle)
569 int ret = MM_ERROR_NONE;
570 GVariant *result = NULL;
574 if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_SOUND_SERVER, AUDIO_METHOD_PLAY_FILE_STOP, g_variant_new("(i)", handle), &result)) != MM_ERROR_NONE) {
575 debug_error("dbus stop file playing failed");
581 g_variant_unref(result);
587 int mm_sound_proxy_clear_focus(int pid)
589 int ret = MM_ERROR_NONE;
590 GVariant *result = NULL;
594 if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_SOUND_SERVER, AUDIO_METHOD_CLEAR_FOCUS, g_variant_new("(i)", pid), &result)) != MM_ERROR_NONE) {
595 debug_error("dbus clear focus failed");
599 g_variant_unref(result);
605 int mm_sound_proxy_add_play_sound_end_callback(mm_sound_stop_callback_wrapper_func func, void* userdata, mm_sound_proxy_userdata_free freefunc, unsigned *subs_id)
607 int ret = MM_ERROR_NONE;
608 struct callback_data *cb_data;
612 CB_DATA_NEW(cb_data, func, userdata, freefunc);
614 if ((ret = mm_sound_dbus_signal_subscribe_to(AUDIO_PROVIDER_SOUND_SERVER, AUDIO_EVENT_PLAY_FILE_END, dbus_callback, cb_data, simple_callback_data_free_func, &cb_data->subs_id)) != MM_ERROR_NONE)
615 debug_error("add play sound end callback failed");
617 *subs_id = cb_data->subs_id;
624 int mm_sound_proxy_remove_play_sound_end_callback(unsigned subs_id)
626 int ret = MM_ERROR_NONE;
629 if ((ret = mm_sound_dbus_signal_unsubscribe(subs_id)) != MM_ERROR_NONE) {
630 debug_error("Remove Play File End callback failed");
637 int mm_sound_proxy_emergent_exit(int exit_pid)
639 int ret = MM_ERROR_NONE;
640 GVariant *params = NULL;
644 params = g_variant_new("(i)", exit_pid);
646 if ((ret = mm_sound_dbus_emit_signal(AUDIO_PROVIDER_AUDIO_CLIENT, AUDIO_EVENT_EMERGENT_EXIT, params)) != MM_ERROR_NONE) {
647 debug_error("dbus emergent exit failed");
651 debug_error("Construct Param for emergent exit signal failed");
652 ret = MM_ERROR_SOUND_INTERNAL;
661 /*------------------------------------------ FOCUS --------------------------------------------------*/
664 int mm_sound_proxy_get_unique_id(int *id)
666 int ret = MM_ERROR_NONE;
668 GVariant *result = NULL;
672 if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_FOCUS_SERVER, AUDIO_METHOD_GET_UNIQUE_ID, NULL, &result)) != MM_ERROR_NONE) {
673 debug_error("dbus get unique id failed");
677 g_variant_get(result, "(i)", &res);
679 debug_msg("got unique id(%d)", *id);
680 g_variant_unref(result);
688 int mm_sound_proxy_register_focus(int id, int instance, const char *stream_type, mm_sound_focus_changed_cb callback, bool is_for_session, void* userdata)
690 int ret = MM_ERROR_NONE;
691 GVariant *params = NULL, *result = NULL;
695 params = g_variant_new("(iisb)", instance, id, stream_type, is_for_session);
697 if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_FOCUS_SERVER, AUDIO_METHOD_REGISTER_FOCUS, params, &result)) != MM_ERROR_NONE) {
698 debug_error("dbus register focus failed");
701 debug_error("Construct Param for method call failed");
704 if (ret != MM_ERROR_NONE)
705 g_variant_get(result, "(i)", &ret);
707 g_variant_unref(result);
715 int mm_sound_proxy_unregister_focus(int instance, int id, bool is_for_session)
717 int ret = MM_ERROR_NONE;
718 GVariant *params = NULL, *result = NULL;
722 params = g_variant_new("(iib)", instance, id, is_for_session);
724 if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_FOCUS_SERVER, AUDIO_METHOD_UNREGISTER_FOCUS, params, &result)) != MM_ERROR_NONE) {
725 debug_error("dbus unregister focus failed");
728 debug_error("Construct Param for method call failed");
731 if (ret != MM_ERROR_NONE)
732 g_variant_get(result, "(i)", &ret);
734 g_variant_unref(result);
741 int mm_sound_proxy_set_foucs_reacquisition(int instance, int id, bool reacquisition)
743 int ret = MM_ERROR_NONE;
744 GVariant *params = NULL, *result = NULL;
748 params = g_variant_new("(iib)", instance, id, reacquisition);
750 if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_FOCUS_SERVER, AUDIO_METHOD_SET_FOCUS_REACQUISITION, params, &result)) != MM_ERROR_NONE) {
751 debug_error("dbus set focus reacquisition failed");
754 debug_error("Construct Param for method call failed");
757 if (ret != MM_ERROR_NONE)
758 g_variant_get(result, "(i)", &ret);
760 g_variant_unref(result);
766 int mm_sound_proxy_get_acquired_focus_stream_type(int focus_type, char **stream_type, char **additional_info)
768 int ret = MM_ERROR_NONE;
769 GVariant *params = NULL, *result = NULL;
773 if (!(params = g_variant_new("(i)", focus_type))) {
774 debug_error("Construct Param for method call failed");
775 return MM_ERROR_SOUND_INTERNAL;
778 if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_FOCUS_SERVER, AUDIO_METHOD_GET_ACQUIRED_FOCUS_STREAM_TYPE, params, &result)) == MM_ERROR_NONE) {
780 g_variant_get(result, "(ss)", stream_type, additional_info);
781 g_variant_unref(result);
784 debug_error("dbus get stream type of acquired focus failed");
791 int mm_sound_proxy_acquire_focus(int instance, int id, mm_sound_focus_type_e type, const char *option, bool is_for_session)
793 int ret = MM_ERROR_NONE;
794 GVariant *params = NULL, *result = NULL;
798 params = g_variant_new("(iiisb)", instance, id, type, option ? option : "", is_for_session);
800 if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_FOCUS_SERVER, AUDIO_METHOD_ACQUIRE_FOCUS, params, &result)) != MM_ERROR_NONE) {
801 debug_error("dbus acquire focus failed");
804 debug_error("Construct Param for method call failed");
807 if (ret != MM_ERROR_NONE)
808 g_variant_get(result, "(i)", &ret);
810 g_variant_unref(result);
816 int mm_sound_proxy_release_focus(int instance, int id, mm_sound_focus_type_e type, const char *option, bool is_for_session)
818 int ret = MM_ERROR_NONE;
819 GVariant *params = NULL, *result = NULL;
823 params = g_variant_new("(iiisb)", instance, id, type, option ? option : "", is_for_session);
825 if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_FOCUS_SERVER, AUDIO_METHOD_RELEASE_FOCUS, params, &result)) != MM_ERROR_NONE) {
826 debug_error("dbus release focus failed");
829 debug_error("Construct Param for method call failed");
832 if (ret != MM_ERROR_NONE)
833 g_variant_get(result, "(i)", &ret);
835 g_variant_unref(result);
841 int mm_sound_proxy_set_focus_watch_callback(int instance, int handle, mm_sound_focus_type_e type, mm_sound_focus_changed_watch_cb callback, bool is_for_session, void* userdata)
843 int ret = MM_ERROR_NONE;
844 GVariant *params = NULL, *result = NULL;
848 params = g_variant_new("(iiib)", instance, handle, type, is_for_session);
850 if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_FOCUS_SERVER, AUDIO_METHOD_WATCH_FOCUS, params, &result)) != MM_ERROR_NONE) {
851 debug_error("dbus set watch focus failed");
854 debug_error("Construct Param for method call failed");
857 if (ret != MM_ERROR_NONE)
858 g_variant_get(result, "(i)", &ret);
860 g_variant_unref(result);
867 int mm_sound_proxy_unset_focus_watch_callback(int focus_tid, int handle, bool is_for_session)
869 int ret = MM_ERROR_NONE;
870 GVariant *params = NULL, *result = NULL;
874 params = g_variant_new("(iib)", focus_tid, handle, is_for_session);
876 if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_FOCUS_SERVER, AUDIO_METHOD_UNWATCH_FOCUS, params, &result)) != MM_ERROR_NONE) {
877 debug_error("dbus unset watch focus failed");
880 debug_error("Construct Param for method call failed");
882 if (ret != MM_ERROR_NONE)
883 g_variant_get(result, "(i)", &ret);
885 g_variant_unref(result);
892 #endif /* USE_FOCUS */
893 /*------------------------------------------ FOCUS --------------------------------------------------*/
895 int mm_sound_proxy_initialize(void)
897 int ret = MM_ERROR_NONE;
905 int mm_sound_proxy_finalize(void)
907 int ret = MM_ERROR_NONE;