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.
32 #include <mm_session_private.h>
34 #include "include/mm_sound_private.h"
35 #include "include/mm_sound_utils.h"
36 #include "include/mm_sound_client.h"
37 #include "include/mm_sound_pa_client.h"
38 #include "include/mm_sound_common.h"
41 #define VOLUME_MAX_MULTIMEDIA 16
42 #define VOLUME_MAX_BASIC 8
43 #define VOLUME_MAX_SINGLE 1
46 #define MASTER_VOLUME_MAX 100
47 #define MASTER_VOLUME_MIN 0
51 static pthread_mutex_t g_subscribe_cb_list_mutex = PTHREAD_MUTEX_INITIALIZER;
53 #define MM_SOUND_DBUS_BUS_NAME_PREPIX "org.tizen.MMSound"
54 #define MM_SOUND_DBUS_OBJECT_PATH "/org/tizen/MMSound"
55 #define MM_SOUND_DBUS_INTERFACE "org.tizen.mmsound"
57 static GDBusConnection *g_dbus_conn_mmsound;
58 static int g_dbus_signal_values[MM_SOUND_SIGNAL_MAX] = {0,};
59 static const char* dbus_signal_name_str[] = {
60 "ReleaseInternalFocus",
63 typedef struct _subscribe_cb {
64 mm_sound_signal_name_t signal_type;
65 mm_sound_signal_callback callback;
71 static const char* _get_volume_str (volume_type_t type)
73 static const char *volume_type_str[VOLUME_TYPE_MAX] =
74 { "SYSTEM", "NOTIFICATION", "ALARM", "RINGTONE", "MEDIA", "CALL", "VOIP", "VOICE", "FIXED"};
76 return (type >= VOLUME_TYPE_SYSTEM && type < VOLUME_TYPE_MAX)? volume_type_str[type] : "Unknown";
79 static int _validate_volume(volume_type_t type, int value)
86 case VOLUME_TYPE_CALL:
87 case VOLUME_TYPE_VOIP:
88 if (value >= VOLUME_MAX_BASIC) {
92 case VOLUME_TYPE_SYSTEM:
93 case VOLUME_TYPE_MEDIA:
94 case VOLUME_TYPE_ALARM:
95 case VOLUME_TYPE_NOTIFICATION:
96 case VOLUME_TYPE_RINGTONE:
97 case VOLUME_TYPE_VOICE:
98 if (value >= VOLUME_MAX_MULTIMEDIA) {
110 int mm_sound_volume_remove_callback(volume_type_t type)
112 /* FIXME : Will be removed */
113 return MM_ERROR_NOT_SUPPORT_API;
117 int mm_sound_add_volume_changed_callback(mm_sound_volume_changed_cb func, void* user_data, unsigned int *subs_id)
119 int ret = MM_ERROR_NONE;
121 if (func == NULL || subs_id == NULL) {
122 debug_error("argument is not valid\n");
123 return MM_ERROR_INVALID_ARGUMENT;
126 ret = mm_sound_client_add_volume_changed_callback(func, user_data, subs_id);
128 debug_error("Can not add volume changed callback, ret = %x\n", ret);
135 int mm_sound_remove_volume_changed_callback(unsigned int subs_id)
137 int ret = MM_ERROR_NONE;
139 ret = mm_sound_client_remove_volume_changed_callback(subs_id);
141 debug_error("Can not remove volume changed callback, ret = %x\n", ret);
148 int mm_sound_volume_set_value(volume_type_t volume_type, const unsigned int volume_level)
150 int ret = MM_ERROR_NONE;
152 debug_msg("type = (%d)%s, value = %d", volume_type, _get_volume_str(volume_type), volume_level);
154 /* Check input param */
155 if (0 > _validate_volume(volume_type, (int)volume_level)) {
156 debug_error("invalid volume type %d, value %u\n", volume_type, volume_level);
157 return MM_ERROR_INVALID_ARGUMENT;
160 ret = mm_sound_util_volume_set_value_by_type(volume_type, volume_level);
161 if (ret == MM_ERROR_NONE) {
162 /* update shared memory value */
163 if(MM_ERROR_NONE != mm_sound_client_set_volume_by_type(volume_type, volume_level)) {
164 debug_error("Can not set volume to shared memory 0x%x\n", ret);
172 int mm_sound_volume_get_value(volume_type_t type, unsigned int *value)
174 int ret = MM_ERROR_NONE;
176 /* Check input param */
178 debug_error("invalid argument\n");
179 return MM_ERROR_INVALID_ARGUMENT;
181 if (type < 0 || type >= VOLUME_TYPE_MAX) {
182 debug_error("invalid volume type value %d\n", type);
183 return MM_ERROR_INVALID_ARGUMENT;
186 ret = mm_sound_util_volume_get_value_by_type(type, value);
188 debug_msg("returned %s = %d", _get_volume_str(type), *value);
193 int mm_sound_volume_primary_type_set(volume_type_t type)
195 int ret = MM_ERROR_NONE;
197 /* Check input param */
198 if(type < VOLUME_TYPE_UNKNOWN || type >= VOLUME_TYPE_MAX) {
199 debug_error("invalid argument\n");
200 return MM_ERROR_INVALID_ARGUMENT;
203 if (vconf_set_int(VCONFKEY_SOUND_PRIMARY_VOLUME_TYPE, type)) {
204 debug_error("could not set vconf for RIMARY_VOLUME_TYPE\n");
205 ret = MM_ERROR_SOUND_INTERNAL;
207 debug_msg("set primary volume type forcibly %d(%s)", type, _get_volume_str(type));
214 int mm_sound_volume_primary_type_get(volume_type_t *type)
216 int ret = MM_ERROR_NONE;
217 int voltype = VOLUME_TYPE_RINGTONE;
219 /* Check input param */
221 debug_error("invalid argument\n");
222 return MM_ERROR_INVALID_ARGUMENT;
225 /* check force set */
226 if (vconf_get_int(VCONFKEY_SOUND_PRIMARY_VOLUME_TYPE, &voltype)) {
227 debug_error("could not get vconf for PRIMARY_VOLUME_TYPE\n");
228 ret = MM_ERROR_SOUND_INTERNAL;
230 debug_msg("get primary volume type %d(%s)", voltype, _get_volume_str(voltype));
238 int mm_sound_set_filter(const char *stream_type, const char *filter_name, const char *filter_parameters, const char *filter_group)
240 /* Check input param */
241 if (!stream_type || !filter_name) {
242 debug_error("invalid argument");
243 return MM_ERROR_INVALID_ARGUMENT;
245 if (!filter_parameters)
246 filter_parameters = "";
248 filter_group = "default";
250 debug_msg("stream_type(%s), filter_name(%s), filter_parameters(%s), filter_group(%s)", stream_type, filter_name, filter_parameters, filter_group);
252 return mm_sound_client_set_filter_by_type(stream_type, filter_name, filter_parameters, filter_group);
256 int mm_sound_unset_filter(const char *stream_type)
258 /* Check input param */
260 debug_error("invalid argument");
261 return MM_ERROR_INVALID_ARGUMENT;
264 debug_msg("stream_type(%s)", stream_type);
266 return mm_sound_client_unset_filter_by_type(stream_type);
270 int mm_sound_control_filter(const char *stream_type, const char *filter_name, const char *filter_controls)
272 /* Check input param */
273 if (!stream_type || !filter_name || !filter_controls) {
274 debug_error("invalid argument");
275 return MM_ERROR_INVALID_ARGUMENT;
278 debug_msg("stream_type(%s), filter_name(%s), filter_controls(%s)", stream_type, filter_name, filter_controls);
280 return mm_sound_client_control_filter_by_type(stream_type, filter_name, filter_controls);
283 ///////////////////////////////////
284 //// MMSOUND PLAY APIs
285 ///////////////////////////////////
286 static inline void _mm_sound_fill_play_param(MMSoundPlayParam *param, const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data)
288 param->filename = filename;
289 param->volume = 0; //volume value dose not effect anymore
290 param->callback = callback;
293 param->volume_config = volume_config;
297 int mm_sound_play_loud_solo_sound(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle)
299 MMSoundPlayParam param = { 0, };
301 /* FIXME : this function will be deleted */
302 _mm_sound_fill_play_param(¶m, filename, volume_config, callback, data);
303 return mm_sound_play_sound_ex(¶m, handle);
307 int mm_sound_play_sound(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle)
309 MMSoundPlayParam param = { 0, };
311 _mm_sound_fill_play_param(¶m, filename, volume_config, callback, data);
312 return mm_sound_play_sound_ex(¶m, handle);
316 int mm_sound_play_sound_ex(MMSoundPlayParam *param, int *handle)
321 /* Check input param */
323 debug_error("param is null\n");
324 return MM_ERROR_INVALID_ARGUMENT;
327 volume_type = MM_SOUND_VOLUME_CONFIG_TYPE(param->volume_config);
329 if (param->filename == NULL) {
330 debug_error("filename is NULL\n");
331 return MM_ERROR_SOUND_FILE_NOT_FOUND;
333 if (volume_type < 0 || volume_type >= VOLUME_TYPE_MAX) {
334 debug_error("Volume type is invalid %d\n", volume_type);
335 return MM_ERROR_INVALID_ARGUMENT;
339 err = mm_sound_client_play_sound(param, 0, &lhandle);
341 debug_error("Failed to play sound\n");
345 /* Set handle to return */
349 debug_critical("The sound hadle cannot be get [%d]\n", lhandle);
352 debug_warning ("success : handle=[%p]\n", handle);
354 return MM_ERROR_NONE;
358 int mm_sound_play_sound_with_stream_info(const char *filename, char *stream_type, int stream_id, unsigned int loop, mm_sound_stop_callback_func callback, void *data, int *handle)
360 MMSoundPlayParam param = { 0, };
363 param.filename = filename;
364 param.volume = 0; //volume value dose not effect anymore
365 param.callback = callback;
373 err = mm_sound_client_play_sound_with_stream_info(¶m, handle, stream_type, stream_id);
375 debug_error("Failed to play sound\n");
379 debug_warning ("success : handle=[%p]\n", handle);
381 return MM_ERROR_NONE;
387 int mm_sound_stop_sound(int handle)
391 debug_warning ("enter : handle=[%d]\n", handle);
393 err = mm_sound_client_stop_sound(handle);
395 debug_error("Fail to stop sound\n");
398 debug_warning ("success : handle=[%d]\n", handle);
400 return MM_ERROR_NONE;
403 ///////////////////////////////////
404 //// MMSOUND TONE APIs
405 ///////////////////////////////////
407 int mm_sound_play_tone_ex (MMSoundTone_t num, int volume_config, const double volume, const int duration, int *handle, bool enable_session)
410 int err = MM_ERROR_NONE;
411 int volume_type = MM_SOUND_VOLUME_CONFIG_TYPE(volume_config);
415 /* Check input param */
417 debug_error("number is invalid %d\n", duration);
418 return MM_ERROR_INVALID_ARGUMENT;
420 if (num < MM_SOUND_TONE_DTMF_0 || num >= MM_SOUND_TONE_NUM) {
421 debug_error("TONE Value is invalid %d\n", num);
422 return MM_ERROR_INVALID_ARGUMENT;
424 if (volume_type < 0 || volume_type >= VOLUME_TYPE_MAX) {
425 debug_error("Volume type is invalid %d\n", volume_type);
426 return MM_ERROR_INVALID_ARGUMENT;
428 if (volume < 0.0 || volume > 1.0) {
429 debug_error("Volume Value is invalid %d\n", volume);
430 return MM_ERROR_INVALID_ARGUMENT;
434 debug_msg("Call MMSoundClientPlayTone\n");
435 err = mm_sound_client_play_tone(num, volume_config, volume, duration, &lhandle, enable_session);
437 debug_error("Failed to play sound\n");
441 /* Set handle to return */
445 debug_critical("The sound handle cannot be get [%d]\n", lhandle);
448 return MM_ERROR_NONE;
452 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)
455 int err = MM_ERROR_NONE;
457 err = mm_sound_client_play_tone_with_stream_info(tone, stream_type, stream_id, volume, duration, handle);
459 debug_error("Failed to play sound\n");
469 int mm_sound_play_tone (MMSoundTone_t num, int volume_config, const double volume, const int duration, int *handle)
471 return mm_sound_play_tone_ex (num, volume_config, volume, duration, handle, true);
474 ///////////////////////////////////
475 //// MMSOUND ROUTING APIs
476 ///////////////////////////////////
479 int mm_sound_test(int a, int b, int* getv)
481 int ret = MM_ERROR_NONE;
483 debug_log("mm_sound_test enter");
485 debug_error("argu null");
486 return MM_ERROR_INVALID_ARGUMENT;
488 ret = mm_sound_client_test(a, b, getv);
490 debug_error("Can not mm sound test, ret = %x\n", ret);
492 debug_log("mm_sound_test leave");
498 int mm_sound_add_test_callback(mm_sound_test_cb func, void *user_data, unsigned int *subs_id)
500 int ret = MM_ERROR_NONE;
502 debug_log("mm_sound_add_test_callback enter");
503 if (!func || !subs_id) {
504 debug_error("argument is not valid\n");
505 return MM_ERROR_INVALID_ARGUMENT;
508 ret = mm_sound_client_add_test_callback(func, user_data, subs_id);
510 debug_error("Can not add test callback, ret = %x\n", ret);
512 debug_log("mm_sound_add_test_callback leave");
518 int mm_sound_remove_test_callback(unsigned int subs_id)
520 int ret = MM_ERROR_NONE;
522 debug_log("mm_sound_remove_test_callback enter");
523 ret = mm_sound_client_remove_test_callback(subs_id);
525 debug_error("Can not remove test callback, ret = %x\n", ret);
527 debug_log("mm_sound_remove_test_callback leave");
532 static int _convert_signal_name_str_to_enum (const char *name_str, mm_sound_signal_name_t *name_enum) {
533 int ret = MM_ERROR_NONE;
535 if (!name_str || !name_enum)
536 return MM_ERROR_INVALID_ARGUMENT;
538 if (!strncmp(name_str, "ReleaseInternalFocus", strlen("ReleaseInternalFocus"))) {
539 *name_enum = MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS;
541 ret = MM_ERROR_INVALID_ARGUMENT;
542 LOGE("not supported signal name(%s), err(0x%08x)", name_str, ret);
547 static void _dbus_signal_callback (const char *signal_name, int value, void *user_data)
549 int ret = MM_ERROR_NONE;
550 mm_sound_signal_name_t signal;
551 subscribe_cb_t *subscribe_cb = (subscribe_cb_t*)user_data;
558 ret = _convert_signal_name_str_to_enum(signal_name, &signal);
562 debug_msg("signal: name[%s], value[%d], user_data[%p], type[%d]\n",
563 signal_name, value, user_data, subscribe_cb->signal_type);
565 if (subscribe_cb->signal_type == MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS) {
566 /* Trigger the signal callback when it comes from the same process.
567 * In this case, the second integer argument is consist of
568 * |<-- pid (16bits) -->|<-- value (16bits) -->|,
569 * FYI, #define PID_MAX_DEFAULT (CONFIG_BASE_SMALL ? 0x1000 : 0x8000).
570 * In case of daemon usage, it uses the client_pid of subscribe_cb. */
571 debug_msg ("client_pid[%d], getpid[%d], value>>16[%d], callback[%p]\n",
572 subscribe_cb->client_pid, getpid(), (value >> 16), subscribe_cb);
573 if ((subscribe_cb->client_pid ? subscribe_cb->client_pid : getpid()) == (value >> 16))
574 subscribe_cb->callback(signal, (value & 0x0000FFFF), subscribe_cb->user_data);
576 debug_warning("not supported type[%d]\n", subscribe_cb->signal_type);
584 static void signal_callback(GDBusConnection *conn,
585 const gchar *sender_name,
586 const gchar *object_path,
587 const gchar *interface_name,
588 const gchar *signal_name,
589 GVariant *parameters,
593 const GVariantType* value_type;
595 debug_msg ("sender : %s, object : %s, interface : %s, signal : %s",
596 sender_name, object_path, interface_name, signal_name);
597 if (g_variant_is_of_type(parameters, G_VARIANT_TYPE("(i)"))) {
598 g_variant_get(parameters, "(i)",&value);
599 debug_msg(" - value : %d\n", value);
600 _dbus_signal_callback(signal_name, value, user_data);
602 value_type = g_variant_get_type(parameters);
603 debug_warning("signal type is %s", value_type);
608 int mm_sound_subscribe_signal(mm_sound_signal_name_t signal_type, unsigned int *subscribe_id,
609 mm_sound_signal_callback callback, void *user_data)
611 int ret = MM_ERROR_NONE;
614 subscribe_cb_t *subscribe_cb = NULL;
618 MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_subscribe_cb_list_mutex, MM_ERROR_SOUND_INTERNAL);
620 if (signal_type < 0 || signal_type >= MM_SOUND_SIGNAL_MAX || !subscribe_id) {
621 debug_error ("invalid argument, signal(%d), subscribe_id(%p)", signal_type, subscribe_id);
622 ret = MM_ERROR_INVALID_ARGUMENT;
626 subscribe_cb = malloc(sizeof(subscribe_cb_t));
628 ret = MM_ERROR_SOUND_INTERNAL;
631 memset(subscribe_cb, 0, sizeof(subscribe_cb_t));
632 subscribe_cb->signal_type = signal_type;
633 subscribe_cb->callback = callback;
634 subscribe_cb->user_data = user_data;
636 g_dbus_conn_mmsound = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
637 if (!g_dbus_conn_mmsound && err) {
638 debug_error ("g_bus_get_sync() error (%s) ", err->message);
640 ret = MM_ERROR_SOUND_INTERNAL;
643 subs_id = g_dbus_connection_signal_subscribe(g_dbus_conn_mmsound, NULL, MM_SOUND_DBUS_INTERFACE,
644 dbus_signal_name_str[signal_type], MM_SOUND_DBUS_OBJECT_PATH,
645 NULL, G_DBUS_SIGNAL_FLAGS_NONE, signal_callback,
648 debug_error ("g_dbus_connection_signal_subscribe() error (%d)", subs_id);
649 ret = MM_ERROR_SOUND_INTERNAL;
650 g_object_unref(g_dbus_conn_mmsound);
653 subscribe_cb->id = subs_id;
654 *subscribe_id = subs_id;
656 MMSOUND_LEAVE_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
666 MMSOUND_LEAVE_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
671 /* ToDo : Almost same as mm_sound_subscribe_signal, need to be merged */
673 int mm_sound_subscribe_signal_for_daemon(mm_sound_signal_name_t signal_type, int client_pid, unsigned int *subscribe_id,
674 mm_sound_signal_callback callback, void *user_data)
676 int ret = MM_ERROR_NONE;
679 subscribe_cb_t *subscribe_cb = NULL;
683 MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_subscribe_cb_list_mutex, MM_ERROR_SOUND_INTERNAL);
685 if (signal_type < 0 || signal_type >= MM_SOUND_SIGNAL_MAX || !client_pid || !subscribe_id) {
686 debug_error ("invalid argument, signal(%d), client_pid(%d), subscribe_id(%p)", signal_type, client_pid, subscribe_id);
687 ret = MM_ERROR_INVALID_ARGUMENT;
691 subscribe_cb = malloc(sizeof(subscribe_cb_t));
693 ret = MM_ERROR_SOUND_INTERNAL;
696 memset(subscribe_cb, 0, sizeof(subscribe_cb_t));
697 subscribe_cb->signal_type = signal_type;
698 subscribe_cb->callback = callback;
699 subscribe_cb->user_data = user_data;
700 subscribe_cb->client_pid = client_pid;
702 g_dbus_conn_mmsound = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
703 if (!g_dbus_conn_mmsound && err) {
704 debug_error ("g_bus_get_sync() error (%s) ", err->message);
706 ret = MM_ERROR_SOUND_INTERNAL;
709 subs_id = g_dbus_connection_signal_subscribe(g_dbus_conn_mmsound, NULL, MM_SOUND_DBUS_INTERFACE,
710 dbus_signal_name_str[signal_type], MM_SOUND_DBUS_OBJECT_PATH,
711 NULL, G_DBUS_SIGNAL_FLAGS_NONE, signal_callback,
714 debug_error ("g_dbus_connection_signal_subscribe() error (%d)", subs_id);
715 ret = MM_ERROR_SOUND_INTERNAL;
716 g_object_unref(g_dbus_conn_mmsound);
719 subscribe_cb->id = subs_id;
720 *subscribe_id = subs_id;
722 MMSOUND_LEAVE_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
732 MMSOUND_LEAVE_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
738 void mm_sound_unsubscribe_signal(unsigned int subscribe_id)
742 MMSOUND_ENTER_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
744 if (g_dbus_conn_mmsound && subscribe_id) {
745 g_dbus_connection_signal_unsubscribe(g_dbus_conn_mmsound, subscribe_id);
746 g_object_unref(g_dbus_conn_mmsound);
749 MMSOUND_LEAVE_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
755 int mm_sound_send_signal(mm_sound_signal_name_t signal_type, int value)
757 int ret = MM_ERROR_NONE;
759 GDBusConnection *conn = NULL;
760 gboolean dbus_ret = TRUE;
764 MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_subscribe_cb_list_mutex, MM_ERROR_SOUND_INTERNAL);
766 if (signal_type < 0 || signal_type >= MM_SOUND_SIGNAL_MAX) {
767 debug_error ("invalid argument, signal(%d)", signal_type);
768 ret = MM_ERROR_INVALID_ARGUMENT;
772 conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
774 debug_error ("g_bus_get_sync() error (%s)", err->message);
775 ret = MM_ERROR_SOUND_INTERNAL;
779 g_dbus_signal_values[signal_type] = value;
780 if (signal_type == MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS) {
781 /* Trigger the signal callback when it comes from the same process.
782 * |<-- pid (16bits) -->|<-- value (16bits) -->|,
783 * FYI, #define PID_MAX_DEFAULT (CONFIG_BASE_SMALL ? 0x1000 : 0x8000). */
784 value |= ((int)getpid() << 16);
785 if ((_mm_session_util_write_information((int)getpid(), MM_SESSION_TYPE_REPLACED_BY_STREAM, 0)))
786 debug_error ("failed to _mm_session_util_write_information for MM_SESSION_TYPE_REPLACED_BY_STREAM");
788 dbus_ret = g_dbus_connection_emit_signal (conn,
789 NULL, MM_SOUND_DBUS_OBJECT_PATH, MM_SOUND_DBUS_INTERFACE, dbus_signal_name_str[signal_type],
790 g_variant_new ("(i)", value),
792 if (!dbus_ret && err) {
793 debug_error ("g_dbus_connection_emit_signal() error (%s)", err->message);
794 ret = MM_ERROR_SOUND_INTERNAL;
798 dbus_ret = g_dbus_connection_flush_sync(conn, NULL, &err);
799 if (!dbus_ret && err) {
800 debug_error ("g_dbus_connection_flush_sync() error (%s)", err->message);
801 ret = MM_ERROR_SOUND_INTERNAL;
805 g_object_unref(conn);
806 debug_msg ("sending signal[%s], value[%d] success", dbus_signal_name_str[signal_type], value);
808 MMSOUND_LEAVE_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
818 g_object_unref(conn);
820 MMSOUND_LEAVE_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
826 int mm_sound_get_signal_value(mm_sound_signal_name_t signal_type, int *value)
828 int ret = MM_ERROR_NONE;
832 MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_subscribe_cb_list_mutex, MM_ERROR_SOUND_INTERNAL);
834 *value = g_dbus_signal_values[signal_type];
836 MMSOUND_LEAVE_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
843 __attribute__ ((constructor))
844 static void _mm_sound_initialize(void)
846 mm_sound_client_initialize();
850 __attribute__ ((destructor))
851 static void _mm_sound_finalize(void)
853 mm_sound_client_finalize();