10 #include "include/mm_sound_mgr_focus_dbus.h"
11 #include "include/mm_sound_mgr_focus_ipc.h"
12 #include "../include/mm_sound_dbus.h"
15 #define BUS_NAME_FOCUS_SERVER "org.tizen.FocusServer"
16 #define OBJECT_FOCUS_SERVER "/org/tizen/FocusServer1"
17 #define INTERFACE_FOCUS_SERVER "org.tizen.FocusServer1"
19 /* Introspection data for the service we are exporting */
20 static const gchar introspection_xml[] =
22 " <interface name='org.tizen.FocusServer1'>"
23 " <method name='GetUniqueId'>"
24 " <arg name='id' type='i' direction='out'/>"
26 " <method name='RegisterFocus'>"
27 " <arg name='pid' type='i' direction='in'/>"
28 " <arg name='handle_id' type='i' direction='in'/>"
29 " <arg name='stream_type' type='s' direction='in'/>"
30 " <arg name='is_for_session' type='b' direction='in'/>"
32 " <method name='UnregisterFocus'>"
33 " <arg name='pid' type='i' direction='in'/>"
34 " <arg name='handle_id' type='i' direction='in'/>"
35 " <arg name='is_for_session' type='b' direction='in'/>"
37 " <method name='SetFocusReacquisition'>"
38 " <arg name='pid' type='i' direction='in'/>"
39 " <arg name='handle_id' type='i' direction='in'/>"
40 " <arg name='reacquisition' type='b' direction='in'/>"
41 " <arg name='is_for_session' type='b' direction='in'/>"
43 " <method name='GetAcquiredFocusStreamType'>"
44 " <arg name='focus_type' type='i' direction='in'/>"
45 " <arg name='stream_type' type='s' direction='out'/>"
46 " <arg name='option' type='i' direction='out'/>"
47 " <arg name='ext_info' type='s' direction='out'/>"
49 " <method name='AcquireFocus'>"
50 " <arg name='pid' type='i' direction='in'/>"
51 " <arg name='handle_id' type='i' direction='in'/>"
52 " <arg name='focus_type' type='i' direction='in'/>"
53 " <arg name='option' type='i' direction='in'/>"
54 " <arg name='ext_info' type='s' direction='in'/>"
55 " <arg name='is_for_session' type='b' direction='in'/>"
57 " <method name='ReleaseFocus'>"
58 " <arg name='pid' type='i' direction='in'/>"
59 " <arg name='handle_id' type='i' direction='in'/>"
60 " <arg name='focus_type' type='i' direction='in'/>"
61 " <arg name='option' type='i' direction='in'/>"
62 " <arg name='ext_info' type='s' direction='in'/>"
63 " <arg name='is_for_session' type='b' direction='in'/>"
65 " <method name='WatchFocus'>"
66 " <arg name='pid' type='i' direction='in'/>"
67 " <arg name='handle_id' type='i' direction='in'/>"
68 " <arg name='focus_type' type='i' direction='in'/>"
69 " <arg name='is_for_session' type='b' direction='in'/>"
70 " <arg name='is_for_monitor' type='b' direction='in'/>"
72 " <method name='UnwatchFocus'>"
73 " <arg name='pid' type='i' direction='in'/>"
74 " <arg name='handle_id' type='i' direction='in'/>"
75 " <arg name='is_for_session' type='b' direction='in'/>"
77 " <method name='DeliverFocus'>"
78 " <arg name='pid' type='i' direction='in'/>"
79 " <arg name='src_handle_id' type='i' direction='in'/>"
80 " <arg name='dst_handle_id' type='i' direction='in'/>"
81 " <arg name='focus_type' type='i' direction='in'/>"
83 " <method name='EmergentExitFocus'>"
84 " <arg name='pid' type='i' direction='in'/>"
88 static GDBusConnection* conn_g;
90 typedef void (*dbus_method_handler)(GDBusMethodInvocation *invocation);
91 typedef int (*dbus_signal_sender)(GDBusConnection *conn, GVariant *parameter);
93 struct mm_sound_mgr_focus_dbus_method{
94 struct mm_sound_dbus_method_info info;
95 dbus_method_handler handler;
98 struct mm_sound_mgr_focus_dbus_signal{
99 struct mm_sound_dbus_signal_info info;
100 dbus_signal_sender sender;
103 static void handle_method_get_unique_id(GDBusMethodInvocation* invocation);
104 static void handle_method_register_focus(GDBusMethodInvocation* invocation);
105 static void handle_method_unregister_focus(GDBusMethodInvocation* invocation);
106 static void handle_method_set_focus_reacquisition(GDBusMethodInvocation* invocation);
107 static void handle_method_get_acquired_focus_stream_type(GDBusMethodInvocation* invocation);
108 static void handle_method_acquire_focus(GDBusMethodInvocation* invocation);
109 static void handle_method_release_focus(GDBusMethodInvocation* invocation);
110 static void handle_method_watch_focus(GDBusMethodInvocation* invocation);
111 static void handle_method_unwatch_focus(GDBusMethodInvocation* invocation);
112 static void handle_method_deliver_focus(GDBusMethodInvocation* invocation);
114 /* Currently , Just using method's name and handler */
115 /* TODO : generate introspection xml automatically, with these value include argument and reply */
116 /* TODO : argument check with these information */
117 /* TODO : divide object and interface with features (ex. play, path, device, focus, asm) */
118 static mm_sound_dbus_method_intf_t methods[AUDIO_METHOD_MAX] = {
119 [AUDIO_METHOD_GET_UNIQUE_ID] = {
121 .name = "GetUniqueId",
123 .handler = handle_method_get_unique_id
125 [AUDIO_METHOD_REGISTER_FOCUS] = {
127 .name = "RegisterFocus",
129 .handler = handle_method_register_focus
131 [AUDIO_METHOD_UNREGISTER_FOCUS] = {
133 .name = "UnregisterFocus",
135 .handler = handle_method_unregister_focus
137 [AUDIO_METHOD_SET_FOCUS_REACQUISITION] = {
139 .name = "SetFocusReacquisition",
141 .handler = handle_method_set_focus_reacquisition
143 [AUDIO_METHOD_GET_ACQUIRED_FOCUS_STREAM_TYPE] = {
145 .name = "GetAcquiredFocusStreamType",
147 .handler = handle_method_get_acquired_focus_stream_type
149 [AUDIO_METHOD_ACQUIRE_FOCUS] = {
151 .name = "AcquireFocus",
153 .handler = handle_method_acquire_focus
155 [AUDIO_METHOD_RELEASE_FOCUS] = {
157 .name = "ReleaseFocus",
159 .handler = handle_method_release_focus
161 [AUDIO_METHOD_WATCH_FOCUS] = {
163 .name = "WatchFocus",
165 .handler = handle_method_watch_focus
167 [AUDIO_METHOD_UNWATCH_FOCUS] = {
169 .name = "UnwatchFocus",
171 .handler = handle_method_unwatch_focus
173 [AUDIO_METHOD_DELIVER_FOCUS] = {
175 .name = "DeliverFocus",
177 .handler = handle_method_deliver_focus
181 static GDBusNodeInfo *introspection_data = NULL;
182 guint focus_server_owner_id ;
183 unsigned emergent_exit_subs_id;
186 For pass error code with 'g_dbus_method_invocation_return_error'
187 We have to use some glib features like GError, GQuark
189 /* Only For error types which is currently being used in server-side */
190 static const GDBusErrorEntry mm_sound_error_entries[] =
192 {MM_ERROR_OUT_OF_MEMORY, "org.tizen.multimedia.OutOfMemory"},
193 {MM_ERROR_OUT_OF_STORAGE, "org.tizen.multimedia.OutOfStorage"},
194 {MM_ERROR_INVALID_ARGUMENT, "org.tizen.multimedia.InvalidArgument"},
195 {MM_ERROR_POLICY_INTERNAL, "org.tizen.multimedia.PolicyInternal"},
196 {MM_ERROR_NOT_SUPPORT_API, "org.tizen.multimedia.NotSupportAPI"},
197 {MM_ERROR_POLICY_BLOCKED, "org.tizen.multimedia.PolicyBlocked"},
198 {MM_ERROR_END_OF_FILE, "org.tizen.multimedia.EndOfFile"},
199 {MM_ERROR_COMMON_OUT_OF_RANGE, "org.tizen.multimedia.common.OutOfRange"},
200 {MM_ERROR_COMMON_UNKNOWN, "org.tizen.multimedia.common.Unknown"},
201 {MM_ERROR_COMMON_NO_FREE_SPACE, "org.tizen.multimedia.common.NoFreeSpace"},
202 {MM_ERROR_SOUND_INTERNAL, "org.tizen.multimedia.audio.Internal"},
203 {MM_ERROR_SOUND_INVALID_STATE, "org.tizen.multimedia.audio.InvalidState"},
204 {MM_ERROR_SOUND_NO_FREE_SPACE, "org.tizen.multimedia.audio.NoFreeSpace"},
205 {MM_ERROR_SOUND_UNSUPPORTED_MEDIA_TYPE, "org.tizen.multimedia.audio.UnsupportedMediaType"},
206 {MM_ERROR_SOUND_INVALID_POINTER, "org.tizen.multimedia.audio.InvalidPointer"},
207 {MM_ERROR_SOUND_INVALID_FILE, "org.tizen.multimedia.audio.InvalidFile"},
208 {MM_ERROR_SOUND_FILE_NOT_FOUND, "org.tizen.multimedia.audio.FileNotFound"},
209 {MM_ERROR_SOUND_NO_DATA, "org.tizen.multimedia.audio.NoData"},
210 {MM_ERROR_SOUND_INVALID_PATH, "org.tizen.multimedia.audio.InvalidPath"},
213 static const char* _convert_error_code(int err_code)
217 for (i = 0; i < G_N_ELEMENTS(mm_sound_error_entries); i++) {
218 if (err_code == mm_sound_error_entries[i].error_code) {
219 return mm_sound_error_entries[i].dbus_error_name;
223 return "org.tizen.multimedia.common.Unknown";
226 static int _get_sender_pid(GDBusMethodInvocation* invocation)
231 GDBusConnection * connection = NULL;
234 connection = g_dbus_method_invocation_get_connection(invocation);
235 sender = g_dbus_method_invocation_get_sender(invocation);
237 debug_msg("connection = %p, sender = %s", connection, sender);
239 value = g_dbus_connection_call_sync(connection, "org.freedesktop.DBus", "/org/freedesktop/DBus",
240 "org.freedesktop.DBus", "GetConnectionUnixProcessID",
241 g_variant_new("(s)", sender, NULL), NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
243 g_variant_get(value, "(u)", &pid);
244 debug_msg("Sender PID = [%d]", pid);
245 g_variant_unref(value);
247 debug_error("err code = %d, err msg = %s", err->code, err->message);
252 static void _method_call_return_value(GDBusMethodInvocation *invocation, GVariant *params)
254 const char *method_name;
255 method_name = g_dbus_method_invocation_get_method_name(invocation);
256 debug_msg("Method Call '%s' success", method_name);
257 g_dbus_method_invocation_return_value(invocation, params);
259 static void _method_call_return_error(GDBusMethodInvocation *invocation, int ret)
261 const char *err_name, *method_name;
262 err_name = _convert_error_code(ret);
263 method_name = g_dbus_method_invocation_get_method_name(invocation);
264 debug_error("Method Call '%s' failed, err '%s(%X)'", method_name, err_name, ret);
265 g_dbus_method_invocation_return_dbus_error(invocation, err_name, "failed");
268 static void handle_method_get_unique_id(GDBusMethodInvocation* invocation)
270 static int unique_id = 0;
274 _method_call_return_value(invocation, g_variant_new("(i)", ++unique_id));
279 static void handle_method_register_focus(GDBusMethodInvocation* invocation)
281 int ret = MM_ERROR_NONE;
283 const char* stream_type = NULL;
284 gboolean is_for_session;
285 GVariant *params = NULL;
290 if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
291 debug_error("Parameter for Method is NULL");
292 ret = MM_ERROR_SOUND_INTERNAL;
296 g_variant_get(params, "(ii&sb)", &pid, &handle_id, &stream_type, &is_for_session);
297 ret = __mm_sound_mgr_focus_ipc_register_focus((is_for_session) ? pid : _get_sender_pid(invocation), handle_id, stream_type, is_for_session);
300 if (ret == MM_ERROR_NONE) {
301 _method_call_return_value(invocation, g_variant_new("()"));
303 _method_call_return_error(invocation, ret);
309 static void handle_method_unregister_focus(GDBusMethodInvocation* invocation)
311 int ret = MM_ERROR_NONE;
312 int pid = 0, handle_id = 0;
313 gboolean is_for_session;
314 GVariant *params = NULL;
318 if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
319 debug_error("Parameter for Method is NULL");
320 ret = MM_ERROR_SOUND_INTERNAL;
324 g_variant_get(params, "(iib)", &pid, &handle_id, &is_for_session);
325 ret = __mm_sound_mgr_focus_ipc_unregister_focus((is_for_session) ? pid : _get_sender_pid(invocation), handle_id, is_for_session);
328 if (ret == MM_ERROR_NONE) {
329 _method_call_return_value(invocation, g_variant_new("()"));
331 _method_call_return_error(invocation, ret);
337 static void handle_method_set_focus_reacquisition(GDBusMethodInvocation* invocation)
339 int ret = MM_ERROR_NONE;
340 int pid = 0, handle_id = 0;
341 gboolean reacquisition;
342 gboolean is_for_session;
343 GVariant *params = NULL;
347 if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
348 debug_error("Parameter for Method is NULL");
349 ret = MM_ERROR_SOUND_INTERNAL;
353 g_variant_get(params, "(iibb)", &pid, &handle_id, &reacquisition, &is_for_session);
354 ret = __mm_sound_mgr_focus_ipc_set_focus_reacquisition(_get_sender_pid(invocation), handle_id, reacquisition, is_for_session);
357 if (ret == MM_ERROR_NONE) {
358 _method_call_return_value(invocation, g_variant_new("()"));
360 _method_call_return_error(invocation, ret);
366 static void handle_method_get_acquired_focus_stream_type(GDBusMethodInvocation* invocation)
368 int ret = MM_ERROR_NONE;
370 char *stream_type = NULL;
372 char *ext_info = NULL;
373 GVariant *params = NULL;
377 if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
378 debug_error("Parameter for Method is NULL");
379 ret = MM_ERROR_SOUND_INTERNAL;
383 g_variant_get(params, "(i)", &focus_type);
384 ret = __mm_sound_mgr_focus_ipc_get_acquired_focus_stream_type(focus_type, &stream_type, &option, &ext_info);
387 if (ret == MM_ERROR_NONE)
388 _method_call_return_value(invocation, g_variant_new("(sis)", stream_type, option, ext_info));
390 _method_call_return_error(invocation, ret);
395 static void handle_method_acquire_focus(GDBusMethodInvocation* invocation)
397 int ret = MM_ERROR_NONE;
398 int pid = 0, handle_id = 0, focus_type = 0, option = 0;
399 const char* ext_info = NULL;
400 gboolean is_for_session;
401 GVariant *params = NULL;
405 if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
406 debug_error("Parameter for Method is NULL");
407 ret = MM_ERROR_SOUND_INTERNAL;
411 g_variant_get(params, "(iiiisb)", &pid, &handle_id, &focus_type, &option, &ext_info, &is_for_session);
412 ret = __mm_sound_mgr_focus_ipc_acquire_focus((is_for_session) ? pid : _get_sender_pid(invocation),
413 handle_id, focus_type, option, ext_info, false, is_for_session);
416 if (ret == MM_ERROR_NONE) {
417 _method_call_return_value(invocation, g_variant_new("()"));
419 _method_call_return_error(invocation, ret);
425 static void handle_method_release_focus(GDBusMethodInvocation* invocation)
427 int ret = MM_ERROR_NONE;
428 int pid = 0, handle_id = 0, focus_type = 0, option = 0;
429 const char* ext_info = NULL;
430 gboolean is_for_session;
431 GVariant *params = NULL;
435 if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
436 debug_error("Parameter for Method is NULL");
437 ret = MM_ERROR_SOUND_INTERNAL;
441 g_variant_get(params, "(iiiisb)", &pid, &handle_id, &focus_type, &option, &ext_info, &is_for_session);
442 ret = __mm_sound_mgr_focus_ipc_release_focus((is_for_session) ? pid : _get_sender_pid(invocation),
443 handle_id, focus_type, option, ext_info, false, is_for_session);
446 if (ret == MM_ERROR_NONE) {
447 _method_call_return_value(invocation, g_variant_new("()"));
449 _method_call_return_error(invocation, ret);
455 static void handle_method_watch_focus(GDBusMethodInvocation* invocation)
457 int ret = MM_ERROR_NONE;
458 int handle_id = 0, focus_type = 0;
459 gboolean is_for_session;
460 gboolean is_for_monitor;
461 GVariant *params = NULL;
466 if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
467 debug_error("Parameter for Method is NULL");
468 ret = MM_ERROR_SOUND_INTERNAL;
472 g_variant_get(params, "(iiibb)", &pid, &handle_id, &focus_type, &is_for_session, &is_for_monitor);
473 ret = __mm_sound_mgr_focus_ipc_watch_focus((is_for_session) ? pid : _get_sender_pid(invocation), handle_id, focus_type, is_for_session, is_for_monitor);
476 if (ret == MM_ERROR_NONE) {
477 _method_call_return_value(invocation, g_variant_new("()"));
479 _method_call_return_error(invocation, ret);
485 static void handle_method_unwatch_focus(GDBusMethodInvocation* invocation)
487 int ret = MM_ERROR_NONE;
490 gboolean is_for_session;
491 GVariant *params = NULL;
495 if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
496 debug_error("Parameter for Method is NULL");
497 ret = MM_ERROR_SOUND_INTERNAL;
501 g_variant_get(params, "(iib)", &pid, &handle_id, &is_for_session);
502 ret = __mm_sound_mgr_focus_ipc_unwatch_focus((is_for_session) ? pid : _get_sender_pid(invocation), handle_id);
505 if (ret == MM_ERROR_NONE) {
506 _method_call_return_value(invocation, g_variant_new("()"));
508 _method_call_return_error(invocation, ret);
514 static void handle_method_deliver_focus(GDBusMethodInvocation* invocation)
516 int ret = MM_ERROR_NONE;
518 int src_handle_id = 0;
519 int dst_handle_id = 0;
521 GVariant *params = NULL;
525 if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
526 debug_error("Parameter for Method is NULL");
527 ret = MM_ERROR_SOUND_INTERNAL;
531 g_variant_get(params, "(iiii)", &pid, &src_handle_id, &dst_handle_id, &focus_type);
532 ret = __mm_sound_mgr_focus_ipc_deliver_focus(pid, src_handle_id, dst_handle_id, focus_type);
535 if (ret == MM_ERROR_NONE) {
536 _method_call_return_value(invocation, g_variant_new("()"));
538 _method_call_return_error(invocation, ret);
544 /**********************************************************************************/
545 static void handle_method_call(GDBusConnection *connection,
547 const gchar *object_path,
548 const gchar *interface_name,
549 const gchar *method_name,
550 GVariant *parameters,
551 GDBusMethodInvocation *invocation,
557 debug_error("Parameter Null");
560 debug_msg("Method Call, obj : %s, intf : %s, method : %s", object_path, interface_name, method_name);
562 for (method_idx = AUDIO_METHOD_GET_UNIQUE_ID; method_idx < AUDIO_METHOD_MAX; method_idx++) {
563 if (!g_strcmp0(method_name, methods[method_idx].info.name)) {
564 methods[method_idx].handler(invocation);
569 static GVariant* handle_get_property(GDBusConnection *connection,
571 const gchar *object_path,
572 const gchar *interface_name,
573 const gchar *property_name,
577 debug_log("Get Property, obj : %s, intf : %s, prop : %s", object_path, interface_name, property_name);
581 static gboolean handle_set_property(GDBusConnection *connection,
583 const gchar *object_path,
584 const gchar *interface_name,
585 const gchar *property_name,
590 debug_log("Set Property, obj : %s, intf : %s, prop : %s", object_path, interface_name, property_name);
594 void emergent_exit_signal_handler(audio_event_t event, GVariant *param, void *userdata)
596 int ret = MM_ERROR_NONE;
599 if (event != AUDIO_EVENT_EMERGENT_EXIT)
604 g_variant_get(param, "(i)", &pid);
605 debug_log("emergent exit : pid %d", pid);
606 ret = __mm_sound_mgr_focus_ipc_emergent_exit(pid);
608 debug_error("__mm_sound_mgr_focus_ipc_emergent_exit failed : 0x%x", ret);
613 static const GDBusInterfaceVTable interface_vtable =
620 static void on_bus_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data)
623 debug_log("Bus Acquired (%s)", name);
626 reg_id = g_dbus_connection_register_object(connection,
628 introspection_data->interfaces[0],
634 debug_error("Register object(%s) failed", OBJECT_FOCUS_SERVER);
639 static void on_name_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data)
641 debug_log("Name Acquired (%s)", name);
644 static void on_name_lost(GDBusConnection *connection, const gchar *name, gpointer user_data)
646 debug_log("Name Lost (%s)", name);
649 static int _mm_sound_mgr_focus_dbus_own_name(GBusType bus_type, const char* wellknown_name, guint* owner_id)
653 debug_msg("Own name (%s) for focus-server", wellknown_name);
655 oid = g_bus_own_name(bus_type, wellknown_name, G_BUS_NAME_OWNER_FLAGS_NONE,
656 on_bus_acquired, on_name_acquired, on_name_lost, NULL, NULL);
658 debug_error("Dbus own name failed");
659 return MM_ERROR_SOUND_INTERNAL;
664 debug_msg("OwnerID (%d) for focus-server", *owner_id);
666 return MM_ERROR_NONE;
669 static void _mm_sound_mgr_focus_dbus_unown_name(guint oid)
671 debug_msg("Unown name for focus-server [%d]", oid);
673 g_bus_unown_name(oid);
677 #define PA_BUS_NAME "org.pulseaudio.Server"
678 #define PA_STREAM_MANAGER_OBJECT_PATH "/org/pulseaudio/StreamManager"
679 #define PA_STREAM_MANAGER_INTERFACE "org.pulseaudio.StreamManager"
680 #define PA_STREAM_MANAGER_METHOD_NAME_GET_STREAM_LIST "GetStreamList"
681 int __mm_sound_mgr_focus_dbus_get_stream_list(stream_list_t* stream_list)
683 int ret = MM_ERROR_NONE;
684 GVariant *result = NULL;
685 GVariant *child = NULL;
686 GDBusConnection *conn = NULL;
690 conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
692 LOGE("g_bus_get_sync() error (%s)", err->message);
694 ret = MM_ERROR_SOUND_INTERNAL;
697 result = g_dbus_connection_call_sync(conn,
699 PA_STREAM_MANAGER_OBJECT_PATH,
700 PA_STREAM_MANAGER_INTERFACE,
701 PA_STREAM_MANAGER_METHOD_NAME_GET_STREAM_LIST,
703 G_VARIANT_TYPE("(vv)"),
704 G_DBUS_CALL_FLAGS_NONE,
708 if (!result && err) {
709 debug_error("g_dbus_connection_call_sync() error (%s)", err->message);
710 ret = MM_ERROR_SOUND_INTERNAL;
713 GVariant *item = NULL;
714 child = g_variant_get_child_value(result, 0);
715 item = g_variant_get_variant(child);
718 g_variant_iter_init(&iter, item);
719 while ((i < AVAIL_STREAMS_MAX) && g_variant_iter_loop(&iter, "&s", &name)) {
720 debug_log("name : %s", name);
721 stream_list->stream_types[i++] = strdup(name);
723 g_variant_unref(item);
724 g_variant_unref(child);
726 child = g_variant_get_child_value(result, 1);
727 item = g_variant_get_variant(child);
730 g_variant_iter_init(&iter, item);
731 while ((i < AVAIL_STREAMS_MAX) && g_variant_iter_loop(&iter, "i", &priority)) {
732 debug_log("priority : %d", priority);
733 stream_list->priorities[i++] = priority;
735 g_variant_unref(item);
736 g_variant_unref(child);
738 g_variant_unref(result);
740 g_object_unref(conn);
745 int MMSoundMgrFocusDbusInit(void)
749 introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, NULL);
750 if (!introspection_data)
751 return MM_ERROR_SOUND_INTERNAL;
753 if (_mm_sound_mgr_focus_dbus_own_name(G_BUS_TYPE_SYSTEM, BUS_NAME_FOCUS_SERVER, &focus_server_owner_id) != MM_ERROR_NONE) {
754 debug_error("dbus own name for focus-server error\n");
755 return MM_ERROR_SOUND_INTERNAL;
757 if (mm_sound_dbus_signal_subscribe_to(AUDIO_PROVIDER_AUDIO_CLIENT, AUDIO_EVENT_EMERGENT_EXIT, emergent_exit_signal_handler, NULL, NULL, &emergent_exit_subs_id) != MM_ERROR_NONE) {
758 debug_error("dbus signal subscribe for emergent exit error\n");
759 return MM_ERROR_SOUND_INTERNAL;
764 return MM_ERROR_NONE;
767 void MMSoundMgrFocusDbusFini(void)
771 if (emergent_exit_subs_id != 0)
772 mm_sound_dbus_signal_unsubscribe(emergent_exit_subs_id);
773 _mm_sound_mgr_focus_dbus_unown_name(focus_server_owner_id);
774 g_dbus_node_info_unref(introspection_data);