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 GList *g_subscribe_cb_list = NULL;
52 static pthread_mutex_t g_subscribe_cb_list_mutex = PTHREAD_MUTEX_INITIALIZER;
54 #define MM_SOUND_DBUS_BUS_NAME_PREPIX "org.tizen.MMSound"
55 #define MM_SOUND_DBUS_OBJECT_PATH "/org/tizen/MMSound"
56 #define MM_SOUND_DBUS_INTERFACE "org.tizen.mmsound"
58 GDBusConnection *g_dbus_conn_mmsound;
60 int g_dbus_signal_values[MM_SOUND_SIGNAL_MAX] = {0,};
62 const char* dbus_signal_name_str[] = {
63 "ReleaseInternalFocus",
66 typedef struct _subscribe_cb {
67 mm_sound_signal_name_t signal_type;
68 mm_sound_signal_callback callback;
74 static const char* _get_volume_str (volume_type_t type)
76 static const char *volume_type_str[VOLUME_TYPE_MAX] =
77 { "SYSTEM", "NOTIFICATION", "ALARM", "RINGTONE", "MEDIA", "CALL", "VOIP", "VOICE", "FIXED"};
79 return (type >= VOLUME_TYPE_SYSTEM && type < VOLUME_TYPE_MAX)? volume_type_str[type] : "Unknown";
82 static int _validate_volume(volume_type_t type, int value)
89 case VOLUME_TYPE_CALL:
90 case VOLUME_TYPE_VOIP:
91 if (value >= VOLUME_MAX_BASIC) {
95 case VOLUME_TYPE_SYSTEM:
96 case VOLUME_TYPE_MEDIA:
97 case VOLUME_TYPE_ALARM:
98 case VOLUME_TYPE_NOTIFICATION:
99 case VOLUME_TYPE_RINGTONE:
100 case VOLUME_TYPE_VOICE:
101 if (value >= VOLUME_MAX_MULTIMEDIA) {
113 int mm_sound_volume_remove_callback(volume_type_t type)
115 /* FIXME : Will be removed */
116 return MM_ERROR_NOT_SUPPORT_API;
120 int mm_sound_add_volume_changed_callback(mm_sound_volume_changed_cb func, void* user_data, unsigned int *subs_id)
122 int ret = MM_ERROR_NONE;
124 if (func == NULL || subs_id == NULL) {
125 debug_error("argument is not valid\n");
126 return MM_ERROR_INVALID_ARGUMENT;
129 ret = mm_sound_client_add_volume_changed_callback(func, user_data, subs_id);
131 debug_error("Can not add volume changed callback, ret = %x\n", ret);
138 int mm_sound_remove_volume_changed_callback(unsigned int subs_id)
140 int ret = MM_ERROR_NONE;
142 ret = mm_sound_client_remove_volume_changed_callback(subs_id);
144 debug_error("Can not remove volume changed callback, ret = %x\n", ret);
151 int mm_sound_volume_set_value(volume_type_t volume_type, const unsigned int volume_level)
153 int ret = MM_ERROR_NONE;
155 debug_msg("type = (%d)%s, value = %d", volume_type, _get_volume_str(volume_type), volume_level);
157 /* Check input param */
158 if (0 > _validate_volume(volume_type, (int)volume_level)) {
159 debug_error("invalid volume type %d, value %u\n", volume_type, volume_level);
160 return MM_ERROR_INVALID_ARGUMENT;
163 ret = mm_sound_util_volume_set_value_by_type(volume_type, volume_level);
164 if (ret == MM_ERROR_NONE) {
165 /* update shared memory value */
166 if(MM_ERROR_NONE != mm_sound_client_set_volume_by_type(volume_type, volume_level)) {
167 debug_error("Can not set volume to shared memory 0x%x\n", ret);
175 int mm_sound_volume_get_value(volume_type_t type, unsigned int *value)
177 int ret = MM_ERROR_NONE;
179 /* Check input param */
181 debug_error("invalid argument\n");
182 return MM_ERROR_INVALID_ARGUMENT;
184 if (type < 0 || type >= VOLUME_TYPE_MAX) {
185 debug_error("invalid volume type value %d\n", type);
186 return MM_ERROR_INVALID_ARGUMENT;
189 ret = mm_sound_util_volume_get_value_by_type(type, value);
191 debug_msg("returned %s = %d", _get_volume_str(type), *value);
196 int mm_sound_volume_primary_type_set(volume_type_t type)
198 int ret = MM_ERROR_NONE;
200 /* Check input param */
201 if(type < VOLUME_TYPE_UNKNOWN || type >= VOLUME_TYPE_MAX) {
202 debug_error("invalid argument\n");
203 return MM_ERROR_INVALID_ARGUMENT;
206 if (vconf_set_int(VCONFKEY_SOUND_PRIMARY_VOLUME_TYPE, type)) {
207 debug_error("could not set vconf for RIMARY_VOLUME_TYPE\n");
208 ret = MM_ERROR_SOUND_INTERNAL;
210 debug_msg("set primary volume type forcibly %d(%s)", type, _get_volume_str(type));
217 int mm_sound_volume_primary_type_get(volume_type_t *type)
219 int ret = MM_ERROR_NONE;
220 int voltype = VOLUME_TYPE_RINGTONE;
222 /* Check input param */
224 debug_error("invalid argument\n");
225 return MM_ERROR_INVALID_ARGUMENT;
228 /* check force set */
229 if (vconf_get_int(VCONFKEY_SOUND_PRIMARY_VOLUME_TYPE, &voltype)) {
230 debug_error("could not get vconf for PRIMARY_VOLUME_TYPE\n");
231 ret = MM_ERROR_SOUND_INTERNAL;
233 debug_msg("get primary volume type %d(%s)", voltype, _get_volume_str(voltype));
240 ///////////////////////////////////
241 //// MMSOUND PLAY APIs
242 ///////////////////////////////////
243 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)
245 param->filename = filename;
246 param->volume = 0; //volume value dose not effect anymore
247 param->callback = callback;
250 param->volume_config = volume_config;
251 param->priority = priority;
252 param->handle_route = handle_route;
256 int mm_sound_play_loud_solo_sound(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle)
258 MMSoundPlayParam param = { 0, };
260 /* FIXME : this function will be deleted */
261 _mm_sound_fill_play_param(¶m, filename, volume_config, callback, data, HANDLE_PRIORITY_NORMAL, MM_SOUND_HANDLE_ROUTE_USING_CURRENT);
262 return mm_sound_play_sound_ex(¶m, handle);
266 int mm_sound_play_sound(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle)
268 MMSoundPlayParam param = { 0, };
270 _mm_sound_fill_play_param(¶m, filename, volume_config, callback, data, HANDLE_PRIORITY_NORMAL, MM_SOUND_HANDLE_ROUTE_USING_CURRENT);
271 return mm_sound_play_sound_ex(¶m, handle);
275 int mm_sound_play_sound_ex(MMSoundPlayParam *param, int *handle)
280 /* Check input param */
282 debug_error("param is null\n");
283 return MM_ERROR_INVALID_ARGUMENT;
286 volume_type = MM_SOUND_VOLUME_CONFIG_TYPE(param->volume_config);
288 if (param->filename == NULL) {
289 debug_error("filename is NULL\n");
290 return MM_ERROR_SOUND_FILE_NOT_FOUND;
292 if (volume_type < 0 || volume_type >= VOLUME_TYPE_MAX) {
293 debug_error("Volume type is invalid %d\n", volume_type);
294 return MM_ERROR_INVALID_ARGUMENT;
297 debug_warning ("play sound : priority=[%d], handle_route=[%d]\n", param->priority, param->handle_route);
300 err = mm_sound_client_play_sound(param, 0, &lhandle);
302 debug_error("Failed to play sound\n");
306 /* Set handle to return */
310 debug_critical("The sound hadle cannot be get [%d]\n", lhandle);
313 debug_warning ("success : handle=[%p]\n", handle);
315 return MM_ERROR_NONE;
319 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)
321 MMSoundPlayParam param = { 0, };
324 param.filename = filename;
325 param.volume = 0; //volume value dose not effect anymore
326 param.callback = callback;
328 param.priority = HANDLE_PRIORITY_NORMAL;
329 param.handle_route = MM_SOUND_HANDLE_ROUTE_USING_CURRENT;
335 err = mm_sound_client_play_sound_with_stream_info(¶m, handle, stream_type, stream_id);
337 debug_error("Failed to play sound\n");
341 debug_warning ("success : handle=[%p]\n", handle);
343 return MM_ERROR_NONE;
349 int mm_sound_stop_sound(int handle)
353 debug_warning ("enter : handle=[%d]\n", handle);
355 err = mm_sound_client_stop_sound(handle);
357 debug_error("Fail to stop sound\n");
360 debug_warning ("success : handle=[%d]\n", handle);
362 return MM_ERROR_NONE;
365 ///////////////////////////////////
366 //// MMSOUND TONE APIs
367 ///////////////////////////////////
369 int mm_sound_play_tone_ex (MMSoundTone_t num, int volume_config, const double volume, const int duration, int *handle, bool enable_session)
372 int err = MM_ERROR_NONE;
373 int volume_type = MM_SOUND_VOLUME_CONFIG_TYPE(volume_config);
377 /* Check input param */
379 debug_error("number is invalid %d\n", duration);
380 return MM_ERROR_INVALID_ARGUMENT;
382 if (num < MM_SOUND_TONE_DTMF_0 || num >= MM_SOUND_TONE_NUM) {
383 debug_error("TONE Value is invalid %d\n", num);
384 return MM_ERROR_INVALID_ARGUMENT;
386 if (volume_type < 0 || volume_type >= VOLUME_TYPE_MAX) {
387 debug_error("Volume type is invalid %d\n", volume_type);
388 return MM_ERROR_INVALID_ARGUMENT;
390 if (volume < 0.0 || volume > 1.0) {
391 debug_error("Volume Value is invalid %d\n", volume);
392 return MM_ERROR_INVALID_ARGUMENT;
396 debug_msg("Call MMSoundClientPlayTone\n");
397 err = mm_sound_client_play_tone(num, volume_config, volume, duration, &lhandle, enable_session);
399 debug_error("Failed to play sound\n");
403 /* Set handle to return */
407 debug_critical("The sound handle cannot be get [%d]\n", lhandle);
410 return MM_ERROR_NONE;
414 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)
417 int err = MM_ERROR_NONE;
419 err = mm_sound_client_play_tone_with_stream_info(tone, stream_type, stream_id, volume, duration, handle);
421 debug_error("Failed to play sound\n");
431 int mm_sound_play_tone (MMSoundTone_t num, int volume_config, const double volume, const int duration, int *handle)
433 return mm_sound_play_tone_ex (num, volume_config, volume, duration, handle, true);
436 ///////////////////////////////////
437 //// MMSOUND ROUTING APIs
438 ///////////////////////////////////
441 int mm_sound_test(int a, int b, int* getv)
443 int ret = MM_ERROR_NONE;
445 debug_log("mm_sound_test enter");
447 debug_error("argu null");
448 return MM_ERROR_INVALID_ARGUMENT;
450 ret = mm_sound_client_test(a, b, getv);
452 debug_error("Can not mm sound test, ret = %x\n", ret);
454 debug_log("mm_sound_test leave");
460 int mm_sound_add_test_callback(mm_sound_test_cb func, void *user_data, unsigned int *subs_id)
462 int ret = MM_ERROR_NONE;
464 debug_log("mm_sound_add_test_callback enter");
465 if (!func || !subs_id) {
466 debug_error("argument is not valid\n");
467 return MM_ERROR_INVALID_ARGUMENT;
470 ret = mm_sound_client_add_test_callback(func, user_data, subs_id);
472 debug_error("Can not add test callback, ret = %x\n", ret);
474 debug_log("mm_sound_add_test_callback leave");
480 int mm_sound_remove_test_callback(unsigned int subs_id)
482 int ret = MM_ERROR_NONE;
484 debug_log("mm_sound_remove_test_callback enter");
485 ret = mm_sound_client_remove_test_callback(subs_id);
487 debug_error("Can not remove test callback, ret = %x\n", ret);
489 debug_log("mm_sound_remove_test_callback leave");
494 static int _convert_signal_name_str_to_enum (const char *name_str, mm_sound_signal_name_t *name_enum) {
495 int ret = MM_ERROR_NONE;
497 if (!name_str || !name_enum)
498 return MM_ERROR_INVALID_ARGUMENT;
500 if (!strncmp(name_str, "ReleaseInternalFocus", strlen("ReleaseInternalFocus"))) {
501 *name_enum = MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS;
503 ret = MM_ERROR_INVALID_ARGUMENT;
504 LOGE("not supported signal name(%s), err(0x%08x)", name_str, ret);
509 static void _dbus_signal_callback (const char *signal_name, int value, void *user_data)
511 int ret = MM_ERROR_NONE;
512 mm_sound_signal_name_t signal;
513 subscribe_cb_t *subscribe_cb = (subscribe_cb_t*)user_data;
520 ret = _convert_signal_name_str_to_enum(signal_name, &signal);
524 debug_msg("signal: name[%s], value[%d], user_data[%p], type[%d]\n",
525 signal_name, value, user_data, subscribe_cb->signal_type);
527 if (subscribe_cb->signal_type == MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS) {
528 /* Trigger the signal callback when it comes from the same process.
529 * In this case, the second integer argument is consist of
530 * |<-- pid (16bits) -->|<-- value (16bits) -->|,
531 * FYI, #define PID_MAX_DEFAULT (CONFIG_BASE_SMALL ? 0x1000 : 0x8000).
532 * In case of daemon usage, it uses the client_pid of subscribe_cb. */
533 debug_msg ("client_pid[%d], getpid[%d], value>>16[%d], callback[%p]\n",
534 subscribe_cb->client_pid, getpid(), (value >> 16), subscribe_cb);
535 if ((subscribe_cb->client_pid ? subscribe_cb->client_pid : getpid()) == (value >> 16))
536 subscribe_cb->callback(signal, (value & 0x0000FFFF), subscribe_cb->user_data);
538 debug_warning("not supported type[%d]\n", subscribe_cb->signal_type);
546 static void signal_callback(GDBusConnection *conn,
547 const gchar *sender_name,
548 const gchar *object_path,
549 const gchar *interface_name,
550 const gchar *signal_name,
551 GVariant *parameters,
555 const GVariantType* value_type;
557 debug_msg ("sender : %s, object : %s, interface : %s, signal : %s",
558 sender_name, object_path, interface_name, signal_name);
559 if (g_variant_is_of_type(parameters, G_VARIANT_TYPE("(i)"))) {
560 g_variant_get(parameters, "(i)",&value);
561 debug_msg(" - value : %d\n", value);
562 _dbus_signal_callback(signal_name, value, user_data);
564 value_type = g_variant_get_type(parameters);
565 debug_warning("signal type is %s", value_type);
570 int mm_sound_subscribe_signal(mm_sound_signal_name_t signal, unsigned int *subscribe_id, mm_sound_signal_callback callback, void *user_data)
572 int ret = MM_ERROR_NONE;
575 subscribe_cb_t *subscribe_cb = NULL;
579 MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_subscribe_cb_list_mutex, MM_ERROR_SOUND_INTERNAL);
581 if (signal < 0 || signal >= MM_SOUND_SIGNAL_MAX || !subscribe_id) {
582 debug_error ("invalid argument, signal(%d), subscribe_id(0x%p)", signal, subscribe_id);
583 ret = MM_ERROR_INVALID_ARGUMENT;
587 subscribe_cb = malloc(sizeof(subscribe_cb_t));
589 ret = MM_ERROR_SOUND_INTERNAL;
592 memset(subscribe_cb, 0, sizeof(subscribe_cb_t));
594 g_dbus_conn_mmsound = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
595 if (!g_dbus_conn_mmsound && err) {
596 debug_error ("g_bus_get_sync() error (%s) ", err->message);
598 ret = MM_ERROR_SOUND_INTERNAL;
602 subscribe_cb->signal_type = signal;
603 subscribe_cb->callback = callback;
604 subscribe_cb->user_data = user_data;
606 *subscribe_id = g_dbus_connection_signal_subscribe(g_dbus_conn_mmsound,
607 NULL, MM_SOUND_DBUS_INTERFACE, dbus_signal_name_str[signal], MM_SOUND_DBUS_OBJECT_PATH, NULL, 0,
608 signal_callback, subscribe_cb, NULL);
609 if (*subscribe_id == 0) {
610 debug_error ("g_dbus_connection_signal_subscribe() error (%d)", *subscribe_id);
611 ret = MM_ERROR_SOUND_INTERNAL;
615 subscribe_cb->id = *subscribe_id;
617 g_subscribe_cb_list = g_list_append(g_subscribe_cb_list, subscribe_cb);
618 if (g_subscribe_cb_list) {
619 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);
621 debug_error("g_list_append failed\n");
622 ret = MM_ERROR_SOUND_INTERNAL;
626 MMSOUND_LEAVE_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
633 g_dbus_connection_signal_unsubscribe(g_dbus_conn_mmsound, *subscribe_id);
634 g_object_unref(g_dbus_conn_mmsound);
640 MMSOUND_LEAVE_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
646 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)
648 int ret = MM_ERROR_NONE;
651 subscribe_cb_t *subscribe_cb = NULL;
655 MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_subscribe_cb_list_mutex, MM_ERROR_SOUND_INTERNAL);
657 if (signal < 0 || signal >= MM_SOUND_SIGNAL_MAX || !client_pid || !subscribe_id) {
658 debug_error ("invalid argument, signal(%d), client_pid(%d), subscribe_id(0x%p)", signal, client_pid, subscribe_id);
659 ret = MM_ERROR_INVALID_ARGUMENT;
663 subscribe_cb = malloc(sizeof(subscribe_cb_t));
665 ret = MM_ERROR_SOUND_INTERNAL;
668 memset(subscribe_cb, 0, sizeof(subscribe_cb_t));
670 g_dbus_conn_mmsound = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
671 if (!g_dbus_conn_mmsound && err) {
672 debug_error ("g_bus_get_sync() error (%s) ", err->message);
674 ret = MM_ERROR_SOUND_INTERNAL;
678 subscribe_cb->signal_type = signal;
679 subscribe_cb->callback = callback;
680 subscribe_cb->user_data = user_data;
681 subscribe_cb->client_pid = client_pid;
683 *subscribe_id = g_dbus_connection_signal_subscribe(g_dbus_conn_mmsound,
684 NULL, MM_SOUND_DBUS_INTERFACE, dbus_signal_name_str[signal], MM_SOUND_DBUS_OBJECT_PATH, NULL, 0,
685 signal_callback, subscribe_cb, NULL);
686 if (*subscribe_id == 0) {
687 debug_error ("g_dbus_connection_signal_subscribe() error (%d)", *subscribe_id);
688 ret = MM_ERROR_SOUND_INTERNAL;
692 subscribe_cb->id = *subscribe_id;
694 g_subscribe_cb_list = g_list_append(g_subscribe_cb_list, subscribe_cb);
695 if (g_subscribe_cb_list) {
696 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);
698 debug_error("g_list_append failed\n");
699 ret = MM_ERROR_SOUND_INTERNAL;
703 MMSOUND_LEAVE_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
710 g_dbus_connection_signal_unsubscribe(g_dbus_conn_mmsound, *subscribe_id);
711 g_object_unref(g_dbus_conn_mmsound);
717 MMSOUND_LEAVE_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
723 void mm_sound_unsubscribe_signal(unsigned int subscribe_id)
726 subscribe_cb_t *subscribe_cb = NULL;
730 MMSOUND_ENTER_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
732 if (g_dbus_conn_mmsound && subscribe_id) {
733 g_dbus_connection_signal_unsubscribe(g_dbus_conn_mmsound, subscribe_id);
734 g_object_unref(g_dbus_conn_mmsound);
735 for (list = g_subscribe_cb_list; list != NULL; list = list->next) {
736 subscribe_cb = (subscribe_cb_t *)list->data;
737 if (subscribe_cb && (subscribe_cb->id == subscribe_id)) {
738 g_subscribe_cb_list = g_list_remove(g_subscribe_cb_list, subscribe_cb);
739 debug_log("subscribe_cb(0x%x) is removed\n", subscribe_cb);
745 MMSOUND_LEAVE_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
751 int mm_sound_send_signal(mm_sound_signal_name_t signal, int value)
753 int ret = MM_ERROR_NONE;
755 GDBusConnection *conn = NULL;
756 gboolean dbus_ret = TRUE;
760 MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_subscribe_cb_list_mutex, MM_ERROR_SOUND_INTERNAL);
762 if (signal < 0 || signal >= MM_SOUND_SIGNAL_MAX) {
763 debug_error ("invalid argument, signal(%d)", signal);
764 ret = MM_ERROR_INVALID_ARGUMENT;
768 conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
770 debug_error ("g_bus_get_sync() error (%s)", err->message);
771 ret = MM_ERROR_SOUND_INTERNAL;
775 g_dbus_signal_values[signal] = value;
776 if (signal == MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS) {
777 /* Trigger the signal callback when it comes from the same process.
778 * |<-- pid (16bits) -->|<-- value (16bits) -->|,
779 * FYI, #define PID_MAX_DEFAULT (CONFIG_BASE_SMALL ? 0x1000 : 0x8000). */
780 value |= ((int)getpid() << 16);
781 if ((_mm_session_util_write_information((int)getpid(), MM_SESSION_TYPE_REPLACED_BY_STREAM, 0)))
782 debug_error ("failed to _mm_session_util_write_information for MM_SESSION_TYPE_REPLACED_BY_STREAM");
784 dbus_ret = g_dbus_connection_emit_signal (conn,
785 NULL, MM_SOUND_DBUS_OBJECT_PATH, MM_SOUND_DBUS_INTERFACE, dbus_signal_name_str[signal],
786 g_variant_new ("(i)", value),
788 if (!dbus_ret && err) {
789 debug_error ("g_dbus_connection_emit_signal() error (%s)", err->message);
790 ret = MM_ERROR_SOUND_INTERNAL;
794 dbus_ret = g_dbus_connection_flush_sync(conn, NULL, &err);
795 if (!dbus_ret && err) {
796 debug_error ("g_dbus_connection_flush_sync() error (%s)", err->message);
797 ret = MM_ERROR_SOUND_INTERNAL;
801 g_object_unref(conn);
802 debug_msg ("sending signal[%s], value[%d] success", dbus_signal_name_str[signal], value);
804 MMSOUND_LEAVE_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
814 g_object_unref(conn);
816 MMSOUND_LEAVE_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
822 int mm_sound_get_signal_value(mm_sound_signal_name_t signal, int *value)
824 int ret = MM_ERROR_NONE;
828 MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_subscribe_cb_list_mutex, MM_ERROR_SOUND_INTERNAL);
830 *value = g_dbus_signal_values[signal];
832 MMSOUND_LEAVE_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
839 __attribute__ ((constructor))
840 static void _mm_sound_initialize(void)
842 mm_sound_client_initialize();
846 __attribute__ ((destructor))
847 static void _mm_sound_finalize(void)
849 mm_sound_client_finalize();