Improve visibility of source codes 34/60534/5 accepted/tizen/common/20160304.195003 accepted/tizen/ivi/20160305.091429 accepted/tizen/mobile/20160305.091339 accepted/tizen/tv/20160305.091357 accepted/tizen/wearable/20160305.091412 submit/tizen/20160303.100043
authorSangchul Lee <sc11.lee@samsung.com>
Mon, 29 Feb 2016 01:35:52 +0000 (10:35 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Thu, 3 Mar 2016 08:52:49 +0000 (17:52 +0900)
[Version] Release 0.3.45
[Profile] Common
[Issue Type] Code clean-up

Change-Id: I6cf57eb1a2d0d41b70c47e47c2d6467a456f2648
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
packaging/capi-media-sound-manager.spec
src/sound_manager.c
src/sound_manager_internal.c
src/sound_manager_private.c

index 9cf33d3a3e2d63d15608a01aea6b842d7e12e045..800b769c8e08066ad7f4d94577b3c454d1b07b08 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       capi-media-sound-manager
 Summary:    Sound Manager library
-Version:    0.3.44
+Version:    0.3.45
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 12d1e3b6a893d6b14bade6439e16bb30f03b8aa7..f9044013cb3dd55dd0f7bac98419ed888673c63b 100644 (file)
@@ -193,22 +193,25 @@ int sound_manager_create_stream_information(sound_stream_type_e stream_type, sou
        sound_stream_info_s *stream_h = malloc(sizeof(sound_stream_info_s));
        if (!stream_h) {
                ret = MM_ERROR_OUT_OF_MEMORY;
-       } else {
-               memset(stream_h, 0, sizeof(sound_stream_info_s));
-               ret = _convert_stream_type(stream_type, &stream_h->stream_type);
+               goto LEAVE;
+       }
+
+       memset(stream_h, 0, sizeof(sound_stream_info_s));
+       ret = _convert_stream_type(stream_type, &stream_h->stream_type);
+       if (ret == MM_ERROR_NONE) {
+               _set_focus_availability(stream_h);
+               ret = _make_pa_connection_and_register_focus(stream_h, callback, user_data);
                if (ret == MM_ERROR_NONE) {
-                       _set_focus_availability(stream_h);
-                       ret = _make_pa_connection_and_register_focus(stream_h, callback, user_data);
-                       if (ret == MM_ERROR_NONE) {
-                               *stream_info = (sound_stream_info_h)stream_h;
-                               SM_REF_FOR_STREAM_INFO(g_stream_info_count, ret);
-                               LOGI("stream_h(%p), index(%u), user_cb(%p), cnt(%d), ret(0x%x)", stream_h, stream_h->index, stream_h->user_cb, g_stream_info_count, ret);
-                       }
+                       *stream_info = (sound_stream_info_h)stream_h;
+                       SM_REF_FOR_STREAM_INFO(g_stream_info_count, ret);
+                       LOGI("stream_h(%p), index(%u), user_cb(%p), cnt(%d), ret(0x%x)", stream_h, stream_h->index, stream_h->user_cb, g_stream_info_count, ret);
                }
-               if (ret)
-                       free(stream_h);
        }
 
+LEAVE:
+       if (ret && stream_h)
+               free(stream_h);
+
        SM_LEAVE_CRITICAL_SECTION(&g_stream_info_count_mutex);
 
        return _convert_sound_manager_error_code(__func__, ret);
@@ -349,8 +352,10 @@ int sound_manager_get_focus_state(sound_stream_info_h stream_info, sound_stream_
        LOGI(">> enter");
 
        SM_INSTANCE_CHECK(stream_h);
-       if (!state_for_playback && !state_for_recording)
+       if (!state_for_playback && !state_for_recording) {
                ret = MM_ERROR_INVALID_ARGUMENT;
+               goto LEAVE;
+       }
 
        if (state_for_playback)
                *state_for_playback = ((stream_h->acquired_focus & SOUND_STREAM_FOCUS_FOR_PLAYBACK) ? (SOUND_STREAM_FOCUS_STATE_ACQUIRED) : (SOUND_STREAM_FOCUS_STATE_RELEASED));
@@ -359,6 +364,7 @@ int sound_manager_get_focus_state(sound_stream_info_h stream_info, sound_stream_
 
        LOGI("acquired_focus(0x%x)", stream_h->acquired_focus);
 
+LEAVE:
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
@@ -372,13 +378,15 @@ int sound_manager_get_sound_type(sound_stream_info_h stream_info, sound_type_e *
        SM_INSTANCE_CHECK(stream_h);
        SM_NULL_ARG_CHECK(sound_type);
 
-       if (stream_h->stream_conf_info.volume_type == NULL)
+       if (stream_h->stream_conf_info.volume_type == NULL) {
                ret = MM_ERROR_SOUND_NO_DATA;
-       else {
-               ret = _convert_sound_type_to_enum(stream_h->stream_conf_info.volume_type, sound_type);
-               LOGI("sound type(%d)", *sound_type);
+               goto LEAVE;
        }
 
+       ret = _convert_sound_type_to_enum(stream_h->stream_conf_info.volume_type, sound_type);
+       LOGI("sound type(%d)", *sound_type);
+
+LEAVE:
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
@@ -392,18 +400,20 @@ int sound_manager_set_focus_state_watch_cb(sound_stream_focus_mask_e focus_mask,
        SM_NULL_ARG_CHECK(callback);
        SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_stream_info_count_mutex, SOUND_MANAGER_ERROR_INTERNAL);
 
-       if (!g_focus_watch_cb_table.user_cb) {
-               SM_REF_FOR_STREAM_INFO(g_stream_info_count, ret);
-               ret = mm_sound_set_focus_watch_callback((mm_sound_focus_type_e)focus_mask, _focus_watch_callback, user_data, &id);
-               if (ret == MM_ERROR_NONE) {
-                       g_focus_watch_cb_table.index = id;
-                       g_focus_watch_cb_table.user_cb = callback;
-                       g_focus_watch_cb_table.user_data = user_data;
-               }
-       } else {
+       if (g_focus_watch_cb_table.user_cb) {
                ret = MM_ERROR_SOUND_INTERNAL;
+               goto LEAVE;
        }
 
+       SM_REF_FOR_STREAM_INFO(g_stream_info_count, ret);
+       ret = mm_sound_set_focus_watch_callback((mm_sound_focus_type_e)focus_mask, _focus_watch_callback, user_data, &id);
+       if (ret == MM_ERROR_NONE) {
+               g_focus_watch_cb_table.index = id;
+               g_focus_watch_cb_table.user_cb = callback;
+               g_focus_watch_cb_table.user_data = user_data;
+       }
+
+LEAVE:
        SM_LEAVE_CRITICAL_SECTION(&g_stream_info_count_mutex);
 
        LOGD("cnt(%d)", g_stream_info_count);
@@ -419,20 +429,23 @@ int sound_manager_unset_focus_state_watch_cb(void)
 
        SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_stream_info_count_mutex, SOUND_MANAGER_ERROR_INTERNAL);
 
-       if (g_focus_watch_cb_table.user_cb) {
-               ret = mm_sound_unset_focus_watch_callback(g_focus_watch_cb_table.index);
-               if (ret == MM_ERROR_NONE) {
-                       g_focus_watch_cb_table.index = -1;
-                       g_focus_watch_cb_table.user_cb = NULL;
-                       g_focus_watch_cb_table.user_data = NULL;
-                       SM_UNREF_FOR_STREAM_INFO(g_stream_info_count, ret);
-               } else {
-                       ret = MM_ERROR_SOUND_INTERNAL;
-               }
-       } else {
+       if (!g_focus_watch_cb_table.user_cb) {
+               ret = MM_ERROR_SOUND_INTERNAL;
+               goto LEAVE;
+       }
+
+       ret = mm_sound_unset_focus_watch_callback(g_focus_watch_cb_table.index);
+       if (ret != MM_ERROR_NONE) {
                ret = MM_ERROR_SOUND_INTERNAL;
+               goto LEAVE;
        }
 
+       g_focus_watch_cb_table.index = -1;
+       g_focus_watch_cb_table.user_cb = NULL;
+       g_focus_watch_cb_table.user_data = NULL;
+       SM_UNREF_FOR_STREAM_INFO(g_stream_info_count, ret);
+
+LEAVE:
        SM_LEAVE_CRITICAL_SECTION(&g_stream_info_count_mutex);
 
        LOGD("cnt(%d)", g_stream_info_count);
@@ -532,12 +545,13 @@ int sound_manager_get_session_type(sound_session_type_e *type)
 
        if (type == NULL)
                return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT);
+
        ret = mm_session_get_current_type(&cur_session);
-       if (ret != 0) {
+       if (ret != MM_ERROR_NONE) {
                LOGW("session hasn't been set, setting default session");
                cur_session = SOUND_SESSION_TYPE_DEFAULT;
                ret = mm_session_init(cur_session);
-               if (ret == 0)
+               if (ret == MM_ERROR_NONE)
                        g_session_interrupt_cb_table.is_registered = 1;
        }
        if ((cur_session > MM_SESSION_TYPE_EMERGENCY) &&
@@ -768,6 +782,7 @@ int sound_manager_get_media_session_resumption_option(sound_session_option_for_r
 
        if (option == NULL)
                return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT);
+
        ret = mm_session_get_current_information(&session, &session_options);
        if (ret != 0) {
                LOGW("session hasn't been set, setting default session");
@@ -805,18 +820,23 @@ int sound_manager_set_voip_session_mode(sound_session_voip_mode_e mode)
 
        ret = mm_session_get_current_information(&session, &session_options);
        if (ret != MM_ERROR_NONE)
-               return _convert_sound_manager_error_code(__func__, ret);
-       else if (session != MM_SESSION_TYPE_VOIP)
-               return _convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL);
+               goto LEAVE;
+
+       if (session != MM_SESSION_TYPE_VOIP) {
+               ret = MM_ERROR_POLICY_INTERNAL;
+               goto LEAVE;
+       }
 
        if (mode < SOUND_SESSION_VOIP_MODE_RINGTONE || mode > SOUND_SESSION_VOIP_MODE_VOICE_WITH_BLUETOOTH) {
                ret = MM_ERROR_INVALID_ARGUMENT;
-               return _convert_sound_manager_error_code(__func__, ret);
+               goto LEAVE;
        }
+
        ret = _set_session_mode((_session_mode_e)mode);
 
        LOGI("session=%d, mode=%d", session, mode);
 
+LEAVE:
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
@@ -828,20 +848,26 @@ int sound_manager_get_voip_session_mode(sound_session_voip_mode_e *mode)
 
        if (mode == NULL) {
                LOGE("mode is null");
-               return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT);
+               ret = MM_ERROR_INVALID_ARGUMENT;
+               goto LEAVE;
        }
 
        ret = mm_session_get_current_information(&session, &session_options);
        if (ret != MM_ERROR_NONE) {
                LOGI("session = %d, option = %d", session, session_options);
-               return _convert_sound_manager_error_code(__func__, ret);
-       } else if (session != MM_SESSION_TYPE_VOIP || g_cached_session_mode == -1)
-               return _convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL);
+               goto LEAVE;
+       }
+
+       if (session != MM_SESSION_TYPE_VOIP || g_cached_session_mode == -1) {
+               ret = MM_ERROR_POLICY_INTERNAL;
+               goto LEAVE;
+       }
 
        *mode = (sound_session_voip_mode_e)g_cached_session_mode;
 
        LOGI("session=%d, mode=%d", session, *mode);
 
+LEAVE:
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
@@ -854,32 +880,33 @@ int sound_manager_set_session_interrupted_cb(sound_session_interrupted_cb callba
 
        if (callback == NULL) {
                ret = MM_ERROR_INVALID_ARGUMENT;
-               goto finish;
+               goto LEAVE;
        }
 
        /* it is not supported both session and stream feature at the same time */
        if (g_stream_info_count) {
                ret =  MM_ERROR_POLICY_INTERNAL;
-               goto finish;
+               goto LEAVE;
        }
 
        if (g_session_interrupt_cb_table.user_cb == NULL) {
                ret = mm_sound_add_device_connected_callback(SOUND_DEVICE_ALL_MASK, (mm_sound_device_connected_cb)_device_connected_cb, NULL, &subs_id);
                if (ret)
-                       goto finish;
+                       goto LEAVE;
                ret = mm_sound_focus_set_session_interrupt_callback((mm_sound_focus_session_interrupt_cb)_focus_session_interrupt_cb, NULL);
                if (ret) {
                        if (mm_sound_remove_device_connected_callback(subs_id) != MM_ERROR_NONE)
                                LOGW("mm_sound_remove_device_connected_callback failed");
-                       goto finish;
+                       goto LEAVE;
                }
                g_session_interrupt_cb_table.subs_id = subs_id;
        }
        g_session_interrupt_cb_table.user_cb = (sound_session_interrupted_cb)callback;
        g_session_interrupt_cb_table.user_data = user_data;
 
-finish:
+LEAVE:
        SM_LEAVE_CRITICAL_SECTION(&g_interrupt_cb_mutex);
+
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
@@ -889,31 +916,36 @@ int sound_manager_unset_session_interrupted_cb(void)
 
        SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_interrupt_cb_mutex, SOUND_MANAGER_ERROR_INTERNAL);
 
-       if (g_session_interrupt_cb_table.user_cb) {
-               ret = mm_sound_focus_unset_session_interrupt_callback();
-               if (ret) {
-                       if (mm_sound_remove_device_connected_callback(g_session_interrupt_cb_table.subs_id) != MM_ERROR_NONE)
-                               LOGW("mm_sound_remove_device_connected_callback failed");
-                       goto finish;
-               }
-               ret = mm_sound_remove_device_connected_callback(g_session_interrupt_cb_table.subs_id);
-               if (ret)
-                       goto finish;
-               g_session_interrupt_cb_table.subs_id = 0;
-               g_session_interrupt_cb_table.user_cb = NULL;
-               g_session_interrupt_cb_table.user_data = NULL;
-       } else {
+       if (!g_session_interrupt_cb_table.user_cb) {
                ret = MM_ERROR_SOUND_INTERNAL;
+               goto LEAVE;
        }
 
-finish:
+       ret = mm_sound_focus_unset_session_interrupt_callback();
+       if (ret) {
+               if (mm_sound_remove_device_connected_callback(g_session_interrupt_cb_table.subs_id) != MM_ERROR_NONE)
+                       LOGW("mm_sound_remove_device_connected_callback failed");
+               goto LEAVE;
+       }
+
+       ret = mm_sound_remove_device_connected_callback(g_session_interrupt_cb_table.subs_id);
+       if (ret)
+               goto LEAVE;
+
+       g_session_interrupt_cb_table.subs_id = 0;
+       g_session_interrupt_cb_table.user_cb = NULL;
+       g_session_interrupt_cb_table.user_data = NULL;
+
+LEAVE:
        SM_LEAVE_CRITICAL_SECTION(&g_interrupt_cb_mutex);
+
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
 int sound_manager_get_current_device_list(sound_device_mask_e device_mask, sound_device_list_h *device_list)
 {
        int ret = MM_ERROR_NONE;
+
        ret = mm_sound_get_current_device_list((mm_sound_device_flags_e)device_mask, device_list);
 
        return _convert_sound_manager_error_code(__func__, ret);
@@ -922,6 +954,7 @@ int sound_manager_get_current_device_list(sound_device_mask_e device_mask, sound
 int sound_manager_free_device_list(sound_device_list_h device_list)
 {
        int ret = MM_ERROR_NONE;
+
        ret = mm_sound_free_device_list(device_list);
 
        return _convert_sound_manager_error_code(__func__, ret);
@@ -930,6 +963,7 @@ int sound_manager_free_device_list(sound_device_list_h device_list)
 int sound_manager_get_next_device(sound_device_list_h device_list, sound_device_h *device)
 {
        int ret = MM_ERROR_NONE;
+
        ret = mm_sound_get_next_device(device_list, device);
 
        return _convert_sound_manager_error_code(__func__, ret);
@@ -938,6 +972,7 @@ int sound_manager_get_next_device(sound_device_list_h device_list, sound_device_
 int sound_manager_get_prev_device(sound_device_list_h device_list, sound_device_h *device)
 {
        int ret = MM_ERROR_NONE;
+
        ret = mm_sound_get_prev_device(device_list, device);
 
        return _convert_sound_manager_error_code(__func__, ret);
@@ -946,6 +981,7 @@ int sound_manager_get_prev_device(sound_device_list_h device_list, sound_device_
 int sound_manager_get_device_type(sound_device_h device, sound_device_type_e *type)
 {
        int ret = MM_ERROR_NONE;
+
        ret = mm_sound_get_device_type(device, (mm_sound_device_type_e*)type);
 
        return _convert_sound_manager_error_code(__func__, ret);
@@ -955,6 +991,7 @@ int sound_manager_get_device_io_direction(sound_device_h device, sound_device_io
 {
        int ret = MM_ERROR_NONE;
        mm_sound_device_io_direction_e mm_sound_io_direction;
+
        ret = mm_sound_get_device_io_direction(device, &mm_sound_io_direction);
        if (ret == MM_ERROR_NONE)
                ret = _convert_device_io_direction(mm_sound_io_direction, io_direction);
@@ -965,6 +1002,7 @@ int sound_manager_get_device_io_direction(sound_device_h device, sound_device_io
 int sound_manager_get_device_id(sound_device_h device, int *id)
 {
        int ret = MM_ERROR_NONE;
+
        ret = mm_sound_get_device_id(device, id);
 
        return _convert_sound_manager_error_code(__func__, ret);
@@ -973,6 +1011,7 @@ int sound_manager_get_device_id(sound_device_h device, int *id)
 int sound_manager_get_device_name(sound_device_h device, char **name)
 {
        int ret = MM_ERROR_NONE;
+
        ret = mm_sound_get_device_name(device, name);
 
        return _convert_sound_manager_error_code(__func__, ret);
@@ -981,6 +1020,7 @@ int sound_manager_get_device_name(sound_device_h device, char **name)
 int sound_manager_get_device_state(sound_device_h device, sound_device_state_e *state)
 {
        int ret = MM_ERROR_NONE;
+
        ret = mm_sound_get_device_state(device, (mm_sound_device_state_e*)state);
 
        return _convert_sound_manager_error_code(__func__, ret);
@@ -1011,16 +1051,19 @@ int sound_manager_unset_device_connected_cb(void)
 
        SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_device_conn_cb_mutex, SOUND_MANAGER_ERROR_INTERNAL);
 
-       if (g_device_connected_cb_table.subs_id > 0) {
-               ret = mm_sound_remove_device_connected_callback(g_device_connected_cb_table.subs_id);
-               if (ret == MM_ERROR_NONE) {
-                       g_device_connected_cb_table.subs_id = 0;
-                       g_device_connected_cb_table.user_cb = NULL;
-                       g_device_connected_cb_table.user_data = NULL;
-               }
-       } else
+       if (g_device_connected_cb_table.subs_id == 0) {
                ret = MM_ERROR_SOUND_INTERNAL;
+               goto LEAVE;
+       }
 
+       ret = mm_sound_remove_device_connected_callback(g_device_connected_cb_table.subs_id);
+       if (ret == MM_ERROR_NONE) {
+               g_device_connected_cb_table.subs_id = 0;
+               g_device_connected_cb_table.user_cb = NULL;
+               g_device_connected_cb_table.user_data = NULL;
+       }
+
+LEAVE:
        SM_LEAVE_CRITICAL_SECTION(&g_device_conn_cb_mutex);
 
        return _convert_sound_manager_error_code(__func__, ret);
@@ -1051,17 +1094,19 @@ int sound_manager_unset_device_information_changed_cb(void)
 
        SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_device_info_cb_mutex, SOUND_MANAGER_ERROR_INTERNAL);
 
-       if (g_device_info_changed_cb_table.subs_id) {
-               ret = mm_sound_remove_device_information_changed_callback(g_device_info_changed_cb_table.subs_id);
-               if (ret == MM_ERROR_NONE) {
-                       g_device_info_changed_cb_table.subs_id = 0;
-                       g_device_info_changed_cb_table.user_cb = NULL;
-                       g_device_info_changed_cb_table.user_data = NULL;
-               }
-       } else {
+       if (g_device_info_changed_cb_table.subs_id == 0) {
                ret = MM_ERROR_SOUND_INTERNAL;
+               goto LEAVE;
+       }
+
+       ret = mm_sound_remove_device_information_changed_callback(g_device_info_changed_cb_table.subs_id);
+       if (ret == MM_ERROR_NONE) {
+               g_device_info_changed_cb_table.subs_id = 0;
+               g_device_info_changed_cb_table.user_cb = NULL;
+               g_device_info_changed_cb_table.user_data = NULL;
        }
 
+LEAVE:
        SM_LEAVE_CRITICAL_SECTION(&g_device_info_cb_mutex);
 
        return _convert_sound_manager_error_code(__func__, ret);
index 411eab28783e36234cf8a708fd3c948d1397e70c..c6ae46942adffaf020e25bf1039da31153b406a3 100644 (file)
@@ -80,22 +80,25 @@ int sound_manager_create_stream_information_internal(sound_stream_type_internal_
        sound_stream_info_s *stream_h = malloc(sizeof(sound_stream_info_s));
        if (!stream_h) {
                ret = MM_ERROR_OUT_OF_MEMORY;
-       } else {
-               memset(stream_h, 0, sizeof(sound_stream_info_s));
-               ret = _convert_stream_type_for_internal(stream_type, &stream_h->stream_type);
-               if (ret == MM_ERROR_NONE) {
-                       _set_focus_availability(stream_h);
-                       ret = _make_pa_connection_and_register_focus(stream_h, callback, user_data);
-                       if (!ret) {
-                               *stream_info = (sound_stream_info_h)stream_h;
-                               SM_REF_FOR_STREAM_INFO(g_stream_info_count, ret);
-                               LOGI("stream_h(%p), index(%u), user_cb(%p), ret(0x%x)", stream_h, stream_h->index, stream_h->user_cb, ret);
-                       }
+               goto LEAVE;
+       }
+
+       memset(stream_h, 0, sizeof(sound_stream_info_s));
+       ret = _convert_stream_type_for_internal(stream_type, &stream_h->stream_type);
+       if (ret == MM_ERROR_NONE) {
+               _set_focus_availability(stream_h);
+               ret = _make_pa_connection_and_register_focus(stream_h, callback, user_data);
+               if (!ret) {
+                       *stream_info = (sound_stream_info_h)stream_h;
+                       SM_REF_FOR_STREAM_INFO(g_stream_info_count, ret);
+                       LOGI("stream_h(%p), index(%u), user_cb(%p), ret(0x%x)", stream_h, stream_h->index, stream_h->user_cb, ret);
                }
-               if (ret)
-                       free(stream_h);
        }
 
+LEAVE:
+       if (ret && stream_h)
+               free(stream_h);
+
        SM_LEAVE_CRITICAL_SECTION(&g_stream_info_count_mutex);
 
        return _convert_sound_manager_error_code(__func__, ret);
@@ -135,6 +138,7 @@ int sound_manager_is_available_stream_information(sound_stream_info_h stream_inf
                }
        }
        LOGI("stream_type[%s], native api[%s], is_available[%d]", stream_h->stream_type, name, *is_available);
+
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
index 668033604e8d48c636e74f086eac50f4d6917e6d..2c1ec5ec79f1dd52aefd46071678934659c18ed9 100644 (file)
@@ -213,8 +213,6 @@ void _set_focus_availability(sound_stream_info_s *stream_info)
 
 int _convert_stream_type_to_change_reason(const char *stream_type, sound_stream_focus_change_reason_e *change_reason)
 {
-       int ret = MM_ERROR_NONE;
-
        SM_NULL_ARG_CHECK_FOR_PRIV(stream_type);
        SM_NULL_ARG_CHECK_FOR_PRIV(change_reason);
 
@@ -257,16 +255,15 @@ int _convert_stream_type_to_change_reason(const char *stream_type, sound_stream_
                *change_reason = SOUND_STREAM_FOCUS_CHANGED_BY_MEDIA_EXTERNAL_ONLY;
 
        } else {
-               ret = MM_ERROR_INVALID_ARGUMENT;
-               LOGE("not supported stream_type(%s), err(0x%08x)", stream_type, ret);
+               LOGE("not supported stream_type(%s)", stream_type);
+               return MM_ERROR_INVALID_ARGUMENT;
        }
-       return ret;
+
+       return MM_ERROR_NONE;
 }
 
 static int _convert_stream_type_to_interrupt_reason(const char *stream_type, sound_session_interrupted_code_e *change_reason)
 {
-       int ret = MM_ERROR_NONE;
-
        SM_NULL_ARG_CHECK_FOR_PRIV(stream_type);
        SM_NULL_ARG_CHECK_FOR_PRIV(change_reason);
 
@@ -297,16 +294,15 @@ static int _convert_stream_type_to_interrupt_reason(const char *stream_type, sou
                *change_reason = SOUND_SESSION_INTERRUPTED_BY_CALL;
 
        } else {
-               ret = MM_ERROR_INVALID_ARGUMENT;
-               LOGE("not supported stream_type(%s), err(0x%08x)", stream_type, ret);
+               LOGE("not supported stream_type(%s)", stream_type);
+               return MM_ERROR_INVALID_ARGUMENT;
        }
-       return ret;
+
+       return MM_ERROR_NONE;
 }
 
 int _convert_sound_type(sound_type_e sound_type, const char **volume_type)
 {
-       int ret = MM_ERROR_NONE;
-
        SM_NULL_ARG_CHECK_FOR_PRIV(volume_type);
 
        switch (sound_type) {
@@ -337,13 +333,11 @@ int _convert_sound_type(sound_type_e sound_type, const char **volume_type)
        }
        LOGI("volume_type[%s]", *volume_type);
 
-       return ret;
+       return MM_ERROR_NONE;
 }
 
 int _convert_sound_type_to_enum(const char *sound_type, sound_type_e *sound_type_enum)
 {
-       int ret = MM_ERROR_NONE;
-
        SM_NULL_ARG_CHECK_FOR_PRIV(sound_type);
        SM_NULL_ARG_CHECK_FOR_PRIV(sound_type_enum);
 
@@ -364,17 +358,15 @@ int _convert_sound_type_to_enum(const char *sound_type, sound_type_e *sound_type
        } else if (!strncmp(sound_type, "voice", strlen(sound_type))) {
                *sound_type_enum = SOUND_TYPE_VOICE;
        } else {
-               ret = MM_ERROR_INVALID_ARGUMENT;
-               LOGE("not supported sound_type(%s), err(0x%08x)", sound_type, ret);
+               LOGE("not supported sound_type(%s)", sound_type);
+               return MM_ERROR_INVALID_ARGUMENT;
        }
 
-       return ret;
+       return MM_ERROR_NONE;
 }
 
 int _convert_device_type(sound_device_type_e device_type_enum, char **device_type)
 {
-       int ret = MM_ERROR_NONE;
-
        SM_NULL_ARG_CHECK_FOR_PRIV(device_type);
 
        switch (device_type_enum) {
@@ -402,20 +394,18 @@ int _convert_device_type(sound_device_type_e device_type_enum, char **device_typ
        case SOUND_DEVICE_FORWARDING:
                *device_type = "forwarding";
                break;
-       }
-       if (!strncmp(*device_type, "", SOUND_DEVICE_TYPE_LEN)) {
+       default:
                LOGE("could not find the device_type[%d] in this switch case statement", device_type_enum);
-               ret = MM_ERROR_SOUND_INTERNAL;
-       } else
-               LOGI("device_type[%s]", *device_type);
+               return MM_ERROR_SOUND_INTERNAL;
+       }
 
-       return ret;
+       LOGI("device_type[%s]", *device_type);
+
+       return MM_ERROR_NONE;
 }
 
 int _convert_device_io_direction(mm_sound_device_io_direction_e io_direction, sound_device_io_direction_e *sound_io_direction)
 {
-       int ret = MM_ERROR_NONE;
-
        SM_NULL_ARG_CHECK(sound_io_direction);
 
        switch (io_direction) {
@@ -429,12 +419,14 @@ int _convert_device_io_direction(mm_sound_device_io_direction_e io_direction, so
                *sound_io_direction = SOUND_DEVICE_IO_DIRECTION_BOTH;
                break;
        }
-       return ret;
+
+       return MM_ERROR_NONE;
 }
 
 const char* _convert_api_name(native_api_e api_name)
 {
        const char* name = NULL;
+
        switch (api_name) {
        case NATIVE_API_SOUND_MANAGER:
                name = "sound-manager";
@@ -455,6 +447,7 @@ const char* _convert_api_name(native_api_e api_name)
                name = "recorder";
                break;
        }
+
        return name;
 }
 
@@ -462,31 +455,33 @@ void _focus_state_change_callback(int index, mm_sound_focus_type_e focus_type, m
 {
        int ret = MM_ERROR_NONE;
        int i = 0;
+       sound_stream_focus_change_reason_e change_reason = SOUND_STREAM_FOCUS_CHANGED_BY_MEDIA;
 
        LOGI(">> enter");
 
-       sound_stream_focus_change_reason_e change_reason = SOUND_STREAM_FOCUS_CHANGED_BY_MEDIA;
        ret = _convert_stream_type_to_change_reason(reason_for_change, &change_reason);
        if (ret) {
                LOGE("failed to _convert_stream_type_to_enum(), reason_for_change(%s), err(0x%08x)", reason_for_change, ret);
-       } else {
-               for (i = 0; i < SOUND_STREAM_INFO_ARR_MAX; i++) {
-                       if (sound_stream_info_arr[i] && sound_stream_info_arr[i]->index == index) {
-                               if (state == FOCUS_IS_RELEASED)
-                                       sound_stream_info_arr[i]->acquired_focus &= ~focus_type;
-                               else if (state == FOCUS_IS_ACQUIRED)
-                                       sound_stream_info_arr[i]->acquired_focus |= focus_type;
-
-                               LOGI("[FOCUS USER CALLBACK(%p) START]", sound_stream_info_arr[i]->user_cb);
-                               sound_stream_info_arr[i]->user_cb((sound_stream_info_h)sound_stream_info_arr[i], change_reason, additional_info, sound_stream_info_arr[i]->user_data);
-                               LOGI("[FOCUS USER CALLBACK(%p) END]", sound_stream_info_arr[i]->user_cb);
-                               break;
-                       }
+               goto LEAVE;
+       }
+
+       for (i = 0; i < SOUND_STREAM_INFO_ARR_MAX; i++) {
+               if (sound_stream_info_arr[i] && sound_stream_info_arr[i]->index == index) {
+                       if (state == FOCUS_IS_RELEASED)
+                               sound_stream_info_arr[i]->acquired_focus &= ~focus_type;
+                       else if (state == FOCUS_IS_ACQUIRED)
+                               sound_stream_info_arr[i]->acquired_focus |= focus_type;
+
+                       LOGI("[FOCUS USER CALLBACK(%p) START]", sound_stream_info_arr[i]->user_cb);
+                       sound_stream_info_arr[i]->user_cb((sound_stream_info_h)sound_stream_info_arr[i], change_reason, additional_info, sound_stream_info_arr[i]->user_data);
+                       LOGI("[FOCUS USER CALLBACK(%p) END]", sound_stream_info_arr[i]->user_cb);
+                       break;
                }
-               if (i == SOUND_STREAM_INFO_ARR_MAX)
-                       LOGE("could not find index(%d), failed to call user callback", index);
        }
+       if (i == SOUND_STREAM_INFO_ARR_MAX)
+               LOGE("could not find index(%d), failed to call user callback", index);
 
+LEAVE:
        LOGI("<< leave");
 
        return;
@@ -496,11 +491,14 @@ void _focus_watch_callback(int index, mm_sound_focus_type_e focus_type, mm_sound
 {
        int ret = MM_ERROR_NONE;
        sound_stream_focus_change_reason_e change_reason = SOUND_STREAM_FOCUS_CHANGED_BY_MEDIA;
+
        ret = _convert_stream_type_to_change_reason(reason_for_change, &change_reason);
        if (ret)
                LOGE("failed to _convert_stream_type_to_enum(), reason_for_change(%s), err(0x%08x)", reason_for_change, ret);
+
        if (g_focus_watch_cb_table.user_cb)
                g_focus_watch_cb_table.user_cb(focus_type, state, change_reason, additional_info, g_focus_watch_cb_table.user_data);
+
        return;
 }
 
@@ -508,6 +506,7 @@ void _pa_context_state_cb(pa_context *c, void *userdata)
 {
        pa_context_state_t state;
        sound_stream_info_s *stream_info_h = (sound_stream_info_s*)userdata;
+
        assert(c);
 
        state = pa_context_get_state(c);
@@ -524,12 +523,15 @@ void _pa_context_state_cb(pa_context *c, void *userdata)
        case PA_CONTEXT_SETTING_NAME:
                break;
        }
+
+       return;
 }
 
 void _pa_stream_state_cb(pa_stream *s, void * userdata)
 {
        pa_stream_state_t state;
        virtual_sound_stream_info_s *vstream_h = (virtual_sound_stream_info_s*)userdata;
+
        assert(s);
 
        state = pa_stream_get_state(s);
@@ -545,6 +547,8 @@ void _pa_stream_state_cb(pa_stream *s, void * userdata)
        case PA_STREAM_CREATING:
                break;
        }
+
+       return;
 }
 
 int _get_stream_conf_info(const char *stream_type, stream_conf_info_s *info)
@@ -554,6 +558,11 @@ int _get_stream_conf_info(const char *stream_type, stream_conf_info_s *info)
        GVariant *child = NULL;
        GDBusConnection *conn = NULL;
        GError *err = NULL;
+       GVariantIter iter;
+       GVariant *item = NULL;
+       gchar *name = NULL;
+       gsize size = 0;
+       int i = 0;
 
        assert(stream_type);
        assert(info);
@@ -575,116 +584,109 @@ int _get_stream_conf_info(const char *stream_type, stream_conf_info_s *info)
                                                        2000,
                                                        NULL,
                                                        &err);
-       if (!result && err) {
+       if (!result) {
                LOGE("g_dbus_connection_call_sync() for GET_STREAM_INFO error (%s)", err->message);
                g_error_free(err);
                ret = MM_ERROR_SOUND_INTERNAL;
-       } else {
-               GVariantIter iter;
-               GVariant *item = NULL;
-               gchar *name = NULL;
-               gsize size = 0;
-               int i = 0;
+               goto LEAVE;
+       }
 
-               /* get priority */
-               child = g_variant_get_child_value(result, 0);
-               item = g_variant_get_variant(child);
-               info->priority = g_variant_get_int32(item);
-               g_variant_unref(item);
-               g_variant_unref(child);
-               LOGI("priority(%d)", info->priority);
-
-               /* get route type */
-               child = g_variant_get_child_value(result, 1);
-               item = g_variant_get_variant(child);
-               info->route_type = g_variant_get_int32(item);
-               g_variant_unref(item);
-               g_variant_unref(child);
-               LOGI("route_type(%d)", info->route_type);
-
-               /* get volume types */
-               child = g_variant_get_child_value(result, 2);
-               item = g_variant_get_variant(child);
-               g_variant_iter_init(&iter, item);
-               while (g_variant_iter_loop(&iter, "&s", &name)) {
-                       if (name && !strncmp(name, "none", strlen("none"))) {
-                               /* skip it */
-                       } else {
-                               /* we use volume type only for out direction */
-                               if (name) {
-                                       LOGI(" volume-type : %s", name);
-                                       info->volume_type = strdup(name);
-                                       break;
-                               }
-                       }
+       /* get priority */
+       child = g_variant_get_child_value(result, 0);
+       item = g_variant_get_variant(child);
+       info->priority = g_variant_get_int32(item);
+       g_variant_unref(item);
+       g_variant_unref(child);
+       LOGI("priority(%d)", info->priority);
+
+       /* get route type */
+       child = g_variant_get_child_value(result, 1);
+       item = g_variant_get_variant(child);
+       info->route_type = g_variant_get_int32(item);
+       g_variant_unref(item);
+       g_variant_unref(child);
+       LOGI("route_type(%d)", info->route_type);
+
+       /* get volume types */
+       child = g_variant_get_child_value(result, 2);
+       item = g_variant_get_variant(child);
+       g_variant_iter_init(&iter, item);
+       while (g_variant_iter_loop(&iter, "&s", &name)) {
+               if (name && !strncmp(name, "none", strlen("none")))
+                       continue;
+               /* we use volume type only for out direction */
+               if (name) {
+                       LOGI(" volume-type : %s", name);
+                       info->volume_type = strdup(name);
+                       break;
                }
-               g_variant_unref(item);
-               g_variant_unref(child);
-
-               /* get availabe in-devices */
-               child = g_variant_get_child_value(result, 3);
-               item = g_variant_get_variant(child);
-               size = g_variant_n_children(item);
-               LOGI("num of avail-in-devices are %d", size);
-               g_variant_iter_init(&iter, item);
-               i = 0;
-               while (g_variant_iter_loop(&iter, "&s", &name)) {
-                       if (size == 1 && !strncmp(name, "none", strlen("none"))) {
-                               LOGI(" in-device is [%s], skip it", name);
-                               break;
-                       } else {
-                               LOGI(" in-device name : %s", name);
-                               info->avail_in_devices[i++] = strdup(name);
-                       }
+       }
+       g_variant_unref(item);
+       g_variant_unref(child);
+
+       /* get availabe in-devices */
+       child = g_variant_get_child_value(result, 3);
+       item = g_variant_get_variant(child);
+       size = g_variant_n_children(item);
+       LOGI("num of avail-in-devices are %d", size);
+       g_variant_iter_init(&iter, item);
+       i = 0;
+       while (g_variant_iter_loop(&iter, "&s", &name)) {
+               if (size == 1 && !strncmp(name, "none", strlen("none"))) {
+                       LOGI(" in-device is [%s], skip it", name);
+                       break;
                }
-               g_variant_unref(item);
-               g_variant_unref(child);
-
-               /* get available out-devices */
-               child = g_variant_get_child_value(result, 4);
-               item = g_variant_get_variant(child);
-               size = g_variant_n_children(item);
-               LOGI("num of avail-out-devices are %d", size);
-               g_variant_iter_init(&iter, item);
-               i = 0;
-               while (g_variant_iter_loop(&iter, "&s", &name)) {
-                       if (size == 1 && !strncmp(name, "none", strlen("none"))) {
-                               LOGI(" out-device is [%s], skip it", name);
-                               break;
-                       } else {
-                               LOGI(" out-device name : %s", name);
-                               info->avail_out_devices[i++] = strdup(name);
-                       }
+               LOGI(" in-device name : %s", name);
+               info->avail_in_devices[i++] = strdup(name);
+       }
+       g_variant_unref(item);
+       g_variant_unref(child);
+
+       /* get available out-devices */
+       child = g_variant_get_child_value(result, 4);
+       item = g_variant_get_variant(child);
+       size = g_variant_n_children(item);
+       LOGI("num of avail-out-devices are %d", size);
+       g_variant_iter_init(&iter, item);
+       i = 0;
+       while (g_variant_iter_loop(&iter, "&s", &name)) {
+               if (size == 1 && !strncmp(name, "none", strlen("none"))) {
+                       LOGI(" out-device is [%s], skip it", name);
+                       break;
                }
-               g_variant_unref(item);
-               g_variant_unref(child);
-
-               /* get available frameworks */
-               child = g_variant_get_child_value(result, 5);
-               item = g_variant_get_variant(child);
-               size = g_variant_n_children(item);
-               LOGI("num of avail-frameworks are %d", size);
-               g_variant_iter_init(&iter, item);
-               i = 0;
-               while (g_variant_iter_loop(&iter, "&s", &name)) {
-                       if (size == 1 && !strncmp(name, "none", strlen("none"))) {
-                               LOGI(" framework is [%s], skip it", name);
-                               break;
-                       } else {
-                               LOGI(" framework name : %s", name);
-                               info->avail_frameworks[i++] = strdup(name);
-                       }
+               LOGI(" out-device name : %s", name);
+               info->avail_out_devices[i++] = strdup(name);
+       }
+       g_variant_unref(item);
+       g_variant_unref(child);
+
+       /* get available frameworks */
+       child = g_variant_get_child_value(result, 5);
+       item = g_variant_get_variant(child);
+       size = g_variant_n_children(item);
+       LOGI("num of avail-frameworks are %d", size);
+       g_variant_iter_init(&iter, item);
+       i = 0;
+       while (g_variant_iter_loop(&iter, "&s", &name)) {
+               if (size == 1 && !strncmp(name, "none", strlen("none"))) {
+                       LOGI(" framework is [%s], skip it", name);
+                       break;
                }
-               g_variant_unref(item);
-               g_variant_unref(child);
-               g_variant_unref(result);
+               LOGI(" framework name : %s", name);
+               info->avail_frameworks[i++] = strdup(name);
+       }
+       g_variant_unref(item);
+       g_variant_unref(child);
+       g_variant_unref(result);
 
-               if (info->priority == -1) {
-                       LOGE("could not find the info of stream type(%s)", *stream_type);
-                       ret = MM_ERROR_SOUND_INTERNAL;
-               }
+       if (info->priority == -1) {
+               LOGE("could not find the info of stream type(%s)", *stream_type);
+               ret = MM_ERROR_SOUND_INTERNAL;
        }
+
+LEAVE:
        g_object_unref(conn);
+
        return ret;
 }
 
@@ -697,11 +699,12 @@ int _set_manual_route_info(unsigned int index, manual_route_info_s *info)
        GVariant *result = NULL;
        GDBusConnection *conn = NULL;
        GError *err = NULL;
+       const gchar *dbus_ret = NULL;
 
        assert(info);
 
        conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
-       if (!conn && err) {
+       if (!conn) {
                LOGE("g_bus_get_sync() error (%s)", err->message);
                g_error_free(err);
                return MM_ERROR_SOUND_INTERNAL;
@@ -712,20 +715,16 @@ int _set_manual_route_info(unsigned int index, manual_route_info_s *info)
        builder_for_in_devices = g_variant_builder_new(G_VARIANT_TYPE("au"));
        builder_for_out_devices = g_variant_builder_new(G_VARIANT_TYPE("au"));
        for (i = 0; i < AVAIL_DEVICES_MAX; i++) {
-               if (info->route_in_devices[i]) {
-                       g_variant_builder_add(builder_for_in_devices, "u", info->route_in_devices[i]);
-                       LOGI("[IN] device_id:%u", info->route_in_devices[i]);
-               } else {
+               if (!info->route_in_devices[i])
                        break;
-               }
+               g_variant_builder_add(builder_for_in_devices, "u", info->route_in_devices[i]);
+               LOGI("[IN] device_id:%u", info->route_in_devices[i]);
        }
        for (i = 0; i < AVAIL_DEVICES_MAX; i++) {
-               if (info->route_out_devices[i]) {
-                       g_variant_builder_add(builder_for_out_devices, "u", info->route_out_devices[i]);
-                       LOGI("[OUT] device_id:%u", info->route_out_devices[i]);
-               } else {
+               if (!info->route_out_devices[i])
                        break;
-               }
+               g_variant_builder_add(builder_for_out_devices, "u", info->route_out_devices[i]);
+               LOGI("[OUT] device_id:%u", info->route_out_devices[i]);
        }
 
        result = g_dbus_connection_call_sync(conn,
@@ -739,24 +738,26 @@ int _set_manual_route_info(unsigned int index, manual_route_info_s *info)
                                                        2000,
                                                        NULL,
                                                        &err);
-       if (!result && err) {
+       if (!result) {
                LOGE("g_dbus_connection_call_sync() for SET_STREAM_ROUTE_DEVICES error (%s)", err->message);
                g_error_free(err);
                ret = MM_ERROR_SOUND_INTERNAL;
-       } else {
-               const gchar *dbus_ret = NULL;
-               g_variant_get(result, "(&s)", &dbus_ret);
-               LOGI("g_dbus_connection_call_sync() success, method return value is (%s)", dbus_ret);
-               if (strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret)))
-                       ret = MM_ERROR_SOUND_INVALID_STATE;
-               else
-                       info->is_set = true;
-
-               g_variant_unref(result);
+               goto LEAVE;
        }
+
+       g_variant_get(result, "(&s)", &dbus_ret);
+       LOGI("g_dbus_connection_call_sync() success, method return value is (%s)", dbus_ret);
+       if (strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret)))
+               ret = MM_ERROR_SOUND_INVALID_STATE;
+       else
+               info->is_set = true;
+
+       g_variant_unref(result);
        g_variant_builder_unref(builder_for_in_devices);
        g_variant_builder_unref(builder_for_out_devices);
+LEAVE:
        g_object_unref(conn);
+
        return ret;
 }
 
@@ -766,6 +767,7 @@ int _set_route_option(unsigned int index, const char *name, int value)
        GVariant *result = NULL;
        GDBusConnection *conn = NULL;
        GError *err = NULL;
+       const gchar *dbus_ret = NULL;
 
        assert(name);
 
@@ -778,7 +780,6 @@ int _set_route_option(unsigned int index, const char *name, int value)
 
        LOGI("[OPTION] %s(%d)", name, value);
 
-
        result = g_dbus_connection_call_sync(conn,
                                                        PA_BUS_NAME,
                                                        PA_STREAM_MANAGER_OBJECT_PATH,
@@ -790,22 +791,24 @@ int _set_route_option(unsigned int index, const char *name, int value)
                                                        2000,
                                                        NULL,
                                                        &err);
-       if (!result && err) {
+       if (!result) {
                LOGE("g_dbus_connection_call_sync() for SET_STREAM_ROUTE_OPTION error (%s)", err->message);
                g_error_free(err);
                ret = MM_ERROR_SOUND_INTERNAL;
-       } else {
-               const gchar *dbus_ret = NULL;
-               g_variant_get(result, "(&s)", &dbus_ret);
-               LOGI("g_dbus_connection_call_sync() success, method return value is (%s)", dbus_ret);
-               if (!strncmp("STREAM_MANAGER_RETURN_ERROR_NO_STREAM", dbus_ret, strlen(dbus_ret)))
-                       ret = MM_ERROR_SOUND_INVALID_STATE;
-               else if (strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret)))
-                       ret = MM_ERROR_SOUND_INTERNAL;
-
-               g_variant_unref(result);
+               goto LEAVE;
        }
+
+       g_variant_get(result, "(&s)", &dbus_ret);
+       LOGI("g_dbus_connection_call_sync() success, method return value is (%s)", dbus_ret);
+       if (!strncmp("STREAM_MANAGER_RETURN_ERROR_NO_STREAM", dbus_ret, strlen(dbus_ret)))
+               ret = MM_ERROR_SOUND_INVALID_STATE;
+       else if (strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret)))
+               ret = MM_ERROR_SOUND_INTERNAL;
+
+       g_variant_unref(result);
+LEAVE:
        g_object_unref(conn);
+
        return ret;
 }
 
@@ -815,13 +818,14 @@ int _get_volume_max_level(const char *direction, const char *volume_type, unsign
        GVariant *result = NULL;
        GDBusConnection *conn = NULL;
        GError *err = NULL;
+       const gchar *dbus_ret = NULL;
 
        assert(direction);
        assert(volume_type);
        assert(max_level);
 
        conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
-       if (!conn && err) {
+       if (!conn) {
                LOGE("g_bus_get_sync() error (%s)", err->message);
                g_error_free(err);
                return MM_ERROR_SOUND_INTERNAL;
@@ -838,20 +842,22 @@ int _get_volume_max_level(const char *direction, const char *volume_type, unsign
                                                        2000,
                                                        NULL,
                                                        &err);
-       if (!result && err) {
+       if (!result) {
                LOGE("g_dbus_connection_call_sync() for GET_VOLUME_MAX_LEVEL error (%s)", err->message);
                g_error_free(err);
                ret = MM_ERROR_SOUND_INTERNAL;
-       } else {
-               const gchar *dbus_ret = NULL;
-               g_variant_get(result, "(u&s)", max_level, &dbus_ret);
-               LOGI("g_dbus_connection_call_sync() success, method return value is (%u, %s)", *max_level, dbus_ret);
-               if (strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret)))
-                       ret = MM_ERROR_SOUND_INTERNAL;
-
-               g_variant_unref(result);
+               goto LEAVE;
        }
+
+       g_variant_get(result, "(u&s)", max_level, &dbus_ret);
+       LOGI("g_dbus_connection_call_sync() success, method return value is (%u, %s)", *max_level, dbus_ret);
+       if (strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret)))
+               ret = MM_ERROR_SOUND_INTERNAL;
+
+       g_variant_unref(result);
+LEAVE:
        g_object_unref(conn);
+
        return ret;
 }
 
@@ -861,13 +867,14 @@ int _get_volume_level(const char *direction, const char *volume_type, unsigned i
        GVariant *result = NULL;
        GDBusConnection *conn = NULL;
        GError *err = NULL;
+       const gchar *dbus_ret = NULL;
 
        assert(direction);
        assert(volume_type);
        assert(level);
 
        conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
-       if (!conn && err) {
+       if (!conn) {
                LOGE("g_bus_get_sync() error (%s)", err->message);
                g_error_free(err);
                return MM_ERROR_SOUND_INTERNAL;
@@ -884,20 +891,22 @@ int _get_volume_level(const char *direction, const char *volume_type, unsigned i
                                                        2000,
                                                        NULL,
                                                        &err);
-       if (!result && err) {
+       if (!result) {
                LOGE("g_dbus_connection_call_sync() for GET_VOLUME_LEVEL error (%s)", err->message);
                g_error_free(err);
                ret = MM_ERROR_SOUND_INTERNAL;
-       } else {
-               const gchar *dbus_ret = NULL;
-               g_variant_get(result, "(u&s)", level, &dbus_ret);
-               LOGI("g_dbus_connection_call_sync() success, method return value is (%u, %s)", *level, dbus_ret);
-               if (strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret)))
-                       ret = MM_ERROR_SOUND_INTERNAL;
-
-               g_variant_unref(result);
+               goto LEAVE;
        }
+
+       g_variant_get(result, "(u&s)", level, &dbus_ret);
+       LOGI("g_dbus_connection_call_sync() success, method return value is (%u, %s)", *level, dbus_ret);
+       if (strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret)))
+               ret = MM_ERROR_SOUND_INTERNAL;
+
+       g_variant_unref(result);
+LEAVE:
        g_object_unref(conn);
+
        return ret;
 }
 
@@ -907,12 +916,15 @@ int _set_volume_level(const char *direction, const char *volume_type, unsigned i
        GVariant *result = NULL;
        GDBusConnection *conn = NULL;
        GError *err = NULL;
+       const gchar *dbus_ret = NULL;
+       int vret = 0;
+       char volume_path[VCONF_PATH_MAX] = {0,};
 
        assert(direction);
        assert(volume_type);
 
        conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
-       if (!conn && err) {
+       if (!conn) {
                LOGE("g_bus_get_sync() error (%s)", err->message);
                g_error_free(err);
                return MM_ERROR_SOUND_INTERNAL;
@@ -929,27 +941,27 @@ int _set_volume_level(const char *direction, const char *volume_type, unsigned i
                                                        2000,
                                                        NULL,
                                                        &err);
-       if (!result && err) {
+       if (!result) {
                LOGE("g_dbus_connection_call_sync() for SET_VOLUME_LEVEL error (%s)", err->message);
                g_error_free(err);
                ret = MM_ERROR_SOUND_INTERNAL;
-       } else {
-               const gchar *dbus_ret = NULL;
-               g_variant_get(result, "(&s)", &dbus_ret);
-               LOGI("g_dbus_connection_call_sync() success, method return value is (%s)", dbus_ret);
-               if (strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret)))
-                       ret = MM_ERROR_SOUND_INTERNAL;
-               else {
-                       int vret = 0;
-                       char volume_path[VCONF_PATH_MAX] = {0,};
-                       /* Set volume value to VCONF */
-                       snprintf(volume_path, sizeof(volume_path)-1, "%s%s", VCONF_PATH_PREFIX_VOLUME, volume_type);
-                       if ((vret = vconf_set_int(volume_path, (int)level)))
-                               LOGE("vconf_set_int(%s) failed..ret[%d]\n", volume_path, vret);
-               }
-               g_variant_unref(result);
+               goto LEAVE;
        }
+
+       g_variant_get(result, "(&s)", &dbus_ret);
+       LOGI("g_dbus_connection_call_sync() success, method return value is (%s)", dbus_ret);
+       if (strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret)))
+               ret = MM_ERROR_SOUND_INTERNAL;
+       else {
+               /* Set volume value to VCONF */
+               snprintf(volume_path, sizeof(volume_path)-1, "%s%s", VCONF_PATH_PREFIX_VOLUME, volume_type);
+               if ((vret = vconf_set_int(volume_path, (int)level)))
+                       LOGE("vconf_set_int(%s) failed..ret[%d]\n", volume_path, vret);
+       }
+       g_variant_unref(result);
+LEAVE:
        g_object_unref(conn);
+
        return ret;
 }
 
@@ -959,12 +971,14 @@ int _get_current_volume_type(const char *direction, char **volume_type)
        GVariant *result = NULL;
        GDBusConnection *conn = NULL;
        GError *err = NULL;
+       const gchar *dbus_volume_type = NULL;
+       const gchar *dbus_ret = NULL;
 
        assert(direction);
        assert(volume_type);
 
        conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
-       if (!conn && err) {
+       if (!conn) {
                LOGE("g_bus_get_sync() error (%s)", err->message);
                g_error_free(err);
                return MM_ERROR_SOUND_INTERNAL;
@@ -981,26 +995,27 @@ int _get_current_volume_type(const char *direction, char **volume_type)
                                                        2000,
                                                        NULL,
                                                        &err);
-       if (!result && err) {
+       if (!result) {
                LOGE("g_dbus_connection_call_sync() for GET_CURRENT_VOLUME_TYPE error (%s)", err->message);
                g_error_free(err);
                ret = MM_ERROR_SOUND_INTERNAL;
-       } else {
-               const gchar *dbus_volume_type = NULL;
-               const gchar *dbus_ret = NULL;
-               g_variant_get(result, "(&s&s)", &dbus_volume_type, &dbus_ret);
-               LOGI("g_dbus_connection_call_sync() success, method return value is (%s, %s)", dbus_volume_type, dbus_ret);
-               if (!strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret))) {
-                       ret = MM_ERROR_NONE;
-                       *volume_type = strdup(dbus_volume_type);
-               } else if (!strncmp("STREAM_MANAGER_RETURN_ERROR_NO_STREAM", dbus_ret, strlen(dbus_ret)))
-                       ret = MM_ERROR_SOUND_VOLUME_NO_INSTANCE;
-               else
-                       ret = MM_ERROR_SOUND_INTERNAL;
-
-               g_variant_unref(result);
+               goto LEAVE;
        }
+
+       g_variant_get(result, "(&s&s)", &dbus_volume_type, &dbus_ret);
+       LOGI("g_dbus_connection_call_sync() success, method return value is (%s, %s)", dbus_volume_type, dbus_ret);
+       if (!strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret))) {
+               ret = MM_ERROR_NONE;
+               *volume_type = strdup(dbus_volume_type);
+       } else if (!strncmp("STREAM_MANAGER_RETURN_ERROR_NO_STREAM", dbus_ret, strlen(dbus_ret)))
+               ret = MM_ERROR_SOUND_VOLUME_NO_INSTANCE;
+       else
+               ret = MM_ERROR_SOUND_INTERNAL;
+
+       g_variant_unref(result);
+LEAVE:
        g_object_unref(conn);
+
        return ret;
 }
 
@@ -1009,9 +1024,10 @@ void _update_focus_status(unsigned int index, unsigned int acquired_focus_status
        GVariant *result = NULL;
        GDBusConnection *conn = NULL;
        GError *err = NULL;
+       const gchar *dbus_ret = NULL;
 
        conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
-       if (!conn && err) {
+       if (!conn) {
                LOGE("g_bus_get_sync() error (%s)", err->message);
                g_error_free(err);
                return;
@@ -1028,19 +1044,20 @@ void _update_focus_status(unsigned int index, unsigned int acquired_focus_status
                                                        2000,
                                                        NULL,
                                                        &err);
-       if (!result && err) {
+       if (!result) {
                LOGE("g_dbus_connection_call_sync() for UPDATE_FOCUS_STATUS error (%s)", err->message);
                g_error_free(err);
-       } else {
-               const gchar *dbus_ret = NULL;
-               g_variant_get(result, "(&s)", &dbus_ret);
-               LOGI("g_dbus_connection_call_sync() success, method return value is (%s)", dbus_ret);
-               if (strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret)))
-                       LOGE("failed to UPDATE_FOCUS_STATUS error (%s)", dbus_ret);
-
-               g_variant_unref(result);
+               goto LEAVE;
        }
+       g_variant_get(result, "(&s)", &dbus_ret);
+       LOGI("g_dbus_connection_call_sync() success, method return value is (%s)", dbus_ret);
+       if (strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret)))
+               LOGE("failed to UPDATE_FOCUS_STATUS error (%s)", dbus_ret);
+
+       g_variant_unref(result);
+LEAVE:
        g_object_unref(conn);
+
        return;
 }
 
@@ -1062,29 +1079,34 @@ void _focus_session_interrupt_cb(mm_sound_focus_state_e state, const char *reaso
                }
                g_session_interrupt_cb_table.user_cb(e, g_session_interrupt_cb_table.user_data);
        }
+
+       return;
 }
 
 void _device_connected_cb(sound_device_h device, bool is_connected, void *user_data)
 {
        mm_sound_device_type_e type;
-       if (mm_sound_get_device_type(device, &type) != MM_ERROR_NONE)
+       if (mm_sound_get_device_type(device, &type) != MM_ERROR_NONE) {
                LOGE("getting device type failed");
-       else {
-               switch (type) {
-               case MM_SOUND_DEVICE_TYPE_AUDIOJACK:
-               case MM_SOUND_DEVICE_TYPE_BLUETOOTH:
-               case MM_SOUND_DEVICE_TYPE_HDMI:
-               case MM_SOUND_DEVICE_TYPE_MIRRORING:
-               case MM_SOUND_DEVICE_TYPE_USB_AUDIO:
-                       if (!is_connected) {
-                               LOGI("sound device unplugged");
-                               g_session_interrupt_cb_table.user_cb(SOUND_SESSION_INTERRUPTED_BY_EARJACK_UNPLUG, g_session_interrupt_cb_table.user_data);
-                       }
-                       break;
-               default:
-                       break;
+               return;
+       }
+
+       switch (type) {
+       case MM_SOUND_DEVICE_TYPE_AUDIOJACK:
+       case MM_SOUND_DEVICE_TYPE_BLUETOOTH:
+       case MM_SOUND_DEVICE_TYPE_HDMI:
+       case MM_SOUND_DEVICE_TYPE_MIRRORING:
+       case MM_SOUND_DEVICE_TYPE_USB_AUDIO:
+               if (!is_connected) {
+                       LOGI("sound device unplugged");
+                       g_session_interrupt_cb_table.user_cb(SOUND_SESSION_INTERRUPTED_BY_EARJACK_UNPLUG, g_session_interrupt_cb_table.user_data);
                }
+               break;
+       default:
+               break;
        }
+
+       return;
 }
 
 /* This is an internal callback for the VOIP SESSION */
@@ -1344,10 +1366,9 @@ int _make_pa_connection_and_register_focus(sound_stream_info_s *stream_h, sound_
        ret = mm_sound_focus_is_cb_thread(&is_focus_cb_thread);
        if (ret)
                return ret;
-       else {
-               if (is_focus_cb_thread)
-                       return MM_ERROR_SOUND_INVALID_OPERATION;
-       }
+
+       if (is_focus_cb_thread)
+               return MM_ERROR_SOUND_INVALID_OPERATION;
 
        if (!(stream_h->pa_mainloop = pa_threaded_mainloop_new()))
                goto PA_ERROR;
@@ -1462,10 +1483,9 @@ int _destroy_pa_connection_and_unregister_focus(sound_stream_info_s *stream_h)
        ret = mm_sound_focus_is_cb_thread(&is_focus_cb_thread);
        if (ret)
                return ret;
-       else {
-               if (is_focus_cb_thread)
-                       return MM_ERROR_SOUND_INVALID_OPERATION;
-       }
+
+       if (is_focus_cb_thread)
+               return MM_ERROR_SOUND_INVALID_OPERATION;
 
        if (stream_h->pa_context) {
                pa_context_disconnect(stream_h->pa_context);
@@ -1549,43 +1569,41 @@ int _add_device_for_stream_routing(sound_stream_info_s *stream_info, sound_devic
 
                if (device_direction == MM_SOUND_DEVICE_IO_DIRECTION_IN || device_direction == MM_SOUND_DEVICE_IO_DIRECTION_BOTH) {
                        for (i = 0; i < AVAIL_DEVICES_MAX; i++) {
-                               if (stream_info->stream_conf_info.avail_in_devices[i]) {
-                                       if (!strncmp(stream_info->stream_conf_info.avail_in_devices[i], device_type_str, SOUND_DEVICE_TYPE_LEN)) {
-                                               for (j = 0; j < AVAIL_DEVICES_MAX; j++) {
-                                                       if (!stream_info->manual_route_info.route_in_devices[j]) {
-                                                               stream_info->manual_route_info.route_in_devices[j] = (unsigned int)device_id;
-                                                               added_successfully = true;
-                                                               break;
-                                                       }
-                                                       if (stream_info->manual_route_info.route_in_devices[j] == (unsigned int)device_id) {
-                                                               /* it was already set */
-                                                               return _convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_DUPLICATED);
-                                                       }
+                               if (!stream_info->stream_conf_info.avail_in_devices[i])
+                                       break;
+
+                               if (!strncmp(stream_info->stream_conf_info.avail_in_devices[i], device_type_str, SOUND_DEVICE_TYPE_LEN)) {
+                                       for (j = 0; j < AVAIL_DEVICES_MAX; j++) {
+                                               if (!stream_info->manual_route_info.route_in_devices[j]) {
+                                                       stream_info->manual_route_info.route_in_devices[j] = (unsigned int)device_id;
+                                                       added_successfully = true;
+                                                       break;
+                                               }
+                                               if (stream_info->manual_route_info.route_in_devices[j] == (unsigned int)device_id) {
+                                                       /* it was already set */
+                                                       return _convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_DUPLICATED);
                                                }
                                        }
-                               } else {
-                                       break;
                                }
                        }
                }
                if (device_direction == MM_SOUND_DEVICE_IO_DIRECTION_OUT || device_direction == MM_SOUND_DEVICE_IO_DIRECTION_BOTH) {
                        for (i = 0; i < AVAIL_DEVICES_MAX; i++) {
-                               if (stream_info->stream_conf_info.avail_out_devices[i]) {
-                                       if (!strncmp(stream_info->stream_conf_info.avail_out_devices[i], device_type_str, SOUND_DEVICE_TYPE_LEN)) {
-                                               for (j = 0; j < AVAIL_DEVICES_MAX; j++) {
-                                                       if (!stream_info->manual_route_info.route_out_devices[j]) {
-                                                               stream_info->manual_route_info.route_out_devices[j] = (unsigned int)device_id;
-                                                               added_successfully = true;
-                                                               break;
-                                                       }
-                                                       if (stream_info->manual_route_info.route_out_devices[j] == (unsigned int)device_id) {
-                                                               /* it was already set */
-                                                               return _convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_DUPLICATED);
-                                                       }
+                               if (!stream_info->stream_conf_info.avail_out_devices[i])
+                                       break;
+
+                               if (!strncmp(stream_info->stream_conf_info.avail_out_devices[i], device_type_str, SOUND_DEVICE_TYPE_LEN)) {
+                                       for (j = 0; j < AVAIL_DEVICES_MAX; j++) {
+                                               if (!stream_info->manual_route_info.route_out_devices[j]) {
+                                                       stream_info->manual_route_info.route_out_devices[j] = (unsigned int)device_id;
+                                                       added_successfully = true;
+                                                       break;
+                                               }
+                                               if (stream_info->manual_route_info.route_out_devices[j] == (unsigned int)device_id) {
+                                                       /* it was already set */
+                                                       return _convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_DUPLICATED);
                                                }
                                        }
-                               } else {
-                                       break;
                                }
                        }
                }
@@ -1626,35 +1644,33 @@ int _remove_device_for_stream_routing(sound_stream_info_s *stream_info, sound_de
 
                if (device_direction == MM_SOUND_DEVICE_IO_DIRECTION_IN || device_direction == MM_SOUND_DEVICE_IO_DIRECTION_BOTH) {
                        for (i = 0; i < AVAIL_DEVICES_MAX; i++) {
-                               if (stream_info->stream_conf_info.avail_in_devices[i]) {
-                                       if (!strncmp(stream_info->stream_conf_info.avail_in_devices[i], device_type_str, SOUND_DEVICE_TYPE_LEN)) {
-                                               for (j = 0; j < AVAIL_DEVICES_MAX; j++) {
-                                                       if (stream_info->manual_route_info.route_in_devices[j] == (unsigned int)device_id) {
-                                                               removed_successfully = true;
-                                                               stream_info->manual_route_info.route_in_devices[j] = 0;
-                                                               break;
-                                                       }
+                               if (!stream_info->stream_conf_info.avail_in_devices[i])
+                                       break;
+
+                               if (!strncmp(stream_info->stream_conf_info.avail_in_devices[i], device_type_str, SOUND_DEVICE_TYPE_LEN)) {
+                                       for (j = 0; j < AVAIL_DEVICES_MAX; j++) {
+                                               if (stream_info->manual_route_info.route_in_devices[j] == (unsigned int)device_id) {
+                                                       removed_successfully = true;
+                                                       stream_info->manual_route_info.route_in_devices[j] = 0;
+                                                       break;
                                                }
                                        }
-                               } else {
-                                       break;
                                }
                        }
                }
                if (device_direction == MM_SOUND_DEVICE_IO_DIRECTION_OUT || device_direction == MM_SOUND_DEVICE_IO_DIRECTION_BOTH) {
                        for (i = 0; i < AVAIL_DEVICES_MAX; i++) {
-                               if (stream_info->stream_conf_info.avail_out_devices[i]) {
-                                       if (!strncmp(stream_info->stream_conf_info.avail_out_devices[i], device_type_str, SOUND_DEVICE_TYPE_LEN)) {
-                                               for (j = 0; j < AVAIL_DEVICES_MAX; j++) {
-                                                       if (stream_info->manual_route_info.route_out_devices[j] == (unsigned int)device_id) {
-                                                               removed_successfully = true;
-                                                               stream_info->manual_route_info.route_out_devices[j] = 0;
-                                                               break;
-                                                       }
+                               if (!stream_info->stream_conf_info.avail_out_devices[i])
+                                       break;
+
+                               if (!strncmp(stream_info->stream_conf_info.avail_out_devices[i], device_type_str, SOUND_DEVICE_TYPE_LEN)) {
+                                       for (j = 0; j < AVAIL_DEVICES_MAX; j++) {
+                                               if (stream_info->manual_route_info.route_out_devices[j] == (unsigned int)device_id) {
+                                                       removed_successfully = true;
+                                                       stream_info->manual_route_info.route_out_devices[j] = 0;
+                                                       break;
                                                }
                                        }
-                               } else {
-                                       break;
                                }
                        }
                }
@@ -1716,24 +1732,28 @@ int _create_virtual_stream(sound_stream_info_s *stream_info, virtual_sound_strea
                }
        }
        LOGI("stream_type[%s], native api[%s], is_available[%d]", stream_info->stream_type, name, result);
-       if (result == true) {
-               (*virtual_stream) = malloc(sizeof(virtual_sound_stream_info_s));
-               if (!(*virtual_stream))
-                       ret = MM_ERROR_OUT_OF_MEMORY;
-               else {
-                       memset((*virtual_stream), 0, sizeof(virtual_sound_stream_info_s));
-                       (*virtual_stream)->stream_type = stream_info->stream_type;
-                       (*virtual_stream)->pa_mainloop = stream_info->pa_mainloop;
-                       (*virtual_stream)->pa_context = stream_info->pa_context;
-                       (*virtual_stream)->pa_proplist = pa_proplist_new();
-                       pa_proplist_sets((*virtual_stream)->pa_proplist, PA_PROP_MEDIA_ROLE, (*virtual_stream)->stream_type);
-                       pa_proplist_setf((*virtual_stream)->pa_proplist, PA_PROP_MEDIA_PARENT_ID, "%u", stream_info->index);
-                       (*virtual_stream)->state = _VSTREAM_STATE_READY;
-                       (*virtual_stream)->stream_info = stream_info;
-               }
-       } else
+       if (result == false) {
                ret = MM_ERROR_NOT_SUPPORT_API;
+               goto LEAVE;
+       }
+
+       (*virtual_stream) = malloc(sizeof(virtual_sound_stream_info_s));
+       if (!(*virtual_stream)) {
+               ret = MM_ERROR_OUT_OF_MEMORY;
+               goto LEAVE;
+       }
 
+       memset((*virtual_stream), 0, sizeof(virtual_sound_stream_info_s));
+       (*virtual_stream)->stream_type = stream_info->stream_type;
+       (*virtual_stream)->pa_mainloop = stream_info->pa_mainloop;
+       (*virtual_stream)->pa_context = stream_info->pa_context;
+       (*virtual_stream)->pa_proplist = pa_proplist_new();
+       pa_proplist_sets((*virtual_stream)->pa_proplist, PA_PROP_MEDIA_ROLE, (*virtual_stream)->stream_type);
+       pa_proplist_setf((*virtual_stream)->pa_proplist, PA_PROP_MEDIA_PARENT_ID, "%u", stream_info->index);
+       (*virtual_stream)->state = _VSTREAM_STATE_READY;
+       (*virtual_stream)->stream_info = stream_info;
+
+LEAVE:
        return ret;
 }