Remove useless converting error logic inside of stream focus APIs 58/237158/5
authorSangchul Lee <sc11.lee@samsung.com>
Thu, 25 Jun 2020 10:52:23 +0000 (19:52 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Fri, 26 Jun 2020 02:31:09 +0000 (11:31 +0900)
[Version] 0.6.14
[Issue Type] Refactoring

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

index 9c5708c..c00e82a 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-sound-manager
 Summary:    Sound Manager library
-Version:    0.6.13
+Version:    0.6.14
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index d1af457..26e9b56 100644 (file)
@@ -568,7 +568,6 @@ LEAVE:
 
 int sound_manager_get_focus_state(sound_stream_info_h stream_info, sound_stream_focus_state_e *state_for_playback, sound_stream_focus_state_e *state_for_recording)
 {
-       int ret = MM_ERROR_NONE;
        sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info;
 
        SM_ARG_CHECK(stream_h);
@@ -587,7 +586,7 @@ int sound_manager_get_focus_state(sound_stream_info_h stream_info, sound_stream_
 
        SM_LEAVE_CRITICAL_SECTION(&stream_h->focus_state_mutex);
 
-       return _convert_sound_manager_error_code(__func__, ret);
+       return SOUND_MANAGER_ERROR_NONE;
 }
 
 int sound_manager_deliver_focus(sound_stream_info_h source, sound_stream_info_h destination, sound_stream_focus_mask_e focus_mask)
@@ -674,7 +673,8 @@ int sound_manager_get_current_media_playback_device_type(sound_device_type_e *de
 
 int sound_manager_get_current_playback_focus(sound_stream_focus_change_reason_e *acquired_by, int *flags, char **extra_info)
 {
-       int ret = MM_ERROR_NONE;
+       int ret = SOUND_MANAGER_ERROR_NONE;
+       int mm_ret = MM_ERROR_NONE;
        char *stream_type_str = NULL;
        char *extra_info_str = NULL;
        int option = 0;
@@ -685,34 +685,36 @@ int sound_manager_get_current_playback_focus(sound_stream_focus_change_reason_e
 
        LOGI(">> enter");
 
-       if ((ret = mm_sound_focus_is_cb_thread(&is_focus_cb_thread, NULL)))
-               return _convert_sound_manager_error_code(__func__, ret);
+       if ((mm_ret = mm_sound_focus_is_cb_thread(&is_focus_cb_thread, NULL)))
+               return _convert_sound_manager_error_code(__func__, mm_ret);
 
        if (is_focus_cb_thread) {
                LOGE("this API should not be called in focus callback");
                return SOUND_MANAGER_ERROR_INVALID_OPERATION;
        }
 
-       ret = mm_sound_get_stream_type_of_acquired_focus((int)SOUND_STREAM_FOCUS_FOR_PLAYBACK, &stream_type_str, &option, &extra_info_str);
-       if (ret == MM_ERROR_NONE) {
-               LOGI("current acquired PLAYBACK focus : stream_type[%s]", stream_type_str);
-               ret = _convert_stream_type_to_change_reason(stream_type_str, acquired_by);
-               if (ret == MM_ERROR_NONE) {
-                       LOGI("                                : reason[%d], flags[0x%x], extra_info[%s]", *acquired_by, option, extra_info_str);
-                       *flags = option;
-                       if (extra_info)
-                               *extra_info = strdup(extra_info_str);
-               }
-               SM_SAFE_FREE(stream_type_str);
-               SM_SAFE_FREE(extra_info_str);
+       mm_ret = mm_sound_get_stream_type_of_acquired_focus((int)SOUND_STREAM_FOCUS_FOR_PLAYBACK, &stream_type_str, &option, &extra_info_str);
+       if (mm_ret)
+               return _convert_sound_manager_error_code(__func__, mm_ret);
+
+       LOGI("current acquired PLAYBACK focus : stream_type[%s]", stream_type_str);
+       ret = _convert_stream_type_to_change_reason(stream_type_str, acquired_by);
+       if (ret == SOUND_MANAGER_ERROR_NONE) {
+               LOGI("                                : reason[%d], flags[0x%x], extra_info[%s]", *acquired_by, option, extra_info_str);
+               *flags = option;
+               if (extra_info)
+                       *extra_info = strdup(extra_info_str);
        }
+       SM_SAFE_FREE(stream_type_str);
+       SM_SAFE_FREE(extra_info_str);
 
-       return _convert_sound_manager_error_code(__func__, ret);
+       return ret;
 }
 
 int sound_manager_get_current_recording_focus(sound_stream_focus_change_reason_e *acquired_by, int *flags, char **extra_info)
 {
-       int ret = MM_ERROR_NONE;
+       int ret = SOUND_MANAGER_ERROR_NONE;
+       int mm_ret = MM_ERROR_NONE;
        char *stream_type_str = NULL;
        char *extra_info_str = NULL;
        int option = 0;
@@ -723,29 +725,30 @@ int sound_manager_get_current_recording_focus(sound_stream_focus_change_reason_e
 
        LOGI(">> enter");
 
-       if ((ret = mm_sound_focus_is_cb_thread(&is_focus_cb_thread, NULL)))
-               return _convert_sound_manager_error_code(__func__, ret);
+       if ((mm_ret = mm_sound_focus_is_cb_thread(&is_focus_cb_thread, NULL)))
+               return _convert_sound_manager_error_code(__func__, mm_ret);
 
        if (is_focus_cb_thread) {
                LOGE("this API should not be called in focus callback");
                return SOUND_MANAGER_ERROR_INVALID_OPERATION;
        }
 
-       ret = mm_sound_get_stream_type_of_acquired_focus((int)SOUND_STREAM_FOCUS_FOR_RECORDING, &stream_type_str, &option, &extra_info_str);
-       if (ret == MM_ERROR_NONE) {
-               LOGI("current acquired RECORDING focus : stream_type[%s]", stream_type_str);
-               ret = _convert_stream_type_to_change_reason(stream_type_str, acquired_by);
-               if (ret == MM_ERROR_NONE) {
-                       LOGI("                                 : reason[%d], flags[0x%x], extra_info[%s]", *acquired_by, option, extra_info_str);
-                       *flags = option;
-                       if (extra_info)
-                               *extra_info = strdup(extra_info_str);
-               }
-               SM_SAFE_FREE(stream_type_str);
-               SM_SAFE_FREE(extra_info_str);
+       mm_ret = mm_sound_get_stream_type_of_acquired_focus((int)SOUND_STREAM_FOCUS_FOR_RECORDING, &stream_type_str, &option, &extra_info_str);
+       if (mm_ret)
+               return _convert_sound_manager_error_code(__func__, mm_ret);
+
+       LOGI("current acquired RECORDING focus : stream_type[%s]", stream_type_str);
+       ret = _convert_stream_type_to_change_reason(stream_type_str, acquired_by);
+       if (ret == SOUND_MANAGER_ERROR_NONE) {
+               LOGI("                                 : reason[%d], flags[0x%x], extra_info[%s]", *acquired_by, option, extra_info_str);
+               *flags = option;
+               if (extra_info)
+                       *extra_info = strdup(extra_info_str);
        }
+       SM_SAFE_FREE(stream_type_str);
+       SM_SAFE_FREE(extra_info_str);
 
-       return _convert_sound_manager_error_code(__func__, ret);
+       return ret;
 }
 
 int sound_manager_add_focus_state_watch_cb(sound_stream_focus_mask_e focus_mask, sound_stream_focus_state_watch_cb callback, void *user_data, int *id)
@@ -753,11 +756,11 @@ int sound_manager_add_focus_state_watch_cb(sound_stream_focus_mask_e focus_mask,
        int ret = MM_ERROR_NONE;
        int i = 0;
 
-       LOGI(">> enter");
-
        SM_ARG_CHECK(callback);
        SM_ARG_CHECK(id);
 
+       LOGI(">> enter");
+
        for (i = 0; i < SOUND_STREAM_INFO_ARR_MAX; i++)
                if (focus_watch_info_arr[i].id == 0)
                        break;
index 5bd5313..d0985e0 100644 (file)
@@ -314,8 +314,8 @@ 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)
 {
-       SM_NULL_ARG_CHECK_FOR_PRIV(stream_type);
-       SM_NULL_ARG_CHECK_FOR_PRIV(change_reason);
+       SM_ARG_CHECK(stream_type);
+       SM_ARG_CHECK(change_reason);
 
        if (!strncmp(stream_type, STREAM_MEDIA, SOUND_STREAM_TYPE_LEN) ||
                !strncmp(stream_type, STREAM_COMPRESSED_MEDIA, SOUND_STREAM_TYPE_LEN) ||
@@ -360,11 +360,11 @@ int _convert_stream_type_to_change_reason(const char *stream_type, sound_stream_
        } else {
                //LCOV_EXCL_START
                LOGE("not supported stream_type(%s)", stream_type);
-               return MM_ERROR_INVALID_ARGUMENT;
+               return SOUND_MANAGER_ERROR_INVALID_PARAMETER;
                //LCOV_EXCL_STOP
        }
 
-       return MM_ERROR_NONE;
+       return SOUND_MANAGER_ERROR_NONE;
 }
 
 static int __get_dbus_connection(GDBusConnection **conn)