16 #include <security-server.h>
17 #define COOKIE_SIZE 20
20 #include "include/mm_sound_mgr_ipc_dbus.h"
21 #include "include/mm_sound_mgr_ipc.h"
24 #define BUS_NAME_SOUND_SERVER "org.tizen.SoundServer"
25 #define OBJECT_SOUND_SERVER "/org/tizen/SoundServer1"
26 #define INTERFACE_SOUND_SERVER "org.tizen.SoundServer1"
28 /* workaround for AF volume gain tuning */
29 #define PROC_DBUS_OBJECT "/Org/Tizen/ResourceD/Process"
30 #define PROC_DBUS_INTERFACE "org.tizen.resourced.process"
31 #define PROC_DBUS_METHOD "ProcExclude"
33 #define OBJECT_ASM "/org/tizen/asm"
34 #define INTERFACE_ASM "org.tizen.asm"
36 /* Introspection data for the service we are exporting */
37 static const gchar introspection_xml[] =
39 " <interface name='org.tizen.SoundServer1'>"
40 " <method name='MethodTest1'>"
41 " <arg type='i' name='num1' direction='in'/>"
42 " <arg type='i' name='num2' direction='in'/>"
43 " <arg type='i' name='multiple' direction='out'/>"
45 " <method name='GetBTA2DPStatus'>"
46 " <arg type='b' name='is_bt_on' direction='out'/>"
47 " <arg type='s' name='bt_name' direction='out'/>"
49 " <method name='PlayFileStart'>"
50 " <arg type='s' name='filename' direction='in'/>"
51 " <arg type='i' name='tone' direction='in'/>"
52 " <arg type='i' name='repeat' direction='in'/>"
53 " <arg type='i' name='volume' direction='in'/>"
54 " <arg type='i' name='vol_config' direction='in'/>"
55 " <arg type='i' name='priority' direction='in'/>"
56 " <arg type='i' name='session_type' direction='in'/>"
57 " <arg type='i' name='session_option' direction='in'/>"
58 " <arg type='i' name='client_pid' direction='in'/>"
59 " <arg type='i' name='handle_route' direction='in'/>"
60 " <arg type='b' name='enable_session' direction='in'/>"
61 " <arg type='s' name='stream_type' direction='in'/>"
62 " <arg type='i' name='stream_index' direction='in'/>"
63 " <arg type='i' name='handle' direction='out'/>"
65 " <method name='PlayFileStartWithStreamInfo'>"
66 " <arg type='s' name='filename' direction='in'/>"
67 " <arg type='i' name='repeat' direction='in'/>"
68 " <arg type='i' name='volume' direction='in'/>"
69 " <arg type='i' name='priority' direction='in'/>"
70 " <arg type='i' name='client_pid' direction='in'/>"
71 " <arg type='i' name='handle_route' direction='in'/>"
72 " <arg type='s' name='stream_type' direction='in'/>"
73 " <arg type='i' name='stream_index' direction='in'/>"
74 " <arg type='i' name='handle' direction='out'/>"
76 " <method name='PlayFileStop'>"
77 " <arg type='i' name='handle' direction='in'/>"
79 " <method name='ClearFocus'>"
80 " <arg type='i' name='pid' direction='in'/>"
82 " <method name='PlayDTMF'>"
83 " <arg type='i' name='tone' direction='in'/>"
84 " <arg type='i' name='repeat' direction='in'/>"
85 " <arg type='i' name='volume' direction='in'/>"
86 " <arg type='i' name='vol_config' direction='in'/>"
87 " <arg type='i' name='session_type' direction='in'/>"
88 " <arg type='i' name='session_option' direction='in'/>"
89 " <arg type='i' name='client_pid' direction='in'/>"
90 " <arg type='b' name='enable_session' direction='in'/>"
91 " <arg type='s' name='stream_type' direction='in'/>"
92 " <arg type='i' name='stream_index' direction='in'/>"
93 " <arg type='i' name='handle' direction='out'/>"
95 " <method name='PlayDTMFWithStreamInfo'>"
96 " <arg type='i' name='tone' direction='in'/>"
97 " <arg type='i' name='repeat' direction='in'/>"
98 " <arg type='i' name='volume' direction='in'/>"
99 " <arg type='i' name='client_pid' direction='in'/>"
100 " <arg type='s' name='stream_type' direction='in'/>"
101 " <arg type='i' name='stream_index' direction='in'/>"
102 " <arg type='i' name='handle' direction='out'/>"
104 " <method name='SetPathForActiveDevice'>"
106 " <method name='GetConnectedDeviceList'>"
107 " <arg type='i' name='device_mask' direction='in'/>"
108 " <arg type='a(iiiis)' name='device_list' direction='out'/>"
110 " <method name='GetAudioPath'>"
111 " <arg type='i' name='device_in' direction='out'/>"
112 " <arg type='i' name='device_out' direction='out'/>"
114 " <method name='ASMRegisterSound'>"
115 #ifdef SUPPORT_CONTAINER
117 " <arg name='container' type='ay' direction='in'/>"
119 " <arg name='container' type='s' direction='in'/>"
122 " <arg name='rcv_pid' type='i' direction='in'/>"
123 " <arg name='rcv_handle' type='i' direction='in'/>"
124 " <arg name='rcv_sound_event' type='i' direction='in'/>"
125 " <arg name='rcv_request_id' type='i' direction='in'/>"
126 " <arg name='rcv_sound_state' type='i' direction='in'/>"
127 " <arg name='rcv_resource' type='i' direction='in'/>"
128 " <arg name='snd_pid' type='i' direction='out'/>"
129 " <arg name='snd_alloc_handle' type='i' direction='out'/>"
130 " <arg name='snd_cmd_handle' type='i' direction='out'/>"
131 " <arg name='snd_request_id' type='i' direction='out'/>"
132 " <arg name='snd_sound_command' type='i' direction='out'/>"
133 " <arg name='snd_sound_state' type='i' direction='out'/>"
135 " <method name='ASMUnregisterSound'>"
136 " <arg name='rcv_pid' type='i' direction='in'/>"
137 " <arg name='rcv_handle' type='i' direction='in'/>"
138 " <arg name='rcv_sound_event' type='i' direction='in'/>"
139 " <arg name='rcv_request_id' type='i' direction='in'/>"
140 " <arg name='rcv_sound_state' type='i' direction='in'/>"
141 " <arg name='rcv_resource' type='i' direction='in'/>"
143 " <method name='ASMRegisterWatcher'>"
144 #ifdef SUPPORT_CONTAINER
146 " <arg name='container' type='ay' direction='in'/>"
148 " <arg name='container' type='s' direction='in'/>"
151 " <arg name='rcv_pid' type='i' direction='in'/>"
152 " <arg name='rcv_handle' type='i' direction='in'/>"
153 " <arg name='rcv_sound_event' type='i' direction='in'/>"
154 " <arg name='rcv_request_id' type='i' direction='in'/>"
155 " <arg name='rcv_sound_state' type='i' direction='in'/>"
156 " <arg name='rcv_resource' type='i' direction='in'/>"
157 " <arg name='snd_pid' type='i' direction='out'/>"
158 " <arg name='snd_alloc_handle' type='i' direction='out'/>"
159 " <arg name='snd_cmd_handle' type='i' direction='out'/>"
160 " <arg name='snd_request_id' type='i' direction='out'/>"
161 " <arg name='snd_sound_command' type='i' direction='out'/>"
162 " <arg name='snd_sound_state' type='i' direction='out'/>"
164 " <method name='ASMUnregisterWatcher'>"
165 " <arg name='rcv_pid' type='i' direction='in'/>"
166 " <arg name='rcv_handle' type='i' direction='in'/>"
167 " <arg name='rcv_sound_event' type='i' direction='in'/>"
168 " <arg name='rcv_request_id' type='i' direction='in'/>"
169 " <arg name='rcv_sound_state' type='i' direction='in'/>"
170 " <arg name='rcv_resource' type='i' direction='in'/>"
172 " <method name='ASMGetMyState'>"
173 " <arg name='rcv_pid' type='i' direction='in'/>"
174 " <arg name='rcv_handle' type='i' direction='in'/>"
175 " <arg name='rcv_sound_event' type='i' direction='in'/>"
176 " <arg name='rcv_request_id' type='i' direction='in'/>"
177 " <arg name='rcv_sound_state' type='i' direction='in'/>"
178 " <arg name='rcv_resource' type='i' direction='in'/>"
179 " <arg name='snd_pid' type='i' direction='out'/>"
180 " <arg name='snd_alloc_handle' type='i' direction='out'/>"
181 " <arg name='snd_cmd_handle' type='i' direction='out'/>"
182 " <arg name='snd_request_id' type='i' direction='out'/>"
183 " <arg name='snd_sound_state' type='i' direction='out'/>"
185 " <method name='ASMGetState'>"
186 " <arg name='rcv_pid' type='i' direction='in'/>"
187 " <arg name='rcv_handle' type='i' direction='in'/>"
188 " <arg name='rcv_sound_event' type='i' direction='in'/>"
189 " <arg name='rcv_request_id' type='i' direction='in'/>"
190 " <arg name='rcv_sound_state' type='i' direction='in'/>"
191 " <arg name='rcv_resource' type='i' direction='in'/>"
192 " <arg name='snd_pid' type='i' direction='out'/>"
193 " <arg name='snd_alloc_handle' type='i' direction='out'/>"
194 " <arg name='snd_cmd_handle' type='i' direction='out'/>"
195 " <arg name='snd_request_id' type='i' direction='out'/>"
196 " <arg name='snd_sound_state' type='i' direction='out'/>"
198 " <method name='ASMSetState'>"
199 " <arg name='rcv_pid' type='i' direction='in'/>"
200 " <arg name='rcv_handle' type='i' direction='in'/>"
201 " <arg name='rcv_sound_event' type='i' direction='in'/>"
202 " <arg name='rcv_request_id' type='i' direction='in'/>"
203 " <arg name='rcv_sound_state' type='i' direction='in'/>"
204 " <arg name='rcv_resource' type='i' direction='in'/>"
205 " <arg name='snd_pid' type='i' direction='out'/>"
206 " <arg name='snd_alloc_handle' type='i' direction='out'/>"
207 " <arg name='snd_cmd_handle' type='i' direction='out'/>"
208 " <arg name='snd_request_id' type='i' direction='out'/>"
209 " <arg name='snd_sound_command' type='i' direction='out'/>"
210 " <arg name='snd_sound_state' type='i' direction='out'/>"
211 " <arg name='snd_error_code' type='i' direction='out'/>"
213 " <method name='ASMSetSubsession'>"
214 " <arg name='rcv_pid' type='i' direction='in'/>"
215 " <arg name='rcv_handle' type='i' direction='in'/>"
216 " <arg name='rcv_sound_event' type='i' direction='in'/>"
217 " <arg name='rcv_request_id' type='i' direction='in'/>"
218 " <arg name='rcv_sound_state' type='i' direction='in'/>"
219 " <arg name='rcv_resource' type='i' direction='in'/>"
220 " <arg name='snd_pid' type='i' direction='out'/>"
221 " <arg name='snd_alloc_handle' type='i' direction='out'/>"
222 " <arg name='snd_cmd_handle' type='i' direction='out'/>"
223 " <arg name='snd_request_id' type='i' direction='out'/>"
225 " <method name='ASMGetSubsession'>"
226 " <arg name='rcv_pid' type='i' direction='in'/>"
227 " <arg name='rcv_handle' type='i' direction='in'/>"
228 " <arg name='rcv_sound_event' type='i' direction='in'/>"
229 " <arg name='rcv_request_id' type='i' direction='in'/>"
230 " <arg name='rcv_sound_state' type='i' direction='in'/>"
231 " <arg name='rcv_resource' type='i' direction='in'/>"
232 " <arg name='snd_pid' type='i' direction='out'/>"
233 " <arg name='snd_alloc_handle' type='i' direction='out'/>"
234 " <arg name='snd_cmd_handle' type='i' direction='out'/>"
235 " <arg name='snd_request_id' type='i' direction='out'/>"
236 " <arg name='snd_sound_command' type='i' direction='out'/>"
238 " <method name='ASMSetSubevent'>"
239 " <arg name='rcv_pid' type='i' direction='in'/>"
240 " <arg name='rcv_handle' type='i' direction='in'/>"
241 " <arg name='rcv_sound_event' type='i' direction='in'/>"
242 " <arg name='rcv_request_id' type='i' direction='in'/>"
243 " <arg name='rcv_sound_state' type='i' direction='in'/>"
244 " <arg name='rcv_resource' type='i' direction='in'/>"
245 " <arg name='snd_pid' type='i' direction='out'/>"
246 " <arg name='snd_alloc_handle' type='i' direction='out'/>"
247 " <arg name='snd_cmd_handle' type='i' direction='out'/>"
248 " <arg name='snd_request_id' type='i' direction='out'/>"
249 " <arg name='snd_sound_command' type='i' direction='out'/>"
250 " <arg name='snd_sound_state' type='i' direction='out'/>"
252 " <method name='ASMGetSubevent'>"
253 " <arg name='rcv_pid' type='i' direction='in'/>"
254 " <arg name='rcv_handle' type='i' direction='in'/>"
255 " <arg name='rcv_sound_event' type='i' direction='in'/>"
256 " <arg name='rcv_request_id' type='i' direction='in'/>"
257 " <arg name='rcv_sound_state' type='i' direction='in'/>"
258 " <arg name='rcv_resource' type='i' direction='in'/>"
259 " <arg name='snd_pid' type='i' direction='out'/>"
260 " <arg name='snd_alloc_handle' type='i' direction='out'/>"
261 " <arg name='snd_cmd_handle' type='i' direction='out'/>"
262 " <arg name='snd_request_id' type='i' direction='out'/>"
263 " <arg name='snd_sound_command' type='i' direction='out'/>"
265 " <method name='ASMSetSessionOption'>"
266 " <arg name='rcv_pid' type='i' direction='in'/>"
267 " <arg name='rcv_handle' type='i' direction='in'/>"
268 " <arg name='rcv_sound_event' type='i' direction='in'/>"
269 " <arg name='rcv_request_id' type='i' direction='in'/>"
270 " <arg name='rcv_sound_state' type='i' direction='in'/>"
271 " <arg name='rcv_resource' type='i' direction='in'/>"
272 " <arg name='snd_pid' type='i' direction='out'/>"
273 " <arg name='snd_alloc_handle' type='i' direction='out'/>"
274 " <arg name='snd_cmd_handle' type='i' direction='out'/>"
275 " <arg name='snd_request_id' type='i' direction='out'/>"
276 " <arg name='snd_sound_command' type='i' direction='out'/>"
277 " <arg name='snd_sound_state' type='i' direction='out'/>"
279 " <method name='ASMGetSessionOption'>"
280 " <arg name='rcv_pid' type='i' direction='in'/>"
281 " <arg name='rcv_handle' type='i' direction='in'/>"
282 " <arg name='rcv_sound_event' type='i' direction='in'/>"
283 " <arg name='rcv_request_id' type='i' direction='in'/>"
284 " <arg name='rcv_sound_state' type='i' direction='in'/>"
285 " <arg name='rcv_resource' type='i' direction='in'/>"
286 " <arg name='snd_pid' type='i' direction='out'/>"
287 " <arg name='snd_alloc_handle' type='i' direction='out'/>"
288 " <arg name='snd_cmd_handle' type='i' direction='out'/>"
289 " <arg name='snd_request_id' type='i' direction='out'/>"
290 " <arg name='snd_sound_command' type='i' direction='out'/>"
291 " <arg name='snd_option_flag' type='i' direction='out'/>"
293 " <method name='ASMResetResumeTag'>"
294 " <arg name='rcv_pid' type='i' direction='in'/>"
295 " <arg name='rcv_handle' type='i' direction='in'/>"
296 " <arg name='rcv_sound_event' type='i' direction='in'/>"
297 " <arg name='rcv_request_id' type='i' direction='in'/>"
298 " <arg name='rcv_sound_state' type='i' direction='in'/>"
299 " <arg name='rcv_resource' type='i' direction='in'/>"
300 " <arg name='snd_pid' type='i' direction='out'/>"
301 " <arg name='snd_alloc_handle' type='i' direction='out'/>"
302 " <arg name='snd_cmd_handle' type='i' direction='out'/>"
303 " <arg name='snd_request_id' type='i' direction='out'/>"
304 " <arg name='snd_sound_command' type='i' direction='out'/>"
305 " <arg name='snd_sound_state' type='i' direction='out'/>"
307 " <method name='ASMDump'>"
308 " <arg name='rcv_pid' type='i' direction='in'/>"
309 " <arg name='rcv_handle' type='i' direction='in'/>"
310 " <arg name='rcv_sound_event' type='i' direction='in'/>"
311 " <arg name='rcv_request_id' type='i' direction='in'/>"
312 " <arg name='rcv_sound_state' type='i' direction='in'/>"
313 " <arg name='rcv_resource' type='i' direction='in'/>"
317 GDBusConnection* conn_g;
319 typedef void (*dbus_method_handler)(GDBusMethodInvocation *invocation);
320 typedef int (*dbus_signal_sender)(GDBusConnection *conn, GVariant *parameter);
322 struct mm_sound_dbus_method{
323 struct mm_sound_dbus_method_info info;
324 dbus_method_handler handler;
327 struct mm_sound_dbus_signal{
328 struct mm_sound_dbus_signal_info info;
329 dbus_signal_sender sender;
332 static void handle_method_play_file_start(GDBusMethodInvocation* invocation);
333 static void handle_method_play_file_start_with_stream_info(GDBusMethodInvocation* invocation);
334 static void handle_method_play_file_stop(GDBusMethodInvocation* invocation);
335 static void handle_method_play_dtmf(GDBusMethodInvocation* invocation);
336 static void handle_method_play_dtmf_with_stream_info(GDBusMethodInvocation* invocation);
337 static void handle_method_clear_focus(GDBusMethodInvocation* invocation);
338 static void handle_method_get_bt_a2dp_status(GDBusMethodInvocation* invocation);
339 static void handle_method_test(GDBusMethodInvocation* invocation);
340 static void handle_method_set_sound_path_for_active_device(GDBusMethodInvocation* invocation);
341 static void handle_method_get_audio_path(GDBusMethodInvocation* invocation);
342 static void handle_method_get_connected_device_list(GDBusMethodInvocation* invocation);
344 static void handle_method_asm_register_sound(GDBusMethodInvocation* invocation);
345 static void handle_method_asm_unregister_sound(GDBusMethodInvocation* invocation);
346 static void handle_method_asm_register_watcher(GDBusMethodInvocation* invocation);
347 static void handle_method_asm_unregister_watcher(GDBusMethodInvocation* invocation);
348 static void handle_method_asm_get_mystate(GDBusMethodInvocation* invocation);
349 static void handle_method_asm_get_state(GDBusMethodInvocation* invocation);
350 static void handle_method_asm_set_state(GDBusMethodInvocation* invocation);
351 static void handle_method_asm_set_subsession(GDBusMethodInvocation* invocation);
352 static void handle_method_asm_get_subsession(GDBusMethodInvocation* invocation);
353 static void handle_method_asm_set_subevent(GDBusMethodInvocation* invocation);
354 static void handle_method_asm_get_subevent(GDBusMethodInvocation* invocation);
355 static void handle_method_asm_set_session_option(GDBusMethodInvocation* invocation);
356 static void handle_method_asm_get_session_option(GDBusMethodInvocation* invocation);
357 static void handle_method_asm_reset_resume_tag(GDBusMethodInvocation* invocation);
358 static void handle_method_asm_dump(GDBusMethodInvocation* invocation);
360 /* Currently , Just using method's name and handler */
361 /* TODO : generate introspection xml automatically, with these value include argument and reply */
362 /* TODO : argument check with these information */
363 /* TODO : divide object and interface with features (ex. play, path, device, focus, asm) */
364 struct mm_sound_dbus_method methods[METHOD_CALL_MAX] = {
365 [METHOD_CALL_TEST] = {
367 .name = "MethodTest1",
369 .handler = handle_method_test
371 [METHOD_CALL_PLAY_FILE_START] = {
373 .name = "PlayFileStart",
375 .handler = handle_method_play_file_start
377 [METHOD_CALL_PLAY_FILE_START_WITH_STREAM_INFO] = {
379 .name = "PlayFileStartWithStreamInfo",
381 .handler = handle_method_play_file_start_with_stream_info
383 [METHOD_CALL_PLAY_FILE_STOP] = {
385 .name = "PlayFileStop",
387 .handler = handle_method_play_file_stop
389 [METHOD_CALL_CLEAR_FOCUS] = {
391 .name = "ClearFocus",
393 .handler = handle_method_clear_focus
395 [METHOD_CALL_PLAY_DTMF] = {
399 .handler = handle_method_play_dtmf
401 [METHOD_CALL_PLAY_DTMF_WITH_STREAM_INFO] = {
403 .name = "PlayDTMFWithStreamInfo",
405 .handler = handle_method_play_dtmf_with_stream_info
407 [METHOD_CALL_GET_BT_A2DP_STATUS] = {
409 .name = "GetBTA2DPStatus",
411 .handler = handle_method_get_bt_a2dp_status
413 [METHOD_CALL_SET_PATH_FOR_ACTIVE_DEVICE] = {
415 .name = "SetPathForActiveDevice",
417 .handler = handle_method_set_sound_path_for_active_device
419 [METHOD_CALL_GET_AUDIO_PATH] = {
421 .name = "GetAudioPath",
423 .handler = handle_method_get_audio_path
425 [METHOD_CALL_GET_CONNECTED_DEVICE_LIST] = {
427 .name = "GetConnectedDeviceList",
429 .handler = handle_method_get_connected_device_list
431 [METHOD_CALL_ASM_REGISTER_SOUND] = {
433 .name = "ASMRegisterSound",
435 .handler = handle_method_asm_register_sound
437 [METHOD_CALL_ASM_UNREGISTER_SOUND] = {
439 .name = "ASMUnregisterSound",
441 .handler = handle_method_asm_unregister_sound
443 [METHOD_CALL_ASM_REGISTER_WATCHER] = {
445 .name = "ASMRegisterWatcher",
447 .handler = handle_method_asm_register_watcher
449 [METHOD_CALL_ASM_UNREGISTER_WATCHER] = {
451 .name = "ASMUnregisterWatcher",
453 .handler = handle_method_asm_unregister_watcher
455 [METHOD_CALL_ASM_GET_MYSTATE] = {
457 .name = "ASMGetMyState",
459 .handler = handle_method_asm_get_mystate
461 [METHOD_CALL_ASM_GET_STATE] = {
463 .name = "ASMGetState",
465 .handler = handle_method_asm_get_state
467 [METHOD_CALL_ASM_SET_STATE] = {
469 .name = "ASMSetState",
471 .handler = handle_method_asm_set_state
473 [METHOD_CALL_ASM_SET_SUBSESSION] = {
475 .name = "ASMSetSubsession",
477 .handler = handle_method_asm_set_subsession
479 [METHOD_CALL_ASM_GET_SUBSESSION] = {
481 .name = "ASMGetSubsession",
483 .handler = handle_method_asm_get_subsession
485 [METHOD_CALL_ASM_SET_SUBEVENT] = {
487 .name = "ASMSetSubevent",
489 .handler = handle_method_asm_set_subevent
491 [METHOD_CALL_ASM_GET_SUBEVENT] = {
493 .name = "ASMGetSubevent",
495 .handler = handle_method_asm_get_subevent
497 [METHOD_CALL_ASM_SET_SESSION_OPTION] = {
499 .name = "ASMSetSessionOption",
501 .handler = handle_method_asm_set_session_option
503 [METHOD_CALL_ASM_GET_SESSION_OPTION] = {
505 .name = "ASMGetSessionOption",
507 .handler = handle_method_asm_get_session_option
509 [METHOD_CALL_ASM_RESET_RESUME_TAG] = {
511 .name = "ASMResetResumeTag",
513 .handler = handle_method_asm_reset_resume_tag
515 [METHOD_CALL_ASM_DUMP] = {
519 .handler = handle_method_asm_dump
523 struct mm_sound_dbus_signal signals[SIGNAL_MAX] = {
526 .name = "SignalTest1",
529 [SIGNAL_PLAY_FILE_END] = {
531 .name = "PlayFileEnd",
534 [SIGNAL_VOLUME_CHANGED] = {
536 .name = "VolumeChanged",
539 [SIGNAL_DEVICE_CONNECTED] = {
541 .name = "DeviceConnected",
544 [SIGNAL_DEVICE_INFO_CHANGED] = {
546 .name = "DeviceInfoChanged",
553 static GDBusNodeInfo *introspection_data = NULL;
554 guint sound_server_owner_id ;
557 For pass error code with 'g_dbus_method_invocation_return_error'
558 We have to use some glib features like GError, GQuark
560 /* Only For error types which is currently being used in server-side */
561 static const GDBusErrorEntry mm_sound_error_entries[] =
563 {MM_ERROR_OUT_OF_MEMORY, "org.tizen.multimedia.OutOfMemory"},
564 {MM_ERROR_OUT_OF_STORAGE, "org.tizen.multimedia.OutOfStorage"},
565 {MM_ERROR_INVALID_ARGUMENT, "org.tizen.multimedia.InvalidArgument"},
566 {MM_ERROR_POLICY_INTERNAL, "org.tizen.multimedia.PolicyInternal"},
567 {MM_ERROR_NOT_SUPPORT_API, "org.tizen.multimedia.NotSupportAPI"},
568 {MM_ERROR_POLICY_BLOCKED, "org.tizen.multimedia.PolicyBlocked"},
569 {MM_ERROR_END_OF_FILE, "org.tizen.multimedia.EndOfFile"},
570 {MM_ERROR_COMMON_OUT_OF_RANGE, "org.tizen.multimedia.common.OutOfRange"},
571 {MM_ERROR_COMMON_UNKNOWN, "org.tizen.multimedia.common.Unknown"},
572 {MM_ERROR_COMMON_NO_FREE_SPACE, "org.tizen.multimedia.common.NoFreeSpace"},
573 {MM_ERROR_SOUND_INTERNAL, "org.tizen.multimedia.audio.Internal"},
574 {MM_ERROR_SOUND_INVALID_STATE, "org.tizen.multimedia.audio.InvalidState"},
575 {MM_ERROR_SOUND_NO_FREE_SPACE, "org.tizen.multimedia.audio.NoFreeSpace"},
576 {MM_ERROR_SOUND_UNSUPPORTED_MEDIA_TYPE, "org.tizen.multimedia.audio.UnsupportedMediaType"},
577 {MM_ERROR_SOUND_INVALID_POINTER, "org.tizen.multimedia.audio.InvalidPointer"},
578 {MM_ERROR_SOUND_INVALID_FILE, "org.tizen.multimedia.audio.InvalidFile"},
579 {MM_ERROR_SOUND_FILE_NOT_FOUND, "org.tizen.multimedia.audio.FileNotFound"},
580 {MM_ERROR_SOUND_NO_DATA, "org.tizen.multimedia.audio.NoData"},
581 {MM_ERROR_SOUND_INVALID_PATH, "org.tizen.multimedia.audio.InvalidPath"},
584 static const char* _convert_error_code(int err_code)
588 for (i = 0; i < G_N_ELEMENTS(mm_sound_error_entries); i++) {
589 if (err_code == mm_sound_error_entries[i].error_code) {
590 return mm_sound_error_entries[i].dbus_error_name;
594 return "org.tizen.multimedia.common.Unknown";
597 static int mm_sound_mgr_ipc_dbus_send_signal(int signal_type, GVariant *parameter)
599 int ret = MM_ERROR_NONE;
600 GDBusConnection *conn = NULL;
602 gboolean emit_success = FALSE;
604 if (signal_type < 0 || signal_type >= SIGNAL_MAX || !parameter) {
605 debug_error("Invalid Argument");
606 return MM_ERROR_SOUND_INTERNAL;
609 debug_log("Signal Emit : %s", signals[signal_type].info.name);
612 conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
614 debug_error ("g_bus_get_sync() error (%s) ", err->message);
616 return MM_ERROR_SOUND_INTERNAL;
621 if (!g_variant_is_of_type(parameter, G_VARIANT_TYPE(signals[signal_type].info.argument))) {
622 debug_error("Invalid Signal Parameter");
623 return MM_ERROR_INVALID_ARGUMENT;
627 emit_success = g_dbus_connection_emit_signal(conn_g, NULL, OBJECT_SOUND_SERVER, INTERFACE_SOUND_SERVER,
628 signals[signal_type].info.name, parameter, &err);
629 if (!emit_success && err) {
630 debug_error("Emit signal (%s) failed, (%s)", signals[signal_type].info.name, err->message);
632 return MM_ERROR_SOUND_INTERNAL;
638 static int _get_sender_pid(GDBusMethodInvocation* invocation)
643 GDBusConnection * connection = NULL;
646 connection = g_dbus_method_invocation_get_connection(invocation);
647 sender = g_dbus_method_invocation_get_sender(invocation);
649 debug_error ("connection = %p, sender = %s", connection, sender);
651 value = g_dbus_connection_call_sync (connection, "org.freedesktop.DBus", "/org/freedesktop/DBus",
652 "org.freedesktop.DBus", "GetConnectionUnixProcessID",
653 g_variant_new("(s)", sender, NULL), NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
655 g_variant_get(value, "(u)", &pid);
656 debug_error ("Sender PID = [%d]", pid);
658 debug_error ("err code = %d, err msg = %s", err->code, err->message);
663 static void _method_call_return_value(GDBusMethodInvocation *invocation, GVariant *params)
665 const char *method_name;
666 method_name = g_dbus_method_invocation_get_method_name(invocation);
667 debug_error("Method Call '%s' success", method_name);
668 g_dbus_method_invocation_return_value(invocation, params);
670 static void _method_call_return_error(GDBusMethodInvocation *invocation, int ret)
672 const char *err_name, *method_name;
673 err_name = _convert_error_code(ret);
674 method_name = g_dbus_method_invocation_get_method_name(invocation);
675 debug_error("Method Call '%s' failed, err '%s(%X)'", method_name, err_name, ret);
676 g_dbus_method_invocation_return_dbus_error(invocation, err_name, "failed");
679 static void handle_method_test(GDBusMethodInvocation* invocation)
681 int ret = MM_ERROR_NONE;
682 int val = 0, val2 = 0;
683 GVariant* params = NULL;
687 if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
688 debug_error("Parameter for Method is NULL");
689 ret = MM_ERROR_SOUND_INTERNAL;
693 g_variant_get(params, "(ii)", &val, &val2);
694 debug_log("Got value : %d , %d", val, val2);
696 if ((ret = mm_sound_mgr_ipc_dbus_send_signal(SIGNAL_TEST, g_variant_new("(i)", val+val2))) != MM_ERROR_NONE) {
697 debug_error("signal send error : %X", ret);
699 debug_error("signal send success");
703 if (ret == MM_ERROR_NONE) {
704 _method_call_return_value(invocation, g_variant_new("(i)", val * val2));
706 ret = MM_ERROR_INVALID_ARGUMENT;
707 _method_call_return_error(invocation, ret);
713 static void handle_method_play_file_start(GDBusMethodInvocation* invocation)
715 gchar* filename = NULL;
716 char *stream_type = NULL;
717 gint32 ret = MM_ERROR_NONE, slotid = 0;
718 gint32 tone = 0, repeat = 0, volume = 0, vol_config = 0, priority = 0;
719 gint32 session_type = 0, session_option = 0, pid = 0, handle_route =0, stream_index = 0;
720 gboolean enable_session = 0;
721 GVariant *params = NULL;
725 if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
726 debug_error("Parameter for Method is NULL");
727 ret = MM_ERROR_SOUND_INTERNAL;
731 g_variant_get(params, "(siiiiiiiiibsi)", &filename, &tone, &repeat, &volume,
732 &vol_config, &priority, &session_type, &session_option, &pid, &handle_route, &enable_session, &stream_type, &stream_index);
734 debug_error("filename null");
735 ret = MM_ERROR_SOUND_INTERNAL;
738 ret = _MMSoundMgrIpcPlayFile(filename, tone, repeat, volume, vol_config, priority,
739 session_type, session_option, _get_sender_pid(invocation), handle_route, enable_session, &slotid, stream_type, stream_index);
742 if (ret == MM_ERROR_NONE) {
743 _method_call_return_value(invocation, g_variant_new("(i)", slotid));
745 _method_call_return_error(invocation, ret);
751 static void handle_method_play_file_start_with_stream_info(GDBusMethodInvocation* invocation)
753 gchar* filename = NULL;
754 char *stream_type = NULL;
755 gint32 ret = MM_ERROR_NONE, slotid = 0;
756 gint32 repeat = 0, volume = 0, priority = 0, pid = 0, handle_route =0, stream_index = 0;
757 GVariant *params = NULL;
761 if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
762 debug_error("Parameter for Method is NULL");
763 ret = MM_ERROR_SOUND_INTERNAL;
767 g_variant_get(params, "(siiiiisi)", &filename, &repeat, &volume,
768 &priority, &pid, &handle_route, &stream_type, &stream_index);
770 debug_error("filename null");
771 ret = MM_ERROR_SOUND_INTERNAL;
774 ret = _MMSoundMgrIpcPlayFileWithStreamInfo(filename, repeat, volume, priority,
775 _get_sender_pid(invocation), handle_route, &slotid, stream_type, stream_index);
778 if (ret == MM_ERROR_NONE) {
779 _method_call_return_value(invocation, g_variant_new("(i)", slotid));
781 _method_call_return_error(invocation, ret);
787 static void handle_method_play_dtmf(GDBusMethodInvocation* invocation)
789 int ret = MM_ERROR_NONE, slotid = 0;
790 int tone = 0, repeat = 0, volume = 0, vol_config = 0, session_type = 0, session_option = 0, pid = 0, stream_index = 0;
791 char* stream_type = NULL;
792 gboolean enable_session = 0;
793 GVariant *params = NULL;
797 if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
798 debug_error("Parameter for Method is NULL");
799 ret = MM_ERROR_SOUND_INTERNAL;
803 g_variant_get(params, "(iiiiiiibsi)", &tone, &repeat, &volume,
804 &vol_config, &session_type, &session_option, &pid, &enable_session, &stream_type, &stream_index);
805 debug_error("volume - %d", volume);
806 ret = _MMSoundMgrIpcPlayDTMF(tone, repeat, volume, vol_config,
807 session_type, session_option, _get_sender_pid(invocation), enable_session, &slotid, stream_type, stream_index);
810 if (ret == MM_ERROR_NONE) {
811 _method_call_return_value(invocation, g_variant_new("(i)", slotid));
813 _method_call_return_error(invocation, ret);
820 static void handle_method_play_dtmf_with_stream_info(GDBusMethodInvocation* invocation)
822 int ret = MM_ERROR_NONE, slotid = 0;
823 int tone = 0, repeat = 0, volume = 0, pid = 0, stream_index = 0;
824 char* stream_type = NULL;
825 GVariant *params = NULL;
829 if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
830 debug_error("Parameter for Method is NULL");
831 ret = MM_ERROR_SOUND_INTERNAL;
835 g_variant_get(params, "(iiiisi)", &tone, &repeat, &volume, &pid, &stream_type, &stream_index);
836 ret = _MMSoundMgrIpcPlayDTMFWithStreamInfo(tone, repeat, volume, _get_sender_pid(invocation), &slotid, stream_type, stream_index);
839 if (ret == MM_ERROR_NONE) {
840 _method_call_return_value(invocation, g_variant_new("(i)", slotid));
842 _method_call_return_error(invocation, ret);
848 static void handle_method_play_file_stop(GDBusMethodInvocation* invocation)
850 int ret = MM_ERROR_NONE;
852 GVariant *params = NULL;
856 if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
857 debug_error("Parameter for Method is NULL");
858 ret = MM_ERROR_SOUND_INTERNAL;
862 g_variant_get(params, "(i)", &handle);
863 ret = _MMSoundMgrIpcStop(handle);
866 if (ret == MM_ERROR_NONE) {
867 _method_call_return_value(invocation, g_variant_new("()"));
869 _method_call_return_error(invocation, ret);
875 static void handle_method_clear_focus(GDBusMethodInvocation* invocation)
877 int ret = MM_ERROR_NONE;
879 GVariant *params = NULL;
883 if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
884 debug_error("Parameter for Method is NULL");
885 ret = MM_ERROR_SOUND_INTERNAL;
889 g_variant_get(params, "(i)", &pid);
890 ret = _MMSoundMgrIpcClearFocus(pid);
893 if (ret == MM_ERROR_NONE) {
894 _method_call_return_value(invocation, g_variant_new("()"));
896 _method_call_return_error(invocation, ret);
902 static void handle_method_get_bt_a2dp_status(GDBusMethodInvocation* invocation)
904 int ret = MM_ERROR_NONE;
905 gboolean is_bt_on = FALSE;
906 gchar* bt_name = NULL;
910 // ret = MMSoundMgrPulseHandleIsBtA2DPOnReq(&is_bt_on, &bt_name);
913 if (ret == MM_ERROR_NONE) {
914 _method_call_return_value(invocation, g_variant_new("(bs)", is_bt_on, bt_name));
916 _method_call_return_error(invocation, ret);
925 static void handle_method_set_sound_path_for_active_device( GDBusMethodInvocation* invocation)
927 int ret = MM_ERROR_NONE;
928 int device_in = 0, device_out = 0;
929 GVariant *params = NULL;
933 if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
934 debug_error("Parameter for Method is NULL");
935 ret = MM_ERROR_SOUND_INTERNAL;
939 g_variant_get(params, "(ii)", &device_in, &device_out);
940 ret = __mm_sound_mgr_ipc_set_sound_path_for_active_device(device_in, device_out);
943 if (ret == MM_ERROR_NONE) {
944 _method_call_return_value(invocation, g_variant_new("()"));
946 _method_call_return_error(invocation, ret);
952 static void handle_method_get_audio_path(GDBusMethodInvocation* invocation)
954 int ret = MM_ERROR_NONE;
955 int device_in = 0, device_out = 0;
959 ret = __mm_sound_mgr_ipc_get_audio_path(&device_in, &device_out);
962 if (ret == MM_ERROR_NONE) {
963 _method_call_return_value(invocation, g_variant_new("(ii)", device_in, device_out));
965 _method_call_return_error(invocation, ret);
971 static void handle_method_get_connected_device_list(GDBusMethodInvocation* invocation)
973 int ret = MM_ERROR_NONE;
974 GVariant *params = NULL, *reply_v = NULL;
975 GVariantBuilder reply_builder;
977 int devices_num = 0, device_idx = 0;
978 mm_sound_device_t *device_list = NULL, *device_entry = NULL;
980 if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
981 debug_error("Parameter for Method is NULL");
982 ret = MM_ERROR_SOUND_INTERNAL;
986 g_variant_get(params, "(i)", &mask_flags);
987 debug_log("Get device list with device_flag %X", mask_flags);
988 if ((ret = __mm_sound_mgr_ipc_get_current_connected_device_list(mask_flags, &device_list, &devices_num))==MM_ERROR_NONE) {
989 g_variant_builder_init(&reply_builder, G_VARIANT_TYPE("(a(iiiis))"));
990 g_variant_builder_open(&reply_builder, G_VARIANT_TYPE("a(iiiis)"));
991 for (device_idx = 0; device_idx < devices_num; device_idx++) {
992 device_entry = &device_list[device_idx];
993 // debug_log("device(%d): id(%d), type(%d), io(%d), state(%d), name(%s) ", device_idx, device_entry->id, device_entry->type, device_entry->io_direction, device_entry->state, device_entry->name);
994 g_variant_builder_add(&reply_builder, "(iiiis)", device_entry->id, device_entry->type, device_entry->io_direction, device_entry->state, device_entry->name);
996 g_variant_builder_close(&reply_builder);
1000 if (ret == MM_ERROR_NONE) {
1001 _method_call_return_value(invocation, g_variant_builder_end(&reply_builder));
1002 debug_log("Reply Sent");
1004 _method_call_return_error(invocation, ret);
1008 /*********************** ASM METHODS ****************************/
1010 #ifdef SUPPORT_CONTAINER
1012 static char* _get_container_from_cookie(GVariant* cookie_data)
1014 char* container = NULL;
1016 char* cookie = NULL;
1019 cookie_len = g_variant_get_size(cookie_data);
1020 if (cookie_len != COOKIE_SIZE) {
1021 debug_error ("cookie_len = [%d]", cookie_len);
1025 ret = security_server_get_zone_by_cookie(g_variant_get_data(cookie_data), &container);
1026 if (ret == SECURITY_SERVER_API_SUCCESS) {
1027 debug_error ("success!!!! zone = [%s]", container);
1029 debug_error ("failed!!!! ret = [%d]", ret);
1034 #endif /* USE_SECURITY */
1035 #endif /* SUPPORT_CONTAINER */
1037 // TODO : Too many arguments..
1038 static void handle_method_asm_register_sound(GDBusMethodInvocation* invocation)
1040 int ret = MM_ERROR_NONE;
1041 int pid = 0, handle = 0, sound_event = 0, request_id = 0, sound_state = 0, resource = 0;
1042 int pid_r = 0, alloc_handle_r = 0, cmd_handle_r = 0, request_id_r = 0, sound_command_r = 0, sound_state_r = 0;
1043 GVariant *params = NULL;
1044 #ifdef SUPPORT_CONTAINER
1045 int container_pid = -1;
1046 char* container = NULL;
1048 GVariant* cookie_data;
1049 #endif /* USE_SECURITY */
1050 #endif /* SUPPORT_CONTAINER */
1054 if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
1055 debug_error("Parameter for Method is NULL");
1056 ret = MM_ERROR_SOUND_INTERNAL;
1060 #ifdef SUPPORT_CONTAINER
1062 g_variant_get(params, "(@ayiiiiii)", &cookie_data, &container_pid, &handle, &sound_event, &request_id, &sound_state, &resource);
1063 container = _get_container_from_cookie(cookie_data);
1064 ret = __mm_sound_mgr_ipc_asm_register_sound(_get_sender_pid(invocation), handle, sound_event, request_id, sound_state, resource,
1065 container, container_pid, &pid_r, &alloc_handle_r, &cmd_handle_r, &request_id_r, &sound_command_r, &sound_state_r);
1068 #else /* USE_SECURITY */
1069 g_variant_get(params, "(siiiiii)", &container, &container_pid, &handle, &sound_event, &request_id, &sound_state, &resource);
1070 ret = __mm_sound_mgr_ipc_asm_register_sound(_get_sender_pid(invocation), handle, sound_event, request_id, sound_state, resource,
1071 container, container_pid, &pid_r, &alloc_handle_r, &cmd_handle_r, &request_id_r, &sound_command_r, &sound_state_r);
1072 #endif /* USE_SECURITY */
1073 #else /* SUPPORT_CONTAINER */
1074 g_variant_get(params, "(iiiiii)", &pid, &handle, &sound_event, &request_id, &sound_state, &resource);
1075 ret = __mm_sound_mgr_ipc_asm_register_sound(_get_sender_pid(invocation), handle, sound_event, request_id, sound_state, resource,
1076 &pid_r, &alloc_handle_r, &cmd_handle_r, &request_id_r, &sound_command_r, &sound_state_r);
1077 #endif /* SUPPORT_CONTAINER */
1080 if (ret == MM_ERROR_NONE) {
1081 _method_call_return_value(invocation, g_variant_new("(iiiiii)", pid_r, alloc_handle_r, cmd_handle_r,
1082 request_id_r, sound_command_r, sound_state_r));
1084 _method_call_return_error(invocation, ret);
1090 static void handle_method_asm_unregister_sound(GDBusMethodInvocation* invocation)
1092 int ret = MM_ERROR_NONE;
1093 int pid = 0, handle = 0, sound_event = 0, request_id = 0, sound_state = 0, resource = 0;
1094 GVariant *params = NULL;
1098 if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
1099 debug_error("Parameter for Method is NULL");
1100 ret = MM_ERROR_SOUND_INTERNAL;
1104 g_variant_get(params, "(iiiiii)", &pid, &handle, &sound_event, &request_id, &sound_state, &resource);
1105 ret = __mm_sound_mgr_ipc_asm_unregister_sound(_get_sender_pid(invocation), handle, sound_event, request_id, sound_state, resource);
1108 if (ret == MM_ERROR_NONE) {
1109 _method_call_return_value(invocation, g_variant_new("()"));
1111 _method_call_return_error(invocation, ret);
1117 static void handle_method_asm_register_watcher(GDBusMethodInvocation* invocation)
1119 int ret = MM_ERROR_NONE;
1120 int pid = 0, handle = 0, sound_event = 0, request_id = 0, sound_state = 0, resource = 0;
1121 int pid_r = 0, alloc_handle_r = 0, cmd_handle_r = 0, request_id_r = 0, sound_command_r = 0, sound_state_r = 0;
1122 GVariant *params = NULL;
1123 #ifdef SUPPORT_CONTAINER
1124 int container_pid = -1;
1125 char* container = NULL;
1127 GVariant* cookie_data;
1128 #endif /* USE_SECURITY */
1129 #endif /* SUPPORT_CONTAINER */
1133 if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
1134 debug_error("Parameter for Method is NULL");
1135 ret = MM_ERROR_SOUND_INTERNAL;
1139 #ifdef SUPPORT_CONTAINER
1141 g_variant_get(params, "(@ayiiiiii)", &cookie_data, &container_pid, &handle, &sound_event, &request_id, &sound_state, &resource);
1142 container = _get_container_from_cookie(cookie_data);
1143 ret = __mm_sound_mgr_ipc_asm_register_watcher(_get_sender_pid(invocation), handle, sound_event, request_id, sound_state, resource,
1144 container, container_pid, &pid_r, &alloc_handle_r, &cmd_handle_r, &request_id_r, &sound_command_r, &sound_state_r);
1147 #else /* USE_SECURITY */
1148 g_variant_get(params, "(siiiiii)", &container, &container_pid, &handle, &sound_event, &request_id, &sound_state, &resource);
1149 ret = __mm_sound_mgr_ipc_asm_register_watcher(_get_sender_pid(invocation), handle, sound_event, request_id, sound_state, resource,
1150 container, container_pid, &pid_r, &alloc_handle_r, &cmd_handle_r, &request_id_r, &sound_command_r, &sound_state_r);
1151 #endif /* USE_SECURITY */
1152 #else /* SUPPORT_CONTAINER */
1153 g_variant_get(params, "(iiiiii)", &pid, &handle, &sound_event, &request_id, &sound_state, &resource);
1154 ret = __mm_sound_mgr_ipc_asm_register_watcher(_get_sender_pid(invocation), handle, sound_event, request_id, sound_state, resource,
1155 &pid_r, &alloc_handle_r, &cmd_handle_r, &request_id_r, &sound_command_r, &sound_state_r);
1156 #endif /* SUPPORT_CONTAINER */
1159 if (ret == MM_ERROR_NONE) {
1160 _method_call_return_value(invocation, g_variant_new("(iiiiii)", pid_r, alloc_handle_r, cmd_handle_r,
1161 request_id_r, sound_command_r, sound_state_r));
1163 _method_call_return_error(invocation, ret);
1169 static void handle_method_asm_unregister_watcher(GDBusMethodInvocation* invocation)
1171 int ret = MM_ERROR_NONE;
1172 int pid = 0, handle = 0, sound_event = 0, request_id = 0, sound_state = 0, resource = 0;
1173 GVariant *params = NULL;
1177 if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
1178 debug_error("Parameter for Method is NULL");
1179 ret = MM_ERROR_SOUND_INTERNAL;
1183 g_variant_get(params, "(iiiiii)", &pid, &handle, &sound_event, &request_id, &sound_state, &resource);
1184 ret = __mm_sound_mgr_ipc_asm_unregister_watcher(_get_sender_pid(invocation), handle, sound_event, request_id, sound_state, resource);
1187 if (ret == MM_ERROR_NONE) {
1188 _method_call_return_value(invocation, g_variant_new("()"));
1190 _method_call_return_error(invocation, ret);
1196 static void handle_method_asm_get_mystate(GDBusMethodInvocation* invocation)
1198 int ret = MM_ERROR_NONE;
1199 int pid = 0, handle = 0, sound_event = 0, request_id = 0, sound_state = 0, resource = 0;
1200 int pid_r = 0, alloc_handle_r = 0, cmd_handle_r = 0, request_id_r = 0, sound_command_r = 0, sound_state_r = 0;
1201 GVariant *params = NULL;
1205 if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
1206 debug_error("Parameter for Method is NULL");
1207 ret = MM_ERROR_SOUND_INTERNAL;
1211 g_variant_get(params, "(iiiiii)", &pid, &handle, &sound_event, &request_id, &sound_state, &resource);
1212 ret = __mm_sound_mgr_ipc_asm_get_mystate(_get_sender_pid(invocation), handle, sound_event, request_id, sound_state, resource,
1213 &pid_r, &alloc_handle_r, &cmd_handle_r, &request_id_r, &sound_state_r);
1216 if (ret == MM_ERROR_NONE) {
1217 _method_call_return_value(invocation, g_variant_new("(iiiii)", pid_r, alloc_handle_r, cmd_handle_r,
1218 request_id_r, sound_state_r));
1220 _method_call_return_error(invocation, ret);
1226 static void handle_method_asm_set_state(GDBusMethodInvocation* invocation)
1228 int ret = MM_ERROR_NONE;
1229 int pid = 0, handle = 0, sound_event = 0, request_id = 0, sound_state = 0, resource = 0;
1230 int pid_r = 0, alloc_handle_r = 0, cmd_handle_r = 0, request_id_r = 0, sound_command_r = 0, sound_state_r = 0, error_code_r = 0;
1231 GVariant *params = NULL;
1235 if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
1236 debug_error("Parameter for Method is NULL");
1237 ret = MM_ERROR_SOUND_INTERNAL;
1241 g_variant_get(params, "(iiiiii)", &pid, &handle, &sound_event, &request_id, &sound_state, &resource);
1242 ret = __mm_sound_mgr_ipc_asm_set_state(_get_sender_pid(invocation), handle, sound_event, request_id, sound_state, resource,
1243 &pid_r, &alloc_handle_r, &cmd_handle_r, &request_id_r, &sound_command_r, &sound_state_r, &error_code_r);
1246 if (ret == MM_ERROR_NONE) {
1247 _method_call_return_value(invocation, g_variant_new("(iiiiiii)", pid_r, alloc_handle_r, cmd_handle_r,
1248 request_id_r, sound_command_r, sound_state_r, error_code_r));
1250 _method_call_return_error(invocation, ret);
1256 static void handle_method_asm_get_state(GDBusMethodInvocation* invocation)
1258 int ret = MM_ERROR_NONE;
1259 int pid = 0, handle = 0, sound_event = 0, request_id = 0, sound_state = 0, resource = 0;
1260 int pid_r = 0, alloc_handle_r = 0, cmd_handle_r = 0, request_id_r = 0, sound_command_r = 0, sound_state_r = 0;
1261 GVariant *params = NULL;
1265 if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
1266 debug_error("Parameter for Method is NULL");
1267 ret = MM_ERROR_SOUND_INTERNAL;
1271 g_variant_get(params, "(iiiiii)", &pid, &handle, &sound_event, &request_id, &sound_state, &resource);
1272 ret = __mm_sound_mgr_ipc_asm_get_state(pid, handle, sound_event, request_id, sound_state, resource,
1273 &pid_r, &alloc_handle_r, &cmd_handle_r, &request_id_r, &sound_state_r);
1276 if (ret == MM_ERROR_NONE) {
1277 _method_call_return_value(invocation, g_variant_new("(iiiii)", pid_r, alloc_handle_r, cmd_handle_r,
1278 request_id_r, sound_state_r));
1280 _method_call_return_error(invocation, ret);
1286 static void handle_method_asm_set_subsession(GDBusMethodInvocation* invocation)
1288 int ret = MM_ERROR_NONE;
1289 int pid = 0, handle = 0, sound_event = 0, request_id = 0, sound_state = 0, resource = 0;
1290 int pid_r = 0, alloc_handle_r = 0, cmd_handle_r = 0, request_id_r = 0;
1291 GVariant *params = NULL;
1295 if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
1296 debug_error("Parameter for Method is NULL");
1297 ret = MM_ERROR_SOUND_INTERNAL;
1301 g_variant_get(params, "(iiiiii)", &pid, &handle, &sound_event, &request_id, &sound_state, &resource);
1302 ret = __mm_sound_mgr_ipc_asm_set_subsession(_get_sender_pid(invocation), handle, sound_event, request_id, sound_state, resource,
1303 &pid_r, &alloc_handle_r, &cmd_handle_r, &request_id_r);
1306 if (ret == MM_ERROR_NONE) {
1307 _method_call_return_value(invocation, g_variant_new("(iiii)", pid_r, alloc_handle_r, cmd_handle_r,
1310 _method_call_return_error(invocation, ret);
1316 static void handle_method_asm_get_subsession(GDBusMethodInvocation* invocation)
1318 int ret = MM_ERROR_NONE;
1319 int pid = 0, handle = 0, sound_event = 0, request_id = 0, sound_state = 0, resource = 0;
1320 int pid_r = 0, alloc_handle_r = 0, cmd_handle_r = 0, request_id_r = 0, sound_command_r = 0;
1321 GVariant *params = NULL;
1325 if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
1326 debug_error("Parameter for Method is NULL");
1327 ret = MM_ERROR_SOUND_INTERNAL;
1331 g_variant_get(params, "(iiiiii)", &pid, &handle, &sound_event, &request_id, &sound_state, &resource);
1332 ret = __mm_sound_mgr_ipc_asm_get_subsession(_get_sender_pid(invocation), handle, sound_event, request_id, sound_state, resource,
1333 &pid_r, &alloc_handle_r, &cmd_handle_r, &request_id_r, &sound_command_r);
1336 if (ret == MM_ERROR_NONE) {
1337 _method_call_return_value(invocation, g_variant_new("(iiiii)", pid_r, alloc_handle_r, cmd_handle_r,
1338 request_id_r, sound_command_r));
1340 _method_call_return_error(invocation, ret);
1346 static void handle_method_asm_set_subevent(GDBusMethodInvocation* invocation)
1348 int ret = MM_ERROR_NONE;
1349 int pid = 0, handle = 0, sound_event = 0, request_id = 0, sound_state = 0, resource = 0;
1350 int pid_r = 0, alloc_handle_r = 0, cmd_handle_r = 0, request_id_r = 0, sound_command_r = 0, sound_state_r = 0;
1351 GVariant *params = NULL;
1355 if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
1356 debug_error("Parameter for Method is NULL");
1357 ret = MM_ERROR_SOUND_INTERNAL;
1361 g_variant_get(params, "(iiiiii)", &pid, &handle, &sound_event, &request_id, &sound_state, &resource);
1362 ret = __mm_sound_mgr_ipc_asm_set_subevent(_get_sender_pid(invocation), handle, sound_event, request_id, sound_state, resource,
1363 &pid_r, &alloc_handle_r, &cmd_handle_r, &request_id_r, &sound_command_r, &sound_state_r);
1366 if (ret == MM_ERROR_NONE) {
1367 _method_call_return_value(invocation, g_variant_new("(iiiiii)", pid_r, alloc_handle_r, cmd_handle_r,
1368 request_id_r, sound_command_r, sound_state_r));
1370 _method_call_return_error(invocation, ret);
1376 static void handle_method_asm_get_subevent(GDBusMethodInvocation* invocation)
1378 int ret = MM_ERROR_NONE;
1379 int pid = 0, handle = 0, sound_event = 0, request_id = 0, sound_state = 0, resource = 0;
1380 int pid_r = 0, alloc_handle_r = 0, cmd_handle_r = 0, request_id_r = 0, sound_command_r = 0;
1381 GVariant *params = NULL;
1385 if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
1386 debug_error("Parameter for Method is NULL");
1387 ret = MM_ERROR_SOUND_INTERNAL;
1391 g_variant_get(params, "(iiiiii)", &pid, &handle, &sound_event, &request_id, &sound_state, &resource);
1392 ret = __mm_sound_mgr_ipc_asm_get_subevent(_get_sender_pid(invocation), handle, sound_event, request_id, sound_state, resource,
1393 &pid_r, &alloc_handle_r, &cmd_handle_r, &request_id_r, &sound_command_r);
1396 if (ret == MM_ERROR_NONE) {
1397 _method_call_return_value(invocation, g_variant_new("(iiiii)", pid_r, alloc_handle_r, cmd_handle_r,
1398 request_id_r, sound_command_r ));
1400 _method_call_return_error(invocation, ret);
1406 static void handle_method_asm_set_session_option(GDBusMethodInvocation* invocation)
1408 int ret = MM_ERROR_NONE;
1409 int pid = 0, handle = 0, sound_event = 0, request_id = 0, sound_state = 0, resource = 0;
1410 int pid_r = 0, alloc_handle_r = 0, cmd_handle_r = 0, request_id_r = 0, sound_command_r = 0, error_code_r = 0;
1411 GVariant *params = NULL;
1415 if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
1416 debug_error("Parameter for Method is NULL");
1417 ret = MM_ERROR_SOUND_INTERNAL;
1421 g_variant_get(params, "(iiiiii)", &pid, &handle, &sound_event, &request_id, &sound_state, &resource);
1422 ret = __mm_sound_mgr_ipc_asm_set_session_option(_get_sender_pid(invocation), handle, sound_event, request_id, sound_state, resource,
1423 &pid_r, &alloc_handle_r, &cmd_handle_r, &request_id_r, &sound_command_r, &error_code_r);
1426 if (ret == MM_ERROR_NONE) {
1427 _method_call_return_value(invocation, g_variant_new("(iiiiii)", pid_r, alloc_handle_r, cmd_handle_r,
1428 request_id_r, sound_command_r, error_code_r ));
1430 _method_call_return_error(invocation, ret);
1436 static void handle_method_asm_get_session_option(GDBusMethodInvocation* invocation)
1438 int ret = MM_ERROR_NONE;
1439 int pid = 0, handle = 0, sound_event = 0, request_id = 0, sound_state = 0, resource = 0;
1440 int pid_r = 0, alloc_handle_r = 0, cmd_handle_r = 0, request_id_r = 0, sound_command_r = 0, option_flag_r = 0;
1441 GVariant *params = NULL;
1445 if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
1446 debug_error("Parameter for Method is NULL");
1447 ret = MM_ERROR_SOUND_INTERNAL;
1451 g_variant_get(params, "(iiiiii)", &pid, &handle, &sound_event, &request_id, &sound_state, &resource);
1452 ret = __mm_sound_mgr_ipc_asm_get_session_option(_get_sender_pid(invocation), handle, sound_event, request_id, sound_state, resource,
1453 &pid_r, &alloc_handle_r, &cmd_handle_r, &request_id_r, &sound_command_r, &option_flag_r);
1456 if (ret == MM_ERROR_NONE) {
1457 _method_call_return_value(invocation, g_variant_new("(iiiiii)", pid_r, alloc_handle_r, cmd_handle_r,
1458 request_id_r, sound_command_r, option_flag_r ));
1460 _method_call_return_error(invocation, ret);
1466 static void handle_method_asm_reset_resume_tag(GDBusMethodInvocation* invocation)
1468 int ret = MM_ERROR_NONE;
1469 int pid = 0, handle = 0, sound_event = 0, request_id = 0, sound_state = 0, resource = 0;
1470 int pid_r = 0, alloc_handle_r = 0, cmd_handle_r = 0, request_id_r = 0, sound_command_r = 0, sound_state_r = 0;
1471 GVariant *params = NULL;
1475 if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
1476 debug_error("Parameter for Method is NULL");
1477 ret = MM_ERROR_SOUND_INTERNAL;
1481 g_variant_get(params, "(iiiiii)", &pid, &handle, &sound_event, &request_id, &sound_state, &resource);
1482 ret = __mm_sound_mgr_ipc_asm_reset_resume_tag(_get_sender_pid(invocation), handle, sound_event, request_id, sound_state, resource,
1483 &pid_r, &alloc_handle_r, &cmd_handle_r, &request_id_r, &sound_command_r, &sound_state_r);
1486 if (ret == MM_ERROR_NONE) {
1487 _method_call_return_value(invocation, g_variant_new("(iiiiii)", pid_r, alloc_handle_r, cmd_handle_r,
1488 request_id_r, sound_command_r, sound_state_r ));
1490 _method_call_return_error(invocation, ret);
1496 static void handle_method_asm_dump(GDBusMethodInvocation* invocation)
1499 int ret = MM_ERROR_NONE;
1500 int pid = 0, handle = 0, sound_event = 0, request_id = 0, sound_state = 0, resource = 0;
1501 GVariant *params = NULL;
1505 if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
1506 debug_error("Parameter for Method is NULL");
1507 ret = MM_ERROR_SOUND_INTERNAL;
1511 g_variant_get(params, "(iiiiii)", &pid, &handle, &sound_event, &request_id, &sound_state, &resource);
1512 ret = __mm_sound_mgr_ipc_asm_dump(_get_sender_pid(invocation), handle, sound_event, request_id, sound_state, resource);
1515 if (ret == MM_ERROR_NONE) {
1516 _method_call_return_value(invocation, g_variant_new("()"));
1518 _method_call_return_error(invocation, ret);
1524 /****************************************************************/
1527 static void handle_method_call(GDBusConnection *connection,
1528 const gchar *sender,
1529 const gchar *object_path,
1530 const gchar *interface_name,
1531 const gchar *method_name,
1532 GVariant *parameters,
1533 GDBusMethodInvocation *invocation,
1539 debug_error("Parameter Null");
1542 debug_log("Method Call, obj : %s, intf : %s, method : %s", object_path, interface_name, method_name);
1544 for (method_idx = 0; method_idx < METHOD_CALL_MAX; method_idx++) {
1545 if (!g_strcmp0(method_name, methods[method_idx].info.name)) {
1546 methods[method_idx].handler(invocation);
1552 static GVariant* handle_get_property(GDBusConnection *connection,
1553 const gchar *sender,
1554 const gchar *object_path,
1555 const gchar *interface_name,
1556 const gchar *property_name,
1560 debug_log("Get Property, obj : %s, intf : %s, prop : %s", object_path, interface_name, property_name);
1564 static gboolean handle_set_property(GDBusConnection *connection,
1565 const gchar *sender,
1566 const gchar *object_path,
1567 const gchar *interface_name,
1568 const gchar *property_name,
1573 debug_log("Set Property, obj : %s, intf : %s, prop : %s", object_path, interface_name, property_name);
1577 static const GDBusInterfaceVTable interface_vtable =
1580 handle_get_property,
1584 static void handle_signal_asm_emergent_exit(GVariant* params, gpointer user_data)
1586 int ret = MM_ERROR_NONE;
1587 int pid = 0, handle = 0, sound_event = 0, request_id = 0, sound_state = 0;
1592 debug_error("Invalid Parameters");
1596 g_variant_get(params, "(iiiii)", &pid, &handle, &sound_event, &request_id, &sound_state);
1597 ret = __mm_sound_mgr_ipc_asm_emergent_exit(pid, handle, sound_event, request_id, sound_state);
1599 if (ret == MM_ERROR_NONE)
1600 debug_error("ASM emergent exit, successfully handled");
1602 debug_error("ASM emergent exit, handle failed, ret : 0x%X", ret);
1607 static void handle_signal(GDBusConnection *connection,
1608 const gchar *sender_name,
1609 const gchar *object_path,
1610 const gchar *interface_name,
1611 const gchar *signal_name,
1615 if (!object_path || !interface_name || !signal_name) {
1616 debug_error("Invalid Parameters");
1620 debug_log("Got Signal : Object '%s, Interface '%s', Signal '%s'", object_path, interface_name, signal_name);
1622 if (!g_strcmp0(object_path, OBJECT_ASM)) {
1623 if (!g_strcmp0(interface_name, INTERFACE_ASM) && !g_strcmp0(signal_name, "EmergentExit")) {
1624 debug_log("handle signal '%s.%s'", interface_name, signal_name);
1625 handle_signal_asm_emergent_exit(params, user_data);
1627 debug_log("Unknown Signal '%s.%s'", interface_name, signal_name);
1630 debug_log("Unknown Object '%s'", object_path);
1635 static void on_bus_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data)
1639 debug_log("Bus Acquired (%s)", name);
1641 conn_g = connection;
1642 reg_id = g_dbus_connection_register_object(connection,
1643 OBJECT_SOUND_SERVER,
1644 introspection_data->interfaces[0],
1650 debug_error("Register object(%s) failed", OBJECT_SOUND_SERVER);
1654 subs_id = g_dbus_connection_signal_subscribe(connection, NULL, INTERFACE_ASM, "EmergentExit", OBJECT_ASM, \
1655 NULL, G_DBUS_SIGNAL_FLAGS_NONE, handle_signal, NULL, NULL );
1658 debug_error ("g_dbus_connection_signal_subscribe() failed ");
1663 static void on_name_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data)
1665 debug_log("Name Acquired (%s)", name);
1668 static void on_name_lost(GDBusConnection *connection, const gchar *name, gpointer user_data)
1670 debug_log("Name Lost (%s)", name);
1673 static int _mm_sound_mgr_dbus_own_name(GBusType bus_type, const char* wellknown_name, guint* owner_id)
1677 debug_log("Own name (%s) for sound-server", wellknown_name);
1679 oid = g_bus_own_name(bus_type, wellknown_name , G_BUS_NAME_OWNER_FLAGS_NONE,
1680 on_bus_acquired, on_name_acquired, on_name_lost, NULL, NULL);
1682 debug_error("Dbus own name failed");
1683 return MM_ERROR_SOUND_INTERNAL;
1688 return MM_ERROR_NONE;
1691 static void _mm_sound_mgr_dbus_unown_name(guint oid)
1693 debug_log("Unown name for Sound-Server");
1695 g_bus_unown_name(oid);
1699 /* not for mm-sound client */
1700 int mm_sound_mgr_ipc_dbus_send_signal_freeze (char* command, int pid)
1703 GDBusConnection *conn = NULL;
1706 if (command == NULL || pid <= 0) {
1707 debug_error ("invalid arguments [%s][%d]", command, pid);
1711 conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
1713 debug_error ("g_bus_get_sync() error (%s) ", err->message);
1718 ret = g_dbus_connection_emit_signal (conn,
1719 NULL, PROC_DBUS_OBJECT, PROC_DBUS_INTERFACE, PROC_DBUS_METHOD,
1720 g_variant_new ("(si)", command, pid),
1723 debug_error ("g_dbus_connection_emit_signal() error (%s) ", err->message);
1727 ret = g_dbus_connection_flush_sync(conn, NULL, &err);
1729 debug_error ("g_dbus_connection_flush_sync() error (%s) ", err->message);
1733 g_object_unref(conn);
1734 debug_msg ("sending [%s] for pid (%d) success", command, pid);
1740 g_object_unref(conn);
1744 int __mm_sound_mgr_ipc_dbus_notify_device_connected (mm_sound_device_t *device, gboolean is_connected)
1746 int ret = MM_ERROR_NONE;
1747 GVariantBuilder builder;
1748 GVariant* param = NULL;
1750 debug_log("Send Signal '%s'", signals[SIGNAL_DEVICE_CONNECTED]);
1752 g_variant_builder_init(&builder, G_VARIANT_TYPE("((iiiis)b)"));
1753 g_variant_builder_open(&builder, G_VARIANT_TYPE_TUPLE);
1754 g_variant_builder_add(&builder, "(iiiis)", device->id, device->type, device->io_direction, device->state, device->name);
1755 g_variant_builder_close(&builder);
1756 g_variant_builder_add(&builder, "b", is_connected);
1757 param = g_variant_builder_end(&builder);
1759 if ((ret = mm_sound_mgr_ipc_dbus_send_signal(SIGNAL_DEVICE_CONNECTED, param))!= MM_ERROR_NONE) {
1760 debug_error("Send device connected signal failed");
1763 debug_error("Build variant for dbus param failed");
1769 int __mm_sound_mgr_ipc_dbus_notify_device_info_changed (mm_sound_device_t *device, int changed_device_info_type)
1771 int ret = MM_ERROR_NONE;
1772 GVariantBuilder builder;
1773 GVariant* param = NULL;
1775 debug_log("Send Signal '%s'", signals[SIGNAL_DEVICE_INFO_CHANGED]);
1777 g_variant_builder_init(&builder, G_VARIANT_TYPE("((iiiis)i)"));
1778 g_variant_builder_open(&builder, G_VARIANT_TYPE_TUPLE);
1779 g_variant_builder_add(&builder, "(iiiis)", device->id, device->type, device->io_direction, device->state, device->name);
1780 g_variant_builder_close(&builder);
1781 g_variant_builder_add(&builder, "i", changed_device_info_type);
1782 param = g_variant_builder_end(&builder);
1784 if ((ret = mm_sound_mgr_ipc_dbus_send_signal(SIGNAL_DEVICE_INFO_CHANGED, param)) != MM_ERROR_NONE) {
1785 debug_error("Send device info changed signal failed");
1788 debug_error("Build variant for dbus param failed");
1794 int __mm_sound_mgr_ipc_dbus_notify_volume_changed(unsigned int vol_type, unsigned int value)
1796 int ret = MM_ERROR_NONE;
1797 GVariant* param = NULL;
1799 debug_log("Send Signal '%s'", signals[SIGNAL_VOLUME_CHANGED]);
1801 param = g_variant_new("(uu)", vol_type, value);
1803 if ((ret = mm_sound_mgr_ipc_dbus_send_signal(SIGNAL_VOLUME_CHANGED, param)) != MM_ERROR_NONE) {
1804 debug_error("Send device connected signal failed");
1807 debug_error("Build variant for dbus param failed");
1813 int __mm_sound_mgr_ipc_dbus_notify_play_file_end(int handle)
1815 int ret = MM_ERROR_NONE;
1816 GVariant* param = NULL;
1818 debug_log("Send Signal '%s'", signals[SIGNAL_PLAY_FILE_END]);
1820 param = g_variant_new("(i)", handle);
1822 if ((ret = mm_sound_mgr_ipc_dbus_send_signal(SIGNAL_PLAY_FILE_END, param)) != MM_ERROR_NONE) {
1823 debug_error("Send play file end for '%d' failed", handle);
1826 debug_error("Build variant for dbus param failed");
1832 int __mm_sound_mgr_ipc_dbus_notify_active_device_changed(int device_in, int device_out)
1834 return MM_ERROR_SOUND_INTERNAL;
1837 int __mm_sound_mgr_ipc_dbus_notify_available_device_changed(int device_in, int device_out, int available)
1839 return MM_ERROR_SOUND_INTERNAL;
1842 #define PA_BUS_NAME "org.pulseaudio.Server"
1843 #define PA_STREAM_MANAGER_OBJECT_PATH "/org/pulseaudio/StreamManager"
1844 #define PA_STREAM_MANAGER_INTERFACE "org.pulseaudio.StreamManager"
1845 #define PA_STREAM_MANAGER_METHOD_NAME_GET_STREAM_LIST "GetStreamList"
1846 int __mm_sound_mgr_ipc_dbus_get_stream_list(stream_list_t* stream_list)
1848 int ret = MM_ERROR_NONE;
1849 GVariant *result = NULL;
1850 GVariant *child = NULL;
1851 GDBusConnection *conn = NULL;
1857 conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
1859 LOGE("g_bus_get_sync() error (%s)", err->message);
1861 ret = MM_ERROR_SOUND_INTERNAL;
1864 result = g_dbus_connection_call_sync (conn,
1866 PA_STREAM_MANAGER_OBJECT_PATH,
1867 PA_STREAM_MANAGER_INTERFACE,
1868 PA_STREAM_MANAGER_METHOD_NAME_GET_STREAM_LIST,
1870 G_VARIANT_TYPE("(vv)"),
1871 G_DBUS_CALL_FLAGS_NONE,
1875 if (!result && err) {
1876 debug_error("g_dbus_connection_call_sync() error (%s)", err->message);
1877 ret = MM_ERROR_SOUND_INTERNAL;
1880 GVariant *item = NULL;
1881 child = g_variant_get_child_value(result, 0);
1882 item = g_variant_get_variant(child);
1885 g_variant_iter_init(&iter, item);
1886 while ((i < AVAIL_STREAMS_MAX) && g_variant_iter_loop(&iter, "&s", &name)) {
1887 debug_log ("name : %s", name);
1888 stream_list->stream_types[i++] = strdup(name);
1890 g_variant_iter_free (&iter);
1891 g_variant_unref (item);
1892 g_variant_unref (child);
1894 child = g_variant_get_child_value(result, 1);
1895 item = g_variant_get_variant(child);
1898 g_variant_iter_init(&iter, item);
1899 while ((i < AVAIL_STREAMS_MAX) && g_variant_iter_loop(&iter, "i", &priority)) {
1900 debug_log ("priority : %d", priority);
1901 stream_list->priorities[i++] = priority;
1903 g_variant_iter_free (&iter);
1904 g_variant_unref (item);
1905 g_variant_unref (child);
1907 g_variant_unref(result);
1909 g_object_unref(conn);
1914 int MMSoundMgrDbusInit(void)
1918 introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL);
1919 if (!introspection_data)
1920 return MM_ERROR_SOUND_INTERNAL;
1922 if (_mm_sound_mgr_dbus_own_name(G_BUS_TYPE_SYSTEM, BUS_NAME_SOUND_SERVER, &sound_server_owner_id) != MM_ERROR_NONE) {
1923 debug_error ("dbus own name for sound-server error\n");
1924 return MM_ERROR_SOUND_INTERNAL;
1929 return MM_ERROR_NONE;
1932 void MMSoundMgrDbusFini(void)
1936 _mm_sound_mgr_dbus_unown_name(sound_server_owner_id);
1937 g_dbus_node_info_unref (introspection_data);