int client_pid;
} subscribe_cb_t;
-static const char* _get_volume_str (volume_type_t type)
+static const char* _get_volume_str(volume_type_t type)
{
- static const char *volume_type_str[VOLUME_TYPE_MAX] =
- { "SYSTEM", "NOTIFICATION", "ALARM", "RINGTONE", "MEDIA", "CALL", "VOIP", "VOICE", "FIXED"};
+ static const char *volume_type_str[VOLUME_TYPE_MAX] = {
+ "SYSTEM", "NOTIFICATION", "ALARM", "RINGTONE", "MEDIA", "CALL", "VOIP", "VOICE", "FIXED"
+ };
- return (type >= VOLUME_TYPE_SYSTEM && type < VOLUME_TYPE_MAX)? volume_type_str[type] : "Unknown";
+ return (type >= VOLUME_TYPE_SYSTEM && type < VOLUME_TYPE_MAX) ? volume_type_str[type] : "Unknown";
}
static int _validate_volume(volume_type_t type, int value)
if (value < 0)
return -1;
- switch (type)
- {
+ switch (type) {
case VOLUME_TYPE_CALL:
case VOLUME_TYPE_VOIP:
if (value >= VOLUME_MAX_BASIC) {
int ret = MM_ERROR_NONE;
/* Check input param */
- if(type < VOLUME_TYPE_UNKNOWN || type >= VOLUME_TYPE_MAX) {
+ if (type < VOLUME_TYPE_UNKNOWN || type >= VOLUME_TYPE_MAX) {
debug_error("invalid argument");
return MM_ERROR_INVALID_ARGUMENT;
}
int voltype = VOLUME_TYPE_RINGTONE;
/* Check input param */
- if(type == NULL) {
+ if (type == NULL) {
debug_error("invalid argument");
return MM_ERROR_INVALID_ARGUMENT;
}
debug_critical("The sound hadle cannot be get [%d]", lhandle);
}
- debug_warning ("success : handle=[%p]", handle);
+ debug_warning("success : handle=[%p]", handle);
return MM_ERROR_NONE;
}
return err;
}
- debug_warning ("success : handle=[%p]", handle);
+ debug_warning("success : handle=[%p]", handle);
return MM_ERROR_NONE;
{
int err;
- debug_warning ("enter : handle=[%d]", handle);
+ debug_warning("enter : handle=[%d]", handle);
/* Stop sound */
err = mm_sound_client_stop_sound(handle);
if (err < 0) {
debug_error("Fail to stop sound");
return err;
}
- debug_warning ("success : handle=[%d]", handle);
+ debug_warning("success : handle=[%d]", handle);
return MM_ERROR_NONE;
}
//// MMSOUND TONE APIs
///////////////////////////////////
EXPORT_API
-int mm_sound_play_tone_ex (MMSoundTone_t num, int volume_config, const double volume, const int duration, int *handle, bool enable_session)
+int mm_sound_play_tone_ex(MMSoundTone_t num, int volume_config, const double volume, const int duration, int *handle, bool enable_session)
{
int lhandle = -1;
int err = MM_ERROR_NONE;
int err = MM_ERROR_NONE;
err = mm_sound_client_play_tone_with_stream_info(tone, stream_type, stream_id, volume, duration, handle);
- if (err <0) {
+ if (err < 0) {
debug_error("Failed to play sound");
return err;
}
EXPORT_API
-int mm_sound_play_tone (MMSoundTone_t num, int volume_config, const double volume, const int duration, int *handle)
+int mm_sound_play_tone(MMSoundTone_t num, int volume_config, const double volume, const int duration, int *handle)
{
- return mm_sound_play_tone_ex (num, volume_config, volume, duration, handle, true);
+ return mm_sound_play_tone_ex(num, volume_config, volume, duration, handle, true);
}
///////////////////////////////////
return ret;
}
-static int _convert_signal_name_str_to_enum (const char *name_str, mm_sound_signal_name_t *name_enum) {
+static int _convert_signal_name_str_to_enum(const char *name_str, mm_sound_signal_name_t *name_enum)
+{
int ret = MM_ERROR_NONE;
if (!name_str || !name_enum)
return ret;
}
-static void _dbus_signal_callback (const char *signal_name, int value, void *user_data)
+static void _dbus_signal_callback(const char *signal_name, int value, void *user_data)
{
int ret = MM_ERROR_NONE;
mm_sound_signal_name_t signal;
* |<-- pid (16bits) -->|<-- value (16bits) -->|,
* FYI, #define PID_MAX_DEFAULT (CONFIG_BASE_SMALL ? 0x1000 : 0x8000).
* In case of daemon usage, it uses the client_pid of subscribe_cb. */
- debug_msg ("client_pid[%d], getpid[%d], value>>16[%d], callback[%p]",
+ debug_msg("client_pid[%d], getpid[%d], value>>16[%d], callback[%p]",
subscribe_cb->client_pid, getpid(), (value >> 16), subscribe_cb);
if ((subscribe_cb->client_pid ? subscribe_cb->client_pid : getpid()) == (value >> 16))
subscribe_cb->callback(signal, (value & 0x0000FFFF), subscribe_cb->user_data);
GVariant *parameters,
gpointer user_data)
{
- int value=0;
+ int value = 0;
const GVariantType* value_type;
- debug_msg ("sender : %s, object : %s, interface : %s, signal : %s",
+ debug_msg("sender : %s, object : %s, interface : %s, signal : %s",
sender_name, object_path, interface_name, signal_name);
if (g_variant_is_of_type(parameters, G_VARIANT_TYPE("(i)"))) {
- g_variant_get(parameters, "(i)",&value);
+ g_variant_get(parameters, "(i)", &value);
debug_msg(" - value : 0x08%x", value);
_dbus_signal_callback(signal_name, value, user_data);
} else {
MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_subscribe_cb_list_mutex, MM_ERROR_SOUND_INTERNAL);
if (signal_type >= MM_SOUND_SIGNAL_MAX || !subscribe_id) {
- debug_error ("invalid argument, signal(%d), subscribe_id(%p)", signal_type, subscribe_id);
+ debug_error("invalid argument, signal(%d), subscribe_id(%p)", signal_type, subscribe_id);
ret = MM_ERROR_INVALID_ARGUMENT;
goto error;
}
g_dbus_conn_mmsound = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
if (!g_dbus_conn_mmsound || err) {
- debug_error ("g_bus_get_sync() error (%s) ", err ? err->message : NULL);
- g_error_free (err);
+ debug_error("g_bus_get_sync() error (%s) ", err ? err->message : NULL);
+ g_error_free(err);
ret = MM_ERROR_SOUND_INTERNAL;
goto error;
}
NULL, G_DBUS_SIGNAL_FLAGS_NONE, signal_callback,
subscribe_cb, free);
if (subs_id == 0) {
- debug_error ("g_dbus_connection_signal_subscribe() error (%d)", subs_id);
+ debug_error("g_dbus_connection_signal_subscribe() error (%d)", subs_id);
ret = MM_ERROR_SOUND_INTERNAL;
g_object_unref(g_dbus_conn_mmsound);
goto error;
MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_subscribe_cb_list_mutex, MM_ERROR_SOUND_INTERNAL);
if (signal_type >= MM_SOUND_SIGNAL_MAX || !client_pid || !subscribe_id) {
- debug_error ("invalid argument, signal(%d), client_pid(%d), subscribe_id(%p)", signal_type, client_pid, subscribe_id);
+ debug_error("invalid argument, signal(%d), client_pid(%d), subscribe_id(%p)", signal_type, client_pid, subscribe_id);
ret = MM_ERROR_INVALID_ARGUMENT;
goto error;
}
g_dbus_conn_mmsound = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
if (!g_dbus_conn_mmsound || err) {
- debug_error ("g_bus_get_sync() error (%s) ", err ? err->message : NULL);
- g_error_free (err);
+ debug_error("g_bus_get_sync() error (%s) ", err ? err->message : NULL);
+ g_error_free(err);
ret = MM_ERROR_SOUND_INTERNAL;
goto error;
}
NULL, G_DBUS_SIGNAL_FLAGS_NONE, signal_callback,
subscribe_cb, free);
if (subs_id == 0) {
- debug_error ("g_dbus_connection_signal_subscribe() error (%d)", subs_id);
+ debug_error("g_dbus_connection_signal_subscribe() error (%d)", subs_id);
ret = MM_ERROR_SOUND_INTERNAL;
g_object_unref(g_dbus_conn_mmsound);
goto error;
MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_subscribe_cb_list_mutex, MM_ERROR_SOUND_INTERNAL);
if (signal_type >= MM_SOUND_SIGNAL_MAX) {
- debug_error ("invalid argument, signal(%d)", signal_type);
+ debug_error("invalid argument, signal(%d)", signal_type);
ret = MM_ERROR_INVALID_ARGUMENT;
goto error;
}
conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
if (!conn || err) {
- debug_error ("g_bus_get_sync() error (%s)", err ? err->message : NULL);
+ debug_error("g_bus_get_sync() error (%s)", err ? err->message : NULL);
ret = MM_ERROR_SOUND_INTERNAL;
goto error;
}
* FYI, #define PID_MAX_DEFAULT (CONFIG_BASE_SMALL ? 0x1000 : 0x8000). */
value |= ((int)getpid() << 16);
if ((_mm_session_util_write_information((int)getpid(), MM_SESSION_TYPE_REPLACED_BY_STREAM, 0)))
- debug_error ("failed to _mm_session_util_write_information for MM_SESSION_TYPE_REPLACED_BY_STREAM");
+ debug_error("failed to _mm_session_util_write_information for MM_SESSION_TYPE_REPLACED_BY_STREAM");
}
- dbus_ret = g_dbus_connection_emit_signal (conn,
+ dbus_ret = g_dbus_connection_emit_signal(conn,
NULL, MM_SOUND_DBUS_OBJECT_PATH, MM_SOUND_DBUS_INTERFACE, dbus_signal_name_str[signal_type],
- g_variant_new ("(i)", value),
+ g_variant_new("(i)", value),
&err);
if (!dbus_ret || err) {
- debug_error ("g_dbus_connection_emit_signal() error (%s)", err ? err->message : NULL);
+ debug_error("g_dbus_connection_emit_signal() error (%s)", err ? err->message : NULL);
ret = MM_ERROR_SOUND_INTERNAL;
goto error;
}
dbus_ret = g_dbus_connection_flush_sync(conn, NULL, &err);
if (!dbus_ret || err) {
- debug_error ("g_dbus_connection_flush_sync() error (%s)", err ? err->message : NULL);
+ debug_error("g_dbus_connection_flush_sync() error (%s)", err ? err->message : NULL);
ret = MM_ERROR_SOUND_INTERNAL;
goto error;
}
g_object_unref(conn);
- debug_msg ("sending signal[%s], value[%d] success", dbus_signal_name_str[signal_type], value);
+ debug_msg("sending signal[%s], value[%d] success", dbus_signal_name_str[signal_type], value);
MMSOUND_LEAVE_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
error:
if (err)
- g_error_free (err);
+ g_error_free(err);
if (conn)
g_object_unref(conn);
return ret;
}
+#ifdef TIZEN_TV
+EXPORT_API
+void mm_sound_dotnet_cleanup(int signo)
+{
+ debug_warning("Dotnet cleanup %d : Start", signo);
+ mm_sound_client_cleanup();
+ debug_warning("Dotnet cleanup %d : End", signo);
+}
+#endif
+
__attribute__ ((constructor))
static void _mm_sound_initialize(void)
{
int data;
} focus_idle_event_t;
-void _system_signal_handler(int signo, siginfo_t *siginfo, void *context)
+void mm_sound_client_cleanup(void)
{
int ret = MM_ERROR_NONE;
+
+ if (g_need_emergent_exit) {
+ ret = mm_sound_proxy_emergent_exit(getpid());
+ if (ret == MM_ERROR_NONE)
+ debug_msg("Success to emergnet_exit");
+ else
+ debug_error("Error occurred : 0x%x", ret);
+ }
+}
+
+void _system_signal_handler(int signo, siginfo_t *siginfo, void *context)
+{
sigset_t old_mask, all_mask;
debug_warning("Got signal : signo(%d)", signo);
sigfillset(&all_mask);
sigprocmask(SIG_BLOCK, &all_mask, &old_mask);
- if (g_need_emergent_exit) {
- ret = mm_sound_proxy_emergent_exit(getpid());
- if (ret == MM_ERROR_NONE)
- debug_msg("Success to emergnet_exit");
- else
- debug_error("Error occurred : 0x%x", ret);
- }
+ mm_sound_client_cleanup();
sigprocmask(SIG_SETMASK, &old_mask, NULL);
/* signal unblock */
debug_warning("signal handling end");
}
+#ifdef TIZEN_TV
+static bool _is_dotnet_app(void)
+{
+ char *is_dotnet = NULL;
+
+ is_dotnet = getenv("DOTNET_APP");
+ if (is_dotnet && atoi(is_dotnet) == 1)
+ return true;
+ else
+ return false;
+}
+#endif
+
int mm_sound_client_initialize(void)
{
int ret = MM_ERROR_NONE;
+ struct sigaction system_action;
+
debug_fenter();
mm_sound_proxy_initialize();
g_idle_event_src = 0;
-
- struct sigaction system_action;
+#ifdef TIZEN_TV
+ if (_is_dotnet_app()) {
+ debug_warning("no signal handler for dotnet!!");
+ return ret;
+ }
+#endif
system_action.sa_sigaction = _system_signal_handler;
system_action.sa_flags = SA_NOCLDSTOP | SA_SIGINFO;
debug_fenter();
- if (g_need_emergent_exit) {
- ret = mm_sound_proxy_emergent_exit(getpid());
- if (ret == MM_ERROR_NONE)
- debug_msg("Success to emergent_exit");
- else
- debug_error("Error occurred : 0x%x", ret);
- }
-
- sigaction(SIGINT, &system_int_old_action, NULL);
- sigaction(SIGABRT, &system_abrt_old_action, NULL);
- sigaction(SIGSEGV, &system_segv_old_action, NULL);
- sigaction(SIGTERM, &system_term_old_action, NULL);
- sigaction(SIGSYS, &system_sys_old_action, NULL);
- sigaction(SIGXCPU, &system_xcpu_old_action, NULL);
+ mm_sound_client_cleanup();
ret = mm_sound_proxy_finalize();
}
#endif
+#ifdef TIZEN_TV
+ if (_is_dotnet_app()) {
+ debug_warning("no signal handler for dotnet!!");
+ return ret;
+ }
+#endif
+
+ sigaction(SIGINT, &system_int_old_action, NULL);
+ sigaction(SIGABRT, &system_abrt_old_action, NULL);
+ sigaction(SIGSEGV, &system_segv_old_action, NULL);
+ sigaction(SIGTERM, &system_term_old_action, NULL);
+ sigaction(SIGSYS, &system_sys_old_action, NULL);
+ sigaction(SIGXCPU, &system_xcpu_old_action, NULL);
+
debug_fleave();
return ret;
}
debug_warning("Read Session Information failed. use default \"media\" type");
session_type = MM_SESSION_TYPE_MEDIA;
- if(MM_ERROR_NONE != mm_session_init(session_type)) {
+ if (MM_ERROR_NONE != mm_session_init(session_type)) {
debug_critical("MMSessionInit() failed");
return MM_ERROR_POLICY_INTERNAL;
}
int session_type = MM_SESSION_TYPE_MEDIA;
int session_options = 0;
int is_focus_registered = 0;
-// int instance = -1; /* instance is unique to communicate with server : client message queue filter type */
+// int instance = -1; /* instance is unique to communicate with server : client message queue filter type */
int volume_type = MM_SOUND_VOLUME_CONFIG_TYPE(param->volume_config);
char stream_type[MAX_STREAM_TYPE_LEN] = {0, };
struct callback_data *cb_data = NULL;
param->skip_session = true;
if (param->skip_session == false) {
- if(MM_ERROR_NONE != _mm_session_util_read_information(-1, &session_type, &session_options)) {
+ if (MM_ERROR_NONE != _mm_session_util_read_information(-1, &session_type, &session_options)) {
debug_warning("Read MMSession Type failed. use default \"media\" type");
session_type = MM_SESSION_TYPE_MEDIA;
- if(MM_ERROR_NONE != mm_session_init(session_type)) {
+ if (MM_ERROR_NONE != mm_session_init(session_type)) {
debug_critical("MMSessionInit() failed");
return MM_ERROR_POLICY_INTERNAL;
}
return ret;
}
-static int _mm_sound_client_device_list_dump (GList *device_list)
+static int _mm_sound_client_device_list_dump(GList *device_list)
{
int ret = MM_ERROR_NONE;
GList *list = NULL;
debug_error("unexpected volume type [%d]", volume_type);
return MM_ERROR_SOUND_INTERNAL;
}
- if (!strncmp(*volume_type_str,"", VOLUME_TYPE_LEN)) {
+ if (!strncmp(*volume_type_str, "", VOLUME_TYPE_LEN)) {
debug_error("could not find the volume_type[%d] in this switch case statement", volume_type);
ret = MM_ERROR_SOUND_INTERNAL;
} else {
}
static void _session_interrupted_cb(int id, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e state,
- const char *reason_for_change, const char *ext_info, void *user_data)
+ const char *reason_for_change, const char *ext_info, void *user_data)
{
debug_msg("id(%d), focus_type(%d), state(%d), reason(%s)", id, focus_type, state, reason_for_change);
if (id != g_focus_session_interrupt_info.watch_cb_id) {
debug_error("id is not valid(param id:%d, g_focus_session_interrupt_watch_cb_id:%d)",
- id, g_focus_session_interrupt_info.watch_cb_id);
+ id, g_focus_session_interrupt_info.watch_cb_id);
return;
}
if (!g_focus_session_interrupt_info.user_cb) {
/* add internal focus watch callback */
if (g_focus_session_interrupt_info.watch_cb_id == -1) {
if ((ret = mm_sound_client_set_focus_watch_callback(getpid(), FOCUS_FOR_BOTH, true, true, _session_interrupted_cb, NULL,
- &g_focus_session_interrupt_info.watch_cb_id))) {
+ &g_focus_session_interrupt_info.watch_cb_id))) {
debug_error("failed to mm_sound_client_set_focus_watch_callback(), ret(0x%x)", ret);
return ret;
}
/* remove internal focus watch callback */
if ((ret = mm_sound_client_unset_focus_watch_callback(g_focus_session_interrupt_info.watch_cb_id))) {
debug_error("failed to mm_sound_client_unset_focus_watch_callback(), id(%d), ret(0x%x)",
- g_focus_session_interrupt_info.watch_cb_id, ret);
+ g_focus_session_interrupt_info.watch_cb_id, ret);
return ret;
}
g_focus_session_interrupt_info.watch_cb_id = -1;
static gboolean _focus_fd_prepare(GSource *source, gint *timeout)
{
#ifdef __DEBUG__
- debug_warning("[ PREPARE : %p, (%p, %d)", source, timeout, timeout? *timeout : -1);
+ debug_warning("[ PREPARE : %p, (%p, %d)", source, timeout, timeout ? *timeout : -1);
#endif
return FALSE;
}
for (i = 0; i < FOCUS_HANDLE_MAX; i++) {
if (g_focus_sound_handle[i].focus_callback && handle == g_focus_sound_handle[i].handle) {
/* debug_msg("found index(%d) for handle(%d)", i, handle);*/
- return (handle == FOCUS_HANDLE_INIT_VAL)? -1 : i;
+ return (handle == FOCUS_HANDLE_INIT_VAL) ? -1 : i;
}
}
return -1;
for (i = 0; i < FOCUS_HANDLE_MAX; i++) {
if (g_focus_sound_handle[i].watch_callback && handle == g_focus_sound_handle[i].handle) {
/* debug_msg("found index(%d) for watch handle(%d)", i, handle);*/
- return (handle == FOCUS_HANDLE_INIT_VAL)? -1 : i;
+ return (handle == FOCUS_HANDLE_INIT_VAL) ? -1 : i;
}
}
return -1;
int changed_state = -1;
count = read(poll_fd->fd, &cb_data, sizeof(cb_data));
- if (count < 0){
+ if (count < 0) {
char str_error[256];
strerror_r(errno, str_error, sizeof(str_error));
- debug_error("GpollFD read fail, errno=%d(%s)",errno, str_error);
+ debug_error("GpollFD read fail, errno=%d(%s)", errno, str_error);
return G_SOURCE_CONTINUE;
}
changed_state = cb_data.state;
if (poll_fd->revents & (POLLIN | POLLPRI)) {
count = read(poll_fd->fd, &cb_data, sizeof(cb_data));
- if (count < 0){
+ if (count < 0) {
char str_error[256];
strerror_r(errno, str_error, sizeof(str_error));
- debug_error("GpollFD read fail, errno=%d(%s)",errno, str_error);
+ debug_error("GpollFD read fail, errno=%d(%s)", errno, str_error);
return G_SOURCE_CONTINUE;
}
}
int mm_sound_client_register_focus(int id, int pid, const char *stream_type, bool is_for_session,
- mm_sound_focus_changed_cb callback, void* user_data)
+ mm_sound_focus_changed_cb callback, void* user_data)
{
int ret = MM_ERROR_NONE;
int instance;
goto cleanup;
}
} else {
- debug_error("Error occurred : 0x%x",ret);
+ debug_error("Error occurred : 0x%x", ret);
goto cleanup;
}
if (ret == MM_ERROR_NONE) {
debug_msg("Success to set focus reacquisition to [%d]", reacquisition);
} else {
- debug_error("Error occurred : 0x%x",ret);
+ debug_error("Error occurred : 0x%x", ret);
goto cleanup;
}
} else {
ret = mm_sound_proxy_get_acquired_focus_stream_type(focus_type, &stream_type_str, option, &ext_info_str);
if (ret == MM_ERROR_NONE) {
debug_msg("Success to get stream type of acquired focus, stream_type(%s), ext_info(%s)",
- stream_type_str, ext_info_str);
+ stream_type_str, ext_info_str);
*stream_type = strdup(stream_type_str);
*ext_info = strdup(ext_info_str);
g_free(stream_type_str);
g_free(ext_info_str);
} else {
- debug_error("Error occurred : 0x%x",ret);
+ debug_error("Error occurred : 0x%x", ret);
}
debug_fleave();
if (ret == MM_ERROR_NONE)
debug_msg("Success to release focus");
else
- debug_error("Error occurred : 0x%x",ret);
+ debug_error("Error occurred : 0x%x", ret);
cleanup:
MMSOUND_LEAVE_CRITICAL_SECTION(&g_index_mutex);
}
int mm_sound_client_set_focus_watch_callback(int pid, mm_sound_focus_type_e focus_type, bool is_for_session, bool is_for_monitor,
- mm_sound_focus_changed_watch_cb callback, void* user_data, int *id)
+ mm_sound_focus_changed_watch_cb callback, void* user_data, int *id)
{
int ret = MM_ERROR_NONE;
int instance;
g_focus_sound_handle[index].unset_watch_callback_requested = false;
ret = mm_sound_proxy_set_focus_watch_callback(pid, g_focus_sound_handle[index].handle, focus_type,
- is_for_session, is_for_monitor, callback, user_data);
+ is_for_session, is_for_monitor, callback, user_data);
if (ret == MM_ERROR_NONE) {
debug_msg("Success to watch focus");
goto cleanup;
}
} else {
- debug_error("Error occurred : 0x%x",ret);
+ debug_error("Error occurred : 0x%x", ret);
goto cleanup;
}
g_focus_sound_handle[index].is_used = false;
ret = mm_sound_proxy_unset_focus_watch_callback(g_focus_sound_handle[index].focus_tid,
- g_focus_sound_handle[index].handle,
- g_focus_sound_handle[index].is_for_session);
+ g_focus_sound_handle[index].handle,
+ g_focus_sound_handle[index].is_for_session);
if (ret == MM_ERROR_NONE)
debug_msg("Success to unwatch focus");
else
- debug_error("Error occurred : 0x%x",ret);
+ debug_error("Error occurred : 0x%x", ret);
g_mutex_unlock(&g_focus_sound_handle[index].focus_lock);