4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Seungbae Shin <seungbae.shin@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
27 #include <sys/types.h>
36 #include <mm_message.h>
37 #include <mm_session_private.h>
39 #include "include/mm_sound_private.h"
40 #include "include/mm_sound.h"
41 #include "include/mm_sound_utils.h"
42 #include "include/mm_sound_client.h"
43 #include "include/mm_sound_pa_client.h"
44 #include "include/mm_ipc.h"
45 #include "include/mm_sound_common.h"
48 #define VOLUME_MAX_MULTIMEDIA 16
49 #define VOLUME_MAX_BASIC 8
50 #define VOLUME_MAX_SINGLE 1
53 #define MASTER_VOLUME_MAX 100
54 #define MASTER_VOLUME_MIN 0
58 static GList *g_subscribe_cb_list = NULL;
59 static pthread_mutex_t g_subscribe_cb_list_mutex = PTHREAD_MUTEX_INITIALIZER;
61 #define MM_SOUND_DBUS_BUS_NAME_PREPIX "org.tizen.MMSound"
62 #define MM_SOUND_DBUS_OBJECT_PATH "/org/tizen/MMSound"
63 #define MM_SOUND_DBUS_INTERFACE "org.tizen.mmsound"
65 GDBusConnection *g_dbus_conn_mmsound;
67 int g_dbus_signal_values[MM_SOUND_SIGNAL_MAX] = {0,};
69 const char* dbus_signal_name_str[] = {
70 "ReleaseInternalFocus",
73 typedef struct _subscribe_cb {
74 mm_sound_signal_name_t signal_type;
75 mm_sound_signal_callback callback;
81 static const char* _get_volume_str (volume_type_t type)
83 static const char *volume_type_str[VOLUME_TYPE_MAX] =
84 { "SYSTEM", "NOTIFICATION", "ALARM", "RINGTONE", "MEDIA", "CALL", "VOIP", "VOICE", "FIXED"};
86 return (type >= VOLUME_TYPE_SYSTEM && type < VOLUME_TYPE_MAX)? volume_type_str[type] : "Unknown";
89 static int _validate_volume(volume_type_t type, int value)
96 case VOLUME_TYPE_CALL:
97 case VOLUME_TYPE_VOIP:
98 if (value >= VOLUME_MAX_BASIC) {
102 case VOLUME_TYPE_SYSTEM:
103 case VOLUME_TYPE_MEDIA:
104 case VOLUME_TYPE_ALARM:
105 case VOLUME_TYPE_NOTIFICATION:
106 case VOLUME_TYPE_RINGTONE:
107 case VOLUME_TYPE_VOICE:
108 if (value >= VOLUME_MAX_MULTIMEDIA) {
120 int mm_sound_volume_remove_callback(volume_type_t type)
122 /* FIXME : Will be removed */
123 return MM_ERROR_NOT_SUPPORT_API;
127 int mm_sound_add_volume_changed_callback(mm_sound_volume_changed_cb func, void* user_data, unsigned int *subs_id)
129 int ret = MM_ERROR_NONE;
131 if (func == NULL || subs_id == NULL) {
132 debug_error("argument is not valid\n");
133 return MM_ERROR_INVALID_ARGUMENT;
136 ret = mm_sound_client_add_volume_changed_callback(func, user_data, subs_id);
138 debug_error("Can not add volume changed callback, ret = %x\n", ret);
145 int mm_sound_remove_volume_changed_callback(unsigned int subs_id)
147 int ret = MM_ERROR_NONE;
149 ret = mm_sound_client_remove_volume_changed_callback(subs_id);
151 debug_error("Can not remove volume changed callback, ret = %x\n", ret);
158 int mm_sound_volume_set_value(volume_type_t volume_type, const unsigned int volume_level)
160 int ret = MM_ERROR_NONE;
162 debug_msg("type = (%d)%s, value = %d", volume_type, _get_volume_str(volume_type), volume_level);
164 /* Check input param */
165 if (0 > _validate_volume(volume_type, (int)volume_level)) {
166 debug_error("invalid volume type %d, value %u\n", volume_type, volume_level);
167 return MM_ERROR_INVALID_ARGUMENT;
170 ret = mm_sound_util_volume_set_value_by_type(volume_type, volume_level);
171 if (ret == MM_ERROR_NONE) {
172 /* update shared memory value */
173 if(MM_ERROR_NONE != mm_sound_client_set_volume_by_type(volume_type, volume_level)) {
174 debug_error("Can not set volume to shared memory 0x%x\n", ret);
182 int mm_sound_volume_get_value(volume_type_t type, unsigned int *value)
184 int ret = MM_ERROR_NONE;
186 /* Check input param */
188 debug_error("invalid argument\n");
189 return MM_ERROR_INVALID_ARGUMENT;
191 if (type < 0 || type >= VOLUME_TYPE_MAX) {
192 debug_error("invalid volume type value %d\n", type);
193 return MM_ERROR_INVALID_ARGUMENT;
196 ret = mm_sound_util_volume_get_value_by_type(type, value);
198 debug_msg("returned %s = %d", _get_volume_str(type), *value);
203 int mm_sound_volume_primary_type_set(volume_type_t type)
205 int ret = MM_ERROR_NONE;
207 /* Check input param */
208 if(type < VOLUME_TYPE_UNKNOWN || type >= VOLUME_TYPE_MAX) {
209 debug_error("invalid argument\n");
210 return MM_ERROR_INVALID_ARGUMENT;
213 if (vconf_set_int(VCONFKEY_SOUND_PRIMARY_VOLUME_TYPE, type)) {
214 debug_error("could not set vconf for RIMARY_VOLUME_TYPE\n");
215 ret = MM_ERROR_SOUND_INTERNAL;
217 debug_msg("set primary volume type forcibly %d(%s)", type, _get_volume_str(type));
224 int mm_sound_volume_primary_type_get(volume_type_t *type)
226 int ret = MM_ERROR_NONE;
227 int voltype = VOLUME_TYPE_RINGTONE;
229 /* Check input param */
231 debug_error("invalid argument\n");
232 return MM_ERROR_INVALID_ARGUMENT;
235 /* check force set */
236 if (vconf_get_int(VCONFKEY_SOUND_PRIMARY_VOLUME_TYPE, &voltype)) {
237 debug_error("could not get vconf for PRIMARY_VOLUME_TYPE\n");
238 ret = MM_ERROR_SOUND_INTERNAL;
240 debug_msg("get primary volume type %d(%s)", voltype, _get_volume_str(voltype));
247 ///////////////////////////////////
248 //// MMSOUND PLAY APIs
249 ///////////////////////////////////
250 static inline void _mm_sound_fill_play_param(MMSoundPlayParam *param, const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int priority, int handle_route)
252 param->filename = filename;
253 param->volume = 0; //volume value dose not effect anymore
254 param->callback = callback;
257 param->volume_config = volume_config;
258 param->priority = priority;
259 param->handle_route = handle_route;
263 int mm_sound_play_loud_solo_sound(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle)
265 MMSoundPlayParam param = { 0, };
267 /* FIXME : this function will be deleted */
268 _mm_sound_fill_play_param(¶m, filename, volume_config, callback, data, HANDLE_PRIORITY_NORMAL, MM_SOUND_HANDLE_ROUTE_USING_CURRENT);
269 return mm_sound_play_sound_ex(¶m, handle);
273 int mm_sound_play_sound(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle)
275 MMSoundPlayParam param = { 0, };
277 _mm_sound_fill_play_param(¶m, filename, volume_config, callback, data, HANDLE_PRIORITY_NORMAL, MM_SOUND_HANDLE_ROUTE_USING_CURRENT);
278 return mm_sound_play_sound_ex(¶m, handle);
282 int mm_sound_play_sound_ex(MMSoundPlayParam *param, int *handle)
287 /* Check input param */
289 debug_error("param is null\n");
290 return MM_ERROR_INVALID_ARGUMENT;
293 volume_type = MM_SOUND_VOLUME_CONFIG_TYPE(param->volume_config);
295 if (param->filename == NULL) {
296 debug_error("filename is NULL\n");
297 return MM_ERROR_SOUND_FILE_NOT_FOUND;
299 if (volume_type < 0 || volume_type >= VOLUME_TYPE_MAX) {
300 debug_error("Volume type is invalid %d\n", volume_type);
301 return MM_ERROR_INVALID_ARGUMENT;
304 debug_warning ("play sound : priority=[%d], handle_route=[%d]\n", param->priority, param->handle_route);
307 err = mm_sound_client_play_sound(param, 0, &lhandle);
309 debug_error("Failed to play sound\n");
313 /* Set handle to return */
317 debug_critical("The sound hadle cannot be get [%d]\n", lhandle);
320 debug_warning ("success : handle=[%p]\n", handle);
322 return MM_ERROR_NONE;
326 int mm_sound_play_sound_with_stream_info(const char *filename, char *stream_type, int stream_id, mm_sound_stop_callback_func callback, void *data, int *handle)
328 MMSoundPlayParam param = { 0, };
331 param.filename = filename;
332 param.volume = 0; //volume value dose not effect anymore
333 param.callback = callback;
336 param.priority = HANDLE_PRIORITY_NORMAL;
337 param.handle_route = MM_SOUND_HANDLE_ROUTE_USING_CURRENT;
339 err = mm_sound_client_play_sound_with_stream_info(¶m, handle, stream_type, stream_id);
341 debug_error("Failed to play sound\n");
345 debug_warning ("success : handle=[%p]\n", handle);
347 return MM_ERROR_NONE;
353 int mm_sound_stop_sound(int handle)
357 debug_warning ("enter : handle=[%p]\n", handle);
359 err = mm_sound_client_stop_sound(handle);
361 debug_error("Fail to stop sound\n");
364 debug_warning ("success : handle=[%p]\n", handle);
366 return MM_ERROR_NONE;
369 ///////////////////////////////////
370 //// MMSOUND TONE APIs
371 ///////////////////////////////////
373 int mm_sound_play_tone_ex (MMSoundTone_t num, int volume_config, const double volume, const int duration, int *handle, bool enable_session)
376 int err = MM_ERROR_NONE;
377 int volume_type = MM_SOUND_VOLUME_CONFIG_TYPE(volume_config);
381 /* Check input param */
383 debug_error("number is invalid %d\n", duration);
384 return MM_ERROR_INVALID_ARGUMENT;
386 if (num < MM_SOUND_TONE_DTMF_0 || num >= MM_SOUND_TONE_NUM) {
387 debug_error("TONE Value is invalid %d\n", num);
388 return MM_ERROR_INVALID_ARGUMENT;
390 if (volume_type < 0 || volume_type >= VOLUME_TYPE_MAX) {
391 debug_error("Volume type is invalid %d\n", volume_type);
392 return MM_ERROR_INVALID_ARGUMENT;
394 if (volume < 0.0 || volume > 1.0) {
395 debug_error("Volume Value is invalid %d\n", volume);
396 return MM_ERROR_INVALID_ARGUMENT;
400 debug_msg("Call MMSoundClientPlayTone\n");
401 err = mm_sound_client_play_tone(num, volume_config, volume, duration, &lhandle, enable_session);
403 debug_error("Failed to play sound\n");
407 /* Set handle to return */
411 debug_critical("The sound handle cannot be get [%d]\n", lhandle);
414 return MM_ERROR_NONE;
418 int mm_sound_play_tone_with_stream_info(MMSoundTone_t tone, char *stream_type, int stream_id, const double volume, const int duration, int *handle)
421 int err = MM_ERROR_NONE;
423 err = mm_sound_client_play_tone_with_stream_info(tone, stream_type, stream_id, volume, duration, handle);
425 debug_error("Failed to play sound\n");
435 int mm_sound_play_tone (MMSoundTone_t num, int volume_config, const double volume, const int duration, int *handle)
437 return mm_sound_play_tone_ex (num, volume_config, volume, duration, handle, true);
440 ///////////////////////////////////
441 //// MMSOUND ROUTING APIs
442 ///////////////////////////////////
445 int mm_sound_test(int a, int b, int* getv)
447 int ret = MM_ERROR_NONE;
449 debug_log("mm_sound_test enter");
451 debug_error("argu null");
452 return MM_ERROR_INVALID_ARGUMENT;
454 ret = mm_sound_client_test(a, b, getv);
456 debug_error("Can not mm sound test, ret = %x\n", ret);
458 debug_log("mm_sound_test leave");
464 int mm_sound_add_test_callback(mm_sound_test_cb func, void *user_data, unsigned int *subs_id)
466 int ret = MM_ERROR_NONE;
468 debug_log("mm_sound_add_test_callback enter");
469 if (!func || !subs_id) {
470 debug_error("argument is not valid\n");
471 return MM_ERROR_INVALID_ARGUMENT;
474 ret = mm_sound_client_add_test_callback(func, user_data, subs_id);
476 debug_error("Can not add test callback, ret = %x\n", ret);
478 debug_log("mm_sound_add_test_callback leave");
484 int mm_sound_remove_test_callback(unsigned int subs_id)
486 int ret = MM_ERROR_NONE;
488 debug_log("mm_sound_remove_test_callback enter");
489 ret = mm_sound_client_remove_test_callback(subs_id);
491 debug_error("Can not remove test callback, ret = %x\n", ret);
493 debug_log("mm_sound_remove_test_callback leave");
498 static int _convert_signal_name_str_to_enum (const char *name_str, mm_sound_signal_name_t *name_enum) {
499 int ret = MM_ERROR_NONE;
501 if (!name_str || !name_enum)
502 return MM_ERROR_INVALID_ARGUMENT;
504 if (!strncmp(name_str, "ReleaseInternalFocus", strlen("ReleaseInternalFocus"))) {
505 *name_enum = MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS;
507 ret = MM_ERROR_INVALID_ARGUMENT;
508 LOGE("not supported signal name(%s), err(0x%08x)", name_str, ret);
513 static void _dbus_signal_callback (const char *signal_name, int value, void *user_data)
515 int ret = MM_ERROR_NONE;
516 mm_sound_signal_name_t signal;
517 subscribe_cb_t *subscribe_cb = (subscribe_cb_t*)user_data;
524 ret = _convert_signal_name_str_to_enum(signal_name, &signal);
528 debug_msg ("signal_name[%s], value[%d], user_data[0x%x]\n", signal_name, value, user_data);
530 if (subscribe_cb->signal_type == MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS) {
531 /* Trigger the signal callback when it comes from the same process.
532 * In this case, the second integer argument is consist of
533 * |<-- pid (16bits) -->|<-- value (16bits) -->|,
534 * FYI, #define PID_MAX_DEFAULT (CONFIG_BASE_SMALL ? 0x1000 : 0x8000).
535 * In case of daemon usage, it uses the client_pid of subscribe_cb. */
536 if ((subscribe_cb->client_pid ? subscribe_cb->client_pid : getpid()) == (value >> 16)) {
537 subscribe_cb->callback(signal, (value & 0x0000FFFF), subscribe_cb->user_data);
540 subscribe_cb->callback(signal, value, subscribe_cb->user_data);
548 static void signal_callback(GDBusConnection *conn,
549 const gchar *sender_name,
550 const gchar *object_path,
551 const gchar *interface_name,
552 const gchar *signal_name,
553 GVariant *parameters,
557 const GVariantType* value_type;
559 debug_msg ("sender : %s, object : %s, interface : %s, signal : %s",
560 sender_name, object_path, interface_name, signal_name);
561 if (g_variant_is_of_type(parameters, G_VARIANT_TYPE("(i)"))) {
562 g_variant_get(parameters, "(i)",&value);
563 debug_msg(" - value : %d\n", value);
564 _dbus_signal_callback(signal_name, value, user_data);
566 value_type = g_variant_get_type(parameters);
567 debug_warning("signal type is %s", value_type);
572 int mm_sound_subscribe_signal(mm_sound_signal_name_t signal, unsigned int *subscribe_id, mm_sound_signal_callback callback, void *user_data)
574 int ret = MM_ERROR_NONE;
577 subscribe_cb_t *subscribe_cb = NULL;
581 MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_subscribe_cb_list_mutex, MM_ERROR_SOUND_INTERNAL);
583 if (signal < 0 || signal >= MM_SOUND_SIGNAL_MAX || !subscribe_id) {
584 debug_error ("invalid argument, signal(%d), subscribe_id(0x%p)", signal, subscribe_id);
585 ret = MM_ERROR_INVALID_ARGUMENT;
589 subscribe_cb = malloc(sizeof(subscribe_cb_t));
591 ret = MM_ERROR_SOUND_INTERNAL;
594 memset(subscribe_cb, 0, sizeof(subscribe_cb_t));
596 g_dbus_conn_mmsound = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
597 if (!g_dbus_conn_mmsound && err) {
598 debug_error ("g_bus_get_sync() error (%s) ", err->message);
600 ret = MM_ERROR_SOUND_INTERNAL;
604 subscribe_cb->signal_type = signal;
605 subscribe_cb->callback = callback;
606 subscribe_cb->user_data = user_data;
608 *subscribe_id = g_dbus_connection_signal_subscribe(g_dbus_conn_mmsound,
609 NULL, MM_SOUND_DBUS_INTERFACE, dbus_signal_name_str[signal], MM_SOUND_DBUS_OBJECT_PATH, NULL, 0,
610 signal_callback, subscribe_cb, NULL);
611 if (*subscribe_id == 0) {
612 debug_error ("g_dbus_connection_signal_subscribe() error (%d)", *subscribe_id);
613 ret = MM_ERROR_SOUND_INTERNAL;
617 subscribe_cb->id = *subscribe_id;
619 g_subscribe_cb_list = g_list_append(g_subscribe_cb_list, subscribe_cb);
620 if (g_subscribe_cb_list) {
621 debug_log("new subscribe_cb(0x%x)[user_callback(0x%x), subscribe_id(%u)] is added\n", subscribe_cb, subscribe_cb->callback, subscribe_cb->id);
623 debug_error("g_list_append failed\n");
624 ret = MM_ERROR_SOUND_INTERNAL;
628 MMSOUND_LEAVE_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
635 g_dbus_connection_signal_unsubscribe(g_dbus_conn_mmsound, *subscribe_id);
636 g_object_unref(g_dbus_conn_mmsound);
642 MMSOUND_LEAVE_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
648 int mm_sound_subscribe_signal_for_daemon(mm_sound_signal_name_t signal, int client_pid, unsigned int *subscribe_id, mm_sound_signal_callback callback, void *user_data)
650 int ret = MM_ERROR_NONE;
653 subscribe_cb_t *subscribe_cb = NULL;
657 MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_subscribe_cb_list_mutex, MM_ERROR_SOUND_INTERNAL);
659 if (signal < 0 || signal >= MM_SOUND_SIGNAL_MAX || !client_pid || !subscribe_id) {
660 debug_error ("invalid argument, signal(%d), client_pid(%d), subscribe_id(0x%p)", signal, client_pid, subscribe_id);
661 ret = MM_ERROR_INVALID_ARGUMENT;
665 subscribe_cb = malloc(sizeof(subscribe_cb_t));
667 ret = MM_ERROR_SOUND_INTERNAL;
670 memset(subscribe_cb, 0, sizeof(subscribe_cb_t));
672 g_dbus_conn_mmsound = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
673 if (!g_dbus_conn_mmsound && err) {
674 debug_error ("g_bus_get_sync() error (%s) ", err->message);
676 ret = MM_ERROR_SOUND_INTERNAL;
680 subscribe_cb->signal_type = signal;
681 subscribe_cb->callback = callback;
682 subscribe_cb->user_data = user_data;
683 subscribe_cb->client_pid = client_pid;
685 *subscribe_id = g_dbus_connection_signal_subscribe(g_dbus_conn_mmsound,
686 NULL, MM_SOUND_DBUS_INTERFACE, dbus_signal_name_str[signal], MM_SOUND_DBUS_OBJECT_PATH, NULL, 0,
687 signal_callback, subscribe_cb, NULL);
688 if (*subscribe_id == 0) {
689 debug_error ("g_dbus_connection_signal_subscribe() error (%d)", *subscribe_id);
690 ret = MM_ERROR_SOUND_INTERNAL;
694 subscribe_cb->id = *subscribe_id;
696 g_subscribe_cb_list = g_list_append(g_subscribe_cb_list, subscribe_cb);
697 if (g_subscribe_cb_list) {
698 debug_log("new subscribe_cb(0x%x)[user_callback(0x%x), subscribe_id(%u)] is added\n", subscribe_cb, subscribe_cb->callback, subscribe_cb->id);
700 debug_error("g_list_append failed\n");
701 ret = MM_ERROR_SOUND_INTERNAL;
705 MMSOUND_LEAVE_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
712 g_dbus_connection_signal_unsubscribe(g_dbus_conn_mmsound, *subscribe_id);
713 g_object_unref(g_dbus_conn_mmsound);
719 MMSOUND_LEAVE_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
725 void mm_sound_unsubscribe_signal(unsigned int subscribe_id)
728 subscribe_cb_t *subscribe_cb = NULL;
732 MMSOUND_ENTER_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
734 if (g_dbus_conn_mmsound && subscribe_id) {
735 g_dbus_connection_signal_unsubscribe(g_dbus_conn_mmsound, subscribe_id);
736 g_object_unref(g_dbus_conn_mmsound);
737 for (list = g_subscribe_cb_list; list != NULL; list = list->next) {
738 subscribe_cb = (subscribe_cb_t *)list->data;
739 if (subscribe_cb && (subscribe_cb->id == subscribe_id)) {
740 g_subscribe_cb_list = g_list_remove(g_subscribe_cb_list, subscribe_cb);
741 debug_log("subscribe_cb(0x%x) is removed\n", subscribe_cb);
747 MMSOUND_LEAVE_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
753 int mm_sound_send_signal(mm_sound_signal_name_t signal, int value)
755 int ret = MM_ERROR_NONE;
757 GDBusConnection *conn = NULL;
758 gboolean dbus_ret = TRUE;
762 MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_subscribe_cb_list_mutex, MM_ERROR_SOUND_INTERNAL);
764 if (signal < 0 || signal >= MM_SOUND_SIGNAL_MAX) {
765 debug_error ("invalid argument, signal(%d)", signal);
766 ret = MM_ERROR_INVALID_ARGUMENT;
770 conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
772 debug_error ("g_bus_get_sync() error (%s)", err->message);
773 ret = MM_ERROR_SOUND_INTERNAL;
777 g_dbus_signal_values[signal] = value;
778 if (signal == MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS) {
779 /* Trigger the signal callback when it comes from the same process.
780 * |<-- pid (16bits) -->|<-- value (16bits) -->|,
781 * FYI, #define PID_MAX_DEFAULT (CONFIG_BASE_SMALL ? 0x1000 : 0x8000). */
782 value |= ((int)getpid() << 16);
783 if ((_mm_session_util_write_information((int)getpid(), MM_SESSION_TYPE_REPLACED_BY_STREAM, 0)))
784 debug_error ("failed to _mm_session_util_write_information for MM_SESSION_TYPE_REPLACED_BY_STREAM");
786 dbus_ret = g_dbus_connection_emit_signal (conn,
787 NULL, MM_SOUND_DBUS_OBJECT_PATH, MM_SOUND_DBUS_INTERFACE, dbus_signal_name_str[signal],
788 g_variant_new ("(i)", value),
790 if (!dbus_ret && err) {
791 debug_error ("g_dbus_connection_emit_signal() error (%s)", err->message);
792 ret = MM_ERROR_SOUND_INTERNAL;
796 dbus_ret = g_dbus_connection_flush_sync(conn, NULL, &err);
797 if (!dbus_ret && err) {
798 debug_error ("g_dbus_connection_flush_sync() error (%s)", err->message);
799 ret = MM_ERROR_SOUND_INTERNAL;
803 g_object_unref(conn);
804 debug_msg ("sending signal[%s], value[%d] success", dbus_signal_name_str[signal], value);
806 MMSOUND_LEAVE_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
816 g_object_unref(conn);
818 MMSOUND_LEAVE_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
824 int mm_sound_get_signal_value(mm_sound_signal_name_t signal, int *value)
826 int ret = MM_ERROR_NONE;
830 MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_subscribe_cb_list_mutex, MM_ERROR_SOUND_INTERNAL);
832 *value = g_dbus_signal_values[signal];
834 MMSOUND_LEAVE_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
841 __attribute__ ((constructor))
842 static void _mm_sound_initialize(void)
844 mm_sound_client_initialize();
848 __attribute__ ((destructor))
849 static void _mm_sound_finalize(void)
851 mm_sound_client_finalize();