Merge branch 'tizen' into tizen_line_coverage 40/204340/1 tizen_line_coverage
authorSangchul Lee <sc11.lee@samsung.com>
Tue, 23 Apr 2019 07:09:22 +0000 (16:09 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Tue, 23 Apr 2019 07:09:22 +0000 (16:09 +0900)
Change-Id: I860bd7c9d8bf82b4dfb2b50ea5bce7ea0fb482d3

src/sound_manager_private.c

index caec215..7c65474 100644 (file)
@@ -54,6 +54,7 @@
 
 #define DBUS_ERR_MSG_MAX                                        24
 
+//LCOV_EXCL_START
 int _convert_dbus_error(const char *error_msg)
 {
        int ret = MM_ERROR_NONE;
@@ -86,6 +87,7 @@ int _convert_dbus_error(const char *error_msg)
 
        return ret;
 }
+//LCOV_EXCL_STOP
 
 int _convert_sound_manager_error_code(const char *func, int code)
 {
@@ -121,8 +123,10 @@ int _convert_sound_manager_error_code(const char *func, int code)
        case MM_ERROR_SOUND_INTERNAL:
        case MM_ERROR_SOUND_VOLUME_CAPTURE_ONLY:
        case MM_ERROR_OUT_OF_MEMORY:
+               //LCOV_EXCL_START
                ret = SOUND_MANAGER_ERROR_INTERNAL;
                errorstr = "INTERNAL";
+               //LCOV_EXCL_STOP
                break;
        case MM_ERROR_POLICY_DUPLICATED:
        case MM_ERROR_POLICY_INTERNAL:
@@ -197,15 +201,18 @@ int _convert_stream_type(sound_stream_type_e stream_type_enum, char **stream_typ
                *stream_type = "ext-media";
                break;
        default:
+               //LCOV_EXCL_START
                LOGE("could not find the stream_type[%d] in this switch case statement", stream_type_enum);
                ret = MM_ERROR_SOUND_INTERNAL;
                break;
+               //LCOV_EXCL_STOP
        }
        LOGI("stream_type[%s]", *stream_type);
 
        return ret;
 }
 
+//LCOV_EXCL_START
 int _convert_stream_type_for_internal(sound_stream_type_internal_e stream_type_enum, char **stream_type)
 {
        int ret = MM_ERROR_NONE;
@@ -257,10 +264,8 @@ int _convert_stream_type_for_internal(sound_stream_type_internal_e stream_type_e
 void _set_focus_availability(sound_stream_info_s *stream_info)
 {
        if (stream_info == NULL || stream_info->stream_type == NULL) {
-               //LCOV_EXCL_START
                LOGE("invalid argument");
                return;
-               //LCOV_EXCL_STOP
        }
        if (!strncmp(stream_info->stream_type, "solo", SOUND_STREAM_TYPE_LEN) ||
                !strncmp(stream_info->stream_type, "radio", SOUND_STREAM_TYPE_LEN) ||
@@ -271,6 +276,7 @@ void _set_focus_availability(sound_stream_info_s *stream_info)
 
        return;
 }
+//LCOV_EXCL_STOP
 
 int _convert_stream_type_to_change_reason(const char *stream_type, sound_stream_focus_change_reason_e *change_reason)
 {
@@ -284,7 +290,7 @@ int _convert_stream_type_to_change_reason(const char *stream_type, sound_stream_
                *change_reason = SOUND_STREAM_FOCUS_CHANGED_BY_MEDIA;
 
        } else if (!strncmp(stream_type, "system", SOUND_STREAM_TYPE_LEN)) {
-               *change_reason = SOUND_STREAM_FOCUS_CHANGED_BY_SYSTEM;
+               *change_reason = SOUND_STREAM_FOCUS_CHANGED_BY_SYSTEM;//LCOV_EXCL_LINE
 
        } else if (!strncmp(stream_type, "alarm", SOUND_STREAM_TYPE_LEN)) {
                *change_reason = SOUND_STREAM_FOCUS_CHANGED_BY_ALARM;
@@ -293,10 +299,10 @@ int _convert_stream_type_to_change_reason(const char *stream_type, sound_stream_
                *change_reason = SOUND_STREAM_FOCUS_CHANGED_BY_NOTIFICATION;
 
        } else if (!strncmp(stream_type, "emergency", SOUND_STREAM_TYPE_LEN)) {
-               *change_reason = SOUND_STREAM_FOCUS_CHANGED_BY_EMERGENCY;
+               *change_reason = SOUND_STREAM_FOCUS_CHANGED_BY_EMERGENCY;//LCOV_EXCL_LINE
 
        } else if (!strncmp(stream_type, "voice-information", SOUND_STREAM_TYPE_LEN)) {
-               *change_reason = SOUND_STREAM_FOCUS_CHANGED_BY_VOICE_INFORMATION;
+               *change_reason = SOUND_STREAM_FOCUS_CHANGED_BY_VOICE_INFORMATION;//LCOV_EXCL_LINE
 
        } else if (!strncmp(stream_type, "voice-recognition", SOUND_STREAM_TYPE_LEN) ||
                        !strncmp(stream_type, "voice-recognition-service", SOUND_STREAM_TYPE_LEN)) {
@@ -312,7 +318,7 @@ int _convert_stream_type_to_change_reason(const char *stream_type, sound_stream_
 
        } else if (!strncmp(stream_type, "call-voice", SOUND_STREAM_TYPE_LEN) ||
                        !strncmp(stream_type, "call-video", SOUND_STREAM_TYPE_LEN)) {
-               *change_reason = SOUND_STREAM_FOCUS_CHANGED_BY_CALL;
+               *change_reason = SOUND_STREAM_FOCUS_CHANGED_BY_CALL;//LCOV_EXCL_LINE
 
        } else if (!strncmp(stream_type, "ext-media", SOUND_STREAM_TYPE_LEN)) {
                *change_reason = SOUND_STREAM_FOCUS_CHANGED_BY_MEDIA_EXTERNAL_ONLY;
@@ -387,17 +393,17 @@ int _convert_sound_type_to_enum(const char *sound_type, sound_type_e *sound_type
        SM_NULL_ARG_CHECK_FOR_PRIV(sound_type_enum);
 
        if (!strncmp(sound_type, "system", strlen(sound_type))) {
-               *sound_type_enum = SOUND_TYPE_SYSTEM;
+               *sound_type_enum = SOUND_TYPE_SYSTEM;//LCOV_EXCL_LINE
        } else if (!strncmp(sound_type, "notification", strlen(sound_type))) {
-               *sound_type_enum = SOUND_TYPE_NOTIFICATION;
+               *sound_type_enum = SOUND_TYPE_NOTIFICATION;//LCOV_EXCL_LINE
        } else if (!strncmp(sound_type, "alarm", strlen(sound_type))) {
                *sound_type_enum = SOUND_TYPE_ALARM;
        } else if (!strncmp(sound_type, "ringtone", strlen(sound_type))) {
-               *sound_type_enum = SOUND_TYPE_RINGTONE;
+               *sound_type_enum = SOUND_TYPE_RINGTONE;//LCOV_EXCL_LINE
        } else if (!strncmp(sound_type, "media", strlen(sound_type))) {
                *sound_type_enum = SOUND_TYPE_MEDIA;
        } else if (!strncmp(sound_type, "call", strlen(sound_type))) {
-               *sound_type_enum = SOUND_TYPE_CALL;
+               *sound_type_enum = SOUND_TYPE_CALL;//LCOV_EXCL_LINE
        } else if (!strncmp(sound_type, "voip", strlen(sound_type))) {
                *sound_type_enum = SOUND_TYPE_VOIP;
        } else if (!strncmp(sound_type, "voice", strlen(sound_type))) {
@@ -411,7 +417,7 @@ int _convert_sound_type_to_enum(const char *sound_type, sound_type_e *sound_type
 
        return MM_ERROR_NONE;
 }
-
+//LCOV_EXCL_START
 int _convert_device_type_enum_to_str(sound_device_type_e device_type, char **device_type_str)
 {
        SM_NULL_ARG_CHECK_FOR_PRIV(device_type_str);
@@ -426,7 +432,6 @@ int _convert_device_type_enum_to_str(sound_device_type_e device_type, char **dev
        case SOUND_DEVICE_BUILTIN_MIC:
                *device_type_str = "builtin-mic";
                break;
-       //LCOV_EXCL_START
        case SOUND_DEVICE_AUDIO_JACK:
                *device_type_str = "audio-jack";
                break;
@@ -448,7 +453,6 @@ int _convert_device_type_enum_to_str(sound_device_type_e device_type, char **dev
        default:
                LOGE("could not find the device_type[%d] in this switch case statement", device_type);
                return MM_ERROR_SOUND_INTERNAL;
-       //LCOV_EXCL_STOP
        }
 
        LOGI("device_type[%s]", *device_type_str);
@@ -463,7 +467,7 @@ int _convert_device_type_str_to_enum(const char *device_type_str, sound_device_t
 
        if (!strncmp(device_type_str, "builtin-speaker", SOUND_DEVICE_TYPE_LEN)) {
                *device_type = SOUND_DEVICE_BUILTIN_SPEAKER;
-       //LCOV_EXCL_START
+
        } else if (!strncmp(device_type_str, "builtin-receiver", SOUND_DEVICE_TYPE_LEN)) {
                *device_type = SOUND_DEVICE_BUILTIN_RECEIVER;
 
@@ -488,11 +492,10 @@ int _convert_device_type_str_to_enum(const char *device_type_str, sound_device_t
                LOGE("not supported device_type(%s)", device_type_str);
                return MM_ERROR_INVALID_ARGUMENT;
        }
-       //LCOV_EXCL_STOP
 
        return MM_ERROR_NONE;
 }
-
+//LCOV_EXCL_STOP
 int _convert_device_type(mm_sound_device_type_e device_type, sound_device_type_e *sound_device_type)
 {
        switch (device_type) {
@@ -551,7 +554,7 @@ int _convert_device_io_direction(mm_sound_device_io_direction_e io_direction, so
 
        return MM_ERROR_NONE;
 }
-
+//LCOV_EXCL_START
 const char* _convert_api_name(native_api_e api_name)
 {
        const char* name = NULL;
@@ -699,6 +702,7 @@ int _convert_sample_rate_to_enum(unsigned int rate, sound_sample_rate_e *rate_e)
 
        return MM_ERROR_NONE;
 }
+//LCOV_EXCL_STOP
 
 int _return_val_if_not_usb_device(sound_device_h device, int ret_val)
 {
@@ -828,6 +832,7 @@ void _pa_context_state_cb(pa_context *c, void *userdata)
        return;
 }
 
+//LCOV_EXCL_START
 void _pa_stream_state_cb(pa_stream *s, void * userdata)
 {
        pa_stream_state_t state;
@@ -851,6 +856,7 @@ void _pa_stream_state_cb(pa_stream *s, void * userdata)
 
        return;
 }
+//LCOV_EXCL_STOP
 
 int _get_stream_conf_info(const char *stream_type, stream_conf_info_s *info)
 {
@@ -883,10 +889,12 @@ int _get_stream_conf_info(const char *stream_type, stream_conf_info_s *info)
                                                        NULL,
                                                        &err);
        if (!result || err) {
+               //LCOV_EXCL_START
                LOGE("g_dbus_connection_call_sync() for GET_STREAM_INFO error (%s)", err ? err->message : NULL);
                g_error_free(err);
                ret = MM_ERROR_SOUND_INTERNAL;
                goto LEAVE;
+               //LCOV_EXCL_STOP
        }
 
        /* get priority */
@@ -967,7 +975,7 @@ int _get_stream_conf_info(const char *stream_type, stream_conf_info_s *info)
        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);
+                       LOGI(" framework is [%s], skip it", name);//LCOV_EXCL_LINE
                        break;
                }
                LOGI(" framework name : %s", name);
@@ -977,7 +985,7 @@ int _get_stream_conf_info(const char *stream_type, stream_conf_info_s *info)
        g_variant_unref(child);
 
        if (info->priority == -1) {
-               LOGE("could not find the info of stream type(%s)", stream_type);
+               LOGE("could not find the info of stream type(%s)", stream_type);//LCOV_EXCL_LINE
                ret = MM_ERROR_NOT_SUPPORT_API;
        }
 
@@ -1039,10 +1047,12 @@ int _set_manual_route_info(unsigned int index, manual_route_info_s *info)
                                                        NULL,
                                                        &err);
        if (!result || err) {
+               //LCOV_EXCL_START
                LOGE("g_dbus_connection_call_sync() for SET_STREAM_ROUTE_DEVICES error (%s)", err ? err->message : NULL);
                g_error_free(err);
                ret = MM_ERROR_SOUND_INTERNAL;
                goto LEAVE;
+               //LCOV_EXCL_STOP
        }
 
        g_variant_get(result, "(&s)", &dbus_ret);
@@ -1063,6 +1073,7 @@ LEAVE:
        return ret;
 }
 
+//LCOV_EXCL_START
 int _set_route_option(unsigned int index, const char *name, int value)
 {
        int ret = MM_ERROR_NONE;
@@ -1109,6 +1120,7 @@ LEAVE:
 
        return ret;
 }
+//LCOV_EXCL_STOP
 
 int _get_volume_max_level(const char *direction, const char *volume_type, unsigned int *max_level)
 {
@@ -1137,16 +1149,18 @@ int _get_volume_max_level(const char *direction, const char *volume_type, unsign
                                                        NULL,
                                                        &err);
        if (!result || err) {
+               //LCOV_EXCL_START
                LOGE("g_dbus_connection_call_sync() for GET_VOLUME_MAX_LEVEL error (%s)", err ? err->message : NULL);
                g_error_free(err);
                ret = MM_ERROR_SOUND_INTERNAL;
                goto LEAVE;
+               //LCOV_EXCL_STOP
        }
 
        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;
+               ret = MM_ERROR_SOUND_INTERNAL;//LCOV_EXCL_LINE
 
 LEAVE:
        g_variant_unref(result);
@@ -1155,6 +1169,7 @@ LEAVE:
        return ret;
 }
 
+//LCOV_EXCL_START
 int _get_volume_level(const char *direction, const char *volume_type, unsigned int *level)
 {
        int ret = MM_ERROR_NONE;
@@ -1251,6 +1266,7 @@ LEAVE:
 
        return ret;
 }
+//LCOV_EXCL_STOP
 
 int _get_current_volume_type(const char *direction, char **volume_type)
 {
@@ -1279,21 +1295,23 @@ int _get_current_volume_type(const char *direction, char **volume_type)
                                                        NULL,
                                                        &err);
        if (!result || err) {
+               //LCOV_EXCL_START
                LOGE("g_dbus_connection_call_sync() for GET_CURRENT_VOLUME_TYPE error (%s)", err ? err->message : NULL);
                g_error_free(err);
                ret = MM_ERROR_SOUND_INTERNAL;
                goto LEAVE;
+               //LCOV_EXCL_STOP
        }
 
        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);
+               ret = MM_ERROR_NONE;//LCOV_EXCL_LINE
+               *volume_type = strdup(dbus_volume_type);//LCOV_EXCL_LINE
        } 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;
+               ret = MM_ERROR_SOUND_INTERNAL;//LCOV_EXCL_LINE
        }
 
 LEAVE:
@@ -1330,10 +1348,12 @@ int _get_current_media_routing_path(const char *direction, sound_device_type_e *
                                                        NULL,
                                                        &err);
        if (!result || err) {
+               //LCOV_EXCL_START
                LOGE("g_dbus_connection_call_sync() for GET_CURRENT_MEDIA_ROUTING_PATH error (%s)", err ? err->message : NULL);
                g_error_free(err);
                ret = MM_ERROR_SOUND_INTERNAL;
                goto LEAVE;
+               //LCOV_EXCL_STOP
        }
 
        g_variant_get(result, "(&s&s)", &dbus_device_type, &dbus_ret);
@@ -1341,7 +1361,7 @@ int _get_current_media_routing_path(const char *direction, sound_device_type_e *
        if (!strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret))) {
                ret = MM_ERROR_NONE;
                if (_convert_device_type_str_to_enum(dbus_device_type, device_type) < 0)
-                       ret = MM_ERROR_SOUND_INTERNAL;
+                       ret = MM_ERROR_SOUND_INTERNAL;//LCOV_EXCL_LINE
        } else {
                if (!strncmp("none", dbus_device_type, strlen(dbus_device_type)))
                        ret = MM_ERROR_SOUND_NO_DATA;
@@ -1378,14 +1398,16 @@ void _update_focus_status(unsigned int index, unsigned int acquired_focus_status
                                                        NULL,
                                                        &err);
        if (!result || err) {
+               //LCOV_EXCL_START
                LOGE("g_dbus_connection_call_sync() for UPDATE_FOCUS_STATUS error (%s)", err ? err->message : NULL);
                g_error_free(err);
                goto LEAVE;
+               //LCOV_EXCL_STOP
        }
        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);
+               LOGE("failed to UPDATE_FOCUS_STATUS error (%s)", dbus_ret);//LCOV_EXCL_LINE
 
 LEAVE:
        g_variant_unref(result);
@@ -1394,6 +1416,7 @@ LEAVE:
        return;
 }
 
+//LCOV_EXCL_START
 int _is_device_running_by_id(int device_id, bool *is_running)
 {
        int ret = MM_ERROR_NONE;
@@ -1903,6 +1926,7 @@ LEAVE:
 
        return ret;
 }
+//LCOV_EXCL_STOP
 
 int _make_pa_connection_and_register_focus(sound_stream_info_s *stream_h, sound_stream_focus_state_changed_cb callback, void *user_data)
 {
@@ -1933,7 +1957,7 @@ int _make_pa_connection_and_register_focus(sound_stream_info_s *stream_h, sound_
        pa_context_set_state_callback(stream_h->pa_context, _pa_context_state_cb, stream_h);
 
        if (pa_context_connect(stream_h->pa_context, NULL, 0, NULL) < 0) {
-               pa_ret = pa_context_errno(stream_h->pa_context);
+               pa_ret = pa_context_errno(stream_h->pa_context);//LCOV_EXCL_LINE
                goto PA_ERROR;
        }
 
@@ -1949,7 +1973,7 @@ int _make_pa_connection_and_register_focus(sound_stream_info_s *stream_h, sound_
                if (state == PA_CONTEXT_READY)
                        break;
                if (!PA_CONTEXT_IS_GOOD(state)) {
-                       pa_ret = pa_context_errno(stream_h->pa_context);
+                       pa_ret = pa_context_errno(stream_h->pa_context);//LCOV_EXCL_LINE
                        goto PA_ERROR_WITH_UNLOCK;
                }
                pa_threaded_mainloop_wait(stream_h->pa_mainloop);
@@ -1967,7 +1991,7 @@ int _make_pa_connection_and_register_focus(sound_stream_info_s *stream_h, sound_
                        stream_h->user_cb = callback;
                        stream_h->user_data = user_data;
                } else {
-                       LOGE("failed to register focus, ret(0x%x)", ret);
+                       LOGE("failed to register focus, ret(0x%x)", ret);//LCOV_EXCL_LINE
                        /* disconnect */
                        goto PA_ERROR;
                }
@@ -2034,7 +2058,7 @@ int _destroy_pa_connection_and_unregister_focus(sound_stream_info_s *stream_h)
        if (!stream_h->is_focus_unavailable) {
                ret = mm_sound_unregister_focus(stream_h->focus_id);
                if (ret)
-                       LOGE("failed to unregister focus, ret(0x%x)", ret);
+                       LOGE("failed to unregister focus, ret(0x%x)", ret);//LCOV_EXCL_LINE
        }
 
        for (i = 0; i < AVAIL_DEVICES_MAX; i++) {
@@ -2257,7 +2281,7 @@ int _remove_all_devices_for_stream_routing(sound_stream_info_s *stream_info)
 
        return MM_ERROR_NONE;
 }
-
+//LCOV_EXCL_START
 int _add_device_id_for_stream_routing(sound_stream_info_s *stream_info, int device_id)
 {
        int ret = MM_ERROR_NONE;
@@ -2329,7 +2353,7 @@ LEAVE:
                mm_sound_free_device(device);
        return ret;
 }
-
+//LCOV_EXCL_STOP
 int _apply_stream_routing(sound_stream_info_s *stream_info)
 {
        int i = 0;
@@ -2338,10 +2362,10 @@ int _apply_stream_routing(sound_stream_info_s *stream_info)
 
        if (stream_info->stream_conf_info.route_type != STREAM_ROUTE_TYPE_MANUAL &&
                stream_info->stream_conf_info.route_type != STREAM_ROUTE_TYPE_MANUAL_EXT) {
-               LOGE("route type is not manual or manual-ext");
+               LOGE("route type is not manual or manual-ext");//LCOV_EXCL_LINE
                /* Differ from others, it uses SOUND_INTERNAL error.
                 * ACR process is required prior to changing error value. */
-               return MM_ERROR_SOUND_INTERNAL;
+               return MM_ERROR_SOUND_INTERNAL;//LCOV_EXCL_LINE
        }
 
        for (i = 0; i < AVAIL_DEVICES_MAX; i++) {
@@ -2353,6 +2377,7 @@ int _apply_stream_routing(sound_stream_info_s *stream_info)
        return MM_ERROR_SOUND_INVALID_STATE;
 }
 
+//LCOV_EXCL_START
 int _create_virtual_stream(sound_stream_info_s *stream_info, virtual_sound_stream_info_s **virtual_stream)
 {
        int ret = MM_ERROR_NONE;
@@ -2491,7 +2516,7 @@ int _start_virtual_stream(virtual_sound_stream_info_s *virtual_stream)
        pa_threaded_mainloop_unlock(virtual_stream->pa_mainloop);
 
        return ret;
-//LCOV_EXCL_START
+
 ERROR_WITH_UNLOCK:
        pa_threaded_mainloop_unlock(virtual_stream->pa_mainloop);
 
@@ -2502,7 +2527,6 @@ ERROR_WITH_UNLOCK:
                }
        }
        LOGE("pa_ret(%d)", pa_ret);
-//LCOV_EXCL_STOP
        return ret;
 }
 
@@ -2612,4 +2636,5 @@ int _set_virtual_stream_volume(virtual_sound_stream_info_s *virtual_stream, doub
        pa_threaded_mainloop_unlock(virtual_stream->pa_mainloop);
 
        return ret;
-}
\ No newline at end of file
+}
+//LCOV_EXCL_STOP