focus_server: Fix bug regarding update of reacquisition information within focus...
[platform/core/multimedia/libmm-sound.git] / mm_sound_client.c
index 433f780..4ba6246 100644 (file)
@@ -146,7 +146,7 @@ typedef struct _focus_idle_event {
        int data;
 } focus_idle_event_t;
 
-void _system_signal_handler(int signo)
+void _system_signal_handler(int signo, siginfo_t *siginfo, void *context)
 {
        int ret = MM_ERROR_NONE;
        sigset_t old_mask, all_mask;
@@ -171,28 +171,40 @@ void _system_signal_handler(int signo)
 
        switch (signo) {
        case SIGINT:
-               sigaction(SIGINT, &system_int_old_action, NULL);
-               raise( signo);
+               if (system_int_old_action.sa_sigaction)
+                       system_int_old_action.sa_sigaction(signo, siginfo, context);
+               else
+                       sigaction(signo, &system_int_old_action, NULL);
                break;
        case SIGABRT:
-               sigaction(SIGABRT, &system_abrt_old_action, NULL);
-               raise( signo);
+               if (system_abrt_old_action.sa_sigaction)
+                       system_abrt_old_action.sa_sigaction(signo, siginfo, context);
+               else
+                       sigaction(signo, &system_abrt_old_action, NULL);
                break;
        case SIGSEGV:
-               sigaction(SIGSEGV, &system_segv_old_action, NULL);
-               raise( signo);
+               if (system_segv_old_action.sa_sigaction)
+                       system_segv_old_action.sa_sigaction(signo, siginfo, context);
+               else
+                       sigaction(signo, &system_segv_old_action, NULL);
                break;
        case SIGTERM:
-               sigaction(SIGTERM, &system_term_old_action, NULL);
-               raise( signo);
+               if (system_term_old_action.sa_sigaction)
+                       system_term_old_action.sa_sigaction(signo, siginfo, context);
+               else
+                       sigaction(signo, &system_term_old_action, NULL);
                break;
        case SIGSYS:
-               sigaction(SIGSYS, &system_sys_old_action, NULL);
-               raise( signo);
+               if (system_sys_old_action.sa_sigaction)
+                       system_sys_old_action.sa_sigaction(signo, siginfo, context);
+               else
+                       sigaction(signo, &system_sys_old_action, NULL);
                break;
        case SIGXCPU:
-               sigaction(SIGXCPU, &system_xcpu_old_action, NULL);
-               raise( signo);
+               if (system_xcpu_old_action.sa_sigaction)
+                       system_xcpu_old_action.sa_sigaction(signo, siginfo, context);
+               else
+                       sigaction(signo, &system_xcpu_old_action, NULL);
                break;
        default:
                break;
@@ -211,8 +223,8 @@ int mm_sound_client_initialize(void)
 
 
        struct sigaction system_action;
-       system_action.sa_handler = _system_signal_handler;
-       system_action.sa_flags = SA_NOCLDSTOP;
+       system_action.sa_sigaction = _system_signal_handler;
+       system_action.sa_flags = SA_NOCLDSTOP | SA_SIGINFO;
 
        sigemptyset(&system_action.sa_mask);
 
@@ -1915,7 +1927,11 @@ int mm_sound_client_set_focus_reacquisition(int id, bool reacquisition, bool is_
        bool result;
 
        debug_fenter();
-       MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_index_mutex, MM_ERROR_SOUND_INTERNAL);
+
+       /* Since the muse server which uses this library for multiple handles executes requests from clients serially,
+        * we can skip locking/unlocking the mutex for this case. */
+       if (!is_for_session)
+               MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_index_mutex, MM_ERROR_SOUND_INTERNAL);
 
        index = _focus_find_index_by_handle(id);
        if (index == -1) {
@@ -1945,7 +1961,8 @@ int mm_sound_client_set_focus_reacquisition(int id, bool reacquisition, bool is_
        debug_msg("set focus reacquisition(%d) for id(%d)", reacquisition, id);
 
 cleanup:
-       MMSOUND_LEAVE_CRITICAL_SECTION(&g_index_mutex);
+       if (!is_for_session)
+               MMSOUND_LEAVE_CRITICAL_SECTION(&g_index_mutex);
        debug_fleave();
        return ret;
 }
@@ -2255,7 +2272,7 @@ int mm_sound_client_execute_focus_func_in_main_context(focus_idle_event_type_e t
 {
        focus_idle_event_t *idle_event_data = NULL;
 
-       if (IDLE_EVENT_TYPE_UNSET_FOCUS_WATCH_CB > type || IDLE_EVENT_TYPE_MAX < type)
+       if (IDLE_EVENT_TYPE_MAX < type)
                return MM_ERROR_INVALID_ARGUMENT;
 
        MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_event_mutex, MM_ERROR_SOUND_INTERNAL);