From 9652fec1f0dbfaad655f62868949fb5f65b9ba85 Mon Sep 17 00:00:00 2001 From: Sangchul Lee Date: Thu, 9 Jul 2020 12:48:15 +0900 Subject: [PATCH] Revise logs in sound_manager_private.c Add logs for the result of out parameter of private functions(). Redundant codes are removed. The parameter name of _convert_device_io_direction() is changed. [Version] 0.6.25 [Issue Type] Log Change-Id: I0b1a6920d2c2d5d85e15c0ae218e38b2ea3defcd Signed-off-by: Sangchul Lee --- include/sound_manager_private.h | 2 +- packaging/capi-media-sound-manager.spec | 2 +- src/sound_manager_internal.c | 4 +- src/sound_manager_private.c | 120 ++++++++++++++++-------- 4 files changed, 85 insertions(+), 43 deletions(-) diff --git a/include/sound_manager_private.h b/include/sound_manager_private.h index e534331..f5f3b1c 100644 --- a/include/sound_manager_private.h +++ b/include/sound_manager_private.h @@ -274,7 +274,7 @@ int _convert_device_type(mm_sound_device_type_e device_type, sound_device_type_e int _convert_device_type_str_to_enum(const char *device_type_str, sound_device_type_e *device_type); -int _convert_device_io_direction(mm_sound_device_io_direction_e io_direction, sound_device_io_direction_e *sound_io_direction); +int _convert_device_io_direction(mm_sound_device_io_direction_e io_direction, sound_device_io_direction_e *device_io_direction); const char* _convert_api_name(native_api_e api_name); diff --git a/packaging/capi-media-sound-manager.spec b/packaging/capi-media-sound-manager.spec index f86053f..09a45be 100644 --- a/packaging/capi-media-sound-manager.spec +++ b/packaging/capi-media-sound-manager.spec @@ -1,6 +1,6 @@ Name: capi-media-sound-manager Summary: Sound Manager library -Version: 0.6.24 +Version: 0.6.25 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/sound_manager_internal.c b/src/sound_manager_internal.c index 2729223..dcc616c 100644 --- a/src/sound_manager_internal.c +++ b/src/sound_manager_internal.c @@ -269,7 +269,7 @@ int sound_manager_is_available_stream_information(sound_stream_info_h stream_inf break; } } - LOGI("stream_type[%s], native api[%s], is_available[%d]", stream_h->stream_type, name, *is_available); + LOGI("stream_type[%s] native api[%s] is_available[%d]", stream_h->stream_type, name, *is_available); return SOUND_MANAGER_ERROR_NONE; } @@ -598,7 +598,7 @@ static int _convert_filter(sound_filter_e filter, char **filter_str, char **filt return SOUND_MANAGER_ERROR_INTERNAL; //LCOV_EXCL_STOP } - LOGI("filter[%s], param[%s]", *filter_str, *filter_params_str); + LOGI("filter[%s] param[%s]", *filter_str, *filter_params_str); return SOUND_MANAGER_ERROR_NONE; } diff --git a/src/sound_manager_private.c b/src/sound_manager_private.c index f81beaa..4dfc552 100644 --- a/src/sound_manager_private.c +++ b/src/sound_manager_private.c @@ -564,6 +564,8 @@ int _convert_device_type_str_to_enum(const char *device_type_str, sound_device_t return SOUND_MANAGER_ERROR_INVALID_PARAMETER; } + LOGI("device_type[%s, %d]", device_type_str, *device_type); + return SOUND_MANAGER_ERROR_NONE; } //LCOV_EXCL_STOP @@ -609,25 +611,29 @@ int _convert_device_type(mm_sound_device_type_e device_type, sound_device_type_e //LCOV_EXCL_STOP } + LOGI("device_type[%d]", *sound_device_type); + return SOUND_MANAGER_ERROR_NONE; } -int _convert_device_io_direction(mm_sound_device_io_direction_e io_direction, sound_device_io_direction_e *sound_io_direction) +int _convert_device_io_direction(mm_sound_device_io_direction_e io_direction, sound_device_io_direction_e *device_io_direction) { - SM_ARG_CHECK(sound_io_direction); + SM_ARG_CHECK(device_io_direction); switch (io_direction) { case MM_SOUND_DEVICE_IO_DIRECTION_IN: - *sound_io_direction = SOUND_DEVICE_IO_DIRECTION_IN; + *device_io_direction = SOUND_DEVICE_IO_DIRECTION_IN; break; case MM_SOUND_DEVICE_IO_DIRECTION_OUT: - *sound_io_direction = SOUND_DEVICE_IO_DIRECTION_OUT; + *device_io_direction = SOUND_DEVICE_IO_DIRECTION_OUT; break; case MM_SOUND_DEVICE_IO_DIRECTION_BOTH: - *sound_io_direction = SOUND_DEVICE_IO_DIRECTION_BOTH; + *device_io_direction = SOUND_DEVICE_IO_DIRECTION_BOTH; break; } + LOGI("device_io_direction[%d]", *device_io_direction); + return SOUND_MANAGER_ERROR_NONE; } //LCOV_EXCL_START @@ -702,6 +708,8 @@ int _convert_sample_format_str_to_enum(const char *format_str, sound_sample_form return SOUND_MANAGER_ERROR_INVALID_PARAMETER; } + LOGI("format[%s, %d]", format_str, *format); + return SOUND_MANAGER_ERROR_NONE; } @@ -776,6 +784,8 @@ int _convert_sample_rate_to_enum(unsigned int rate, sound_sample_rate_e *rate_e) return SOUND_MANAGER_ERROR_INVALID_PARAMETER; } + LOGI("rate[%d, %d]", rate, *rate_e); + return SOUND_MANAGER_ERROR_NONE; } //LCOV_EXCL_STOP @@ -857,6 +867,8 @@ void _focus_watch_callback(int index, mm_sound_focus_type_e focus_type, mm_sound sound_stream_focus_change_reason_e change_reason = SOUND_STREAM_FOCUS_CHANGED_BY_MEDIA; _focus_watch_info_s *watch_info; + LOGI(">> enter"); + if (!user_data) { LOGE("user_data is null"); goto LEAVE; @@ -879,6 +891,7 @@ void _focus_watch_callback(int index, mm_sound_focus_type_e focus_type, mm_sound LEAVE: LOGI("<< leave"); + return; } //LCOV_EXCL_STOP @@ -892,7 +905,7 @@ void _pa_context_state_cb(pa_context *c, void *userdata) state = pa_context_get_state(c); - LOGI("[%p] context state = [%d]", pa_info, state); + LOGI("pa_info[%p] context state[%d]", pa_info, state); if (state == PA_CONTEXT_FAILED) { pa_info->is_disconnected = true; @@ -924,7 +937,7 @@ void _pa_stream_state_cb(pa_stream *s, void * userdata) assert(s); state = pa_stream_get_state(s); - LOGI("[%p] stream [%d] state = [%d]", vstream_h, pa_stream_get_index(s), state); + LOGI("vstream_h[%p] index[%d] state[%d]", vstream_h, pa_stream_get_index(s), state); switch (state) { case PA_STREAM_READY: @@ -1096,7 +1109,7 @@ int _set_manual_route_info(unsigned int index, manual_route_info_s *info) if ((ret = __get_dbus_connection(&conn)) != SOUND_MANAGER_ERROR_NONE) return ret; - LOGI("stream info index(%u)", index); + LOGI("index[%u]", index); builder_for_in_devices = g_variant_builder_new(G_VARIANT_TYPE("au")); builder_for_out_devices = g_variant_builder_new(G_VARIANT_TYPE("au")); @@ -1141,12 +1154,14 @@ int _set_manual_route_info(unsigned int index, manual_route_info_s *info) } 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 = SOUND_MANAGER_ERROR_INTERNAL; else info->is_set = true; + LOGI("dbus_ret[%s] ret[0x%x]", dbus_ret, ret); + LEAVE: g_variant_unref(result); if (builder_for_in_devices) @@ -1172,7 +1187,7 @@ int _set_route_option(unsigned int index, const char *name, int value) if ((ret = __get_dbus_connection(&conn)) != SOUND_MANAGER_ERROR_NONE) return ret; - LOGI("[OPTION] %s(%d)", name, value); + LOGI("index[%u] name[%s] value[%d]", index, name, value); result = g_dbus_connection_call_sync(conn, PA_BUS_NAME, @@ -1194,12 +1209,14 @@ int _set_route_option(unsigned int index, const char *name, int value) } 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 = SOUND_MANAGER_ERROR_INVALID_STATE; else if (strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret))) ret = SOUND_MANAGER_ERROR_INTERNAL; + LOGI("dbus_ret[%s] ret[0x%x]", dbus_ret, ret); + LEAVE: g_variant_unref(result); g_object_unref(conn); @@ -1245,9 +1262,13 @@ int _get_volume_max_level(const char *direction, const char *volume_type, unsign } 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 = SOUND_MANAGER_ERROR_INTERNAL;//LCOV_EXCL_LINE + else + LOGI("max_level[%u]", *max_level); + + LOGI("dbus_ret[%s] ret[0x%x]", dbus_ret, ret); LEAVE: g_variant_unref(result); @@ -1292,9 +1313,13 @@ int _get_volume_level(const char *direction, const char *volume_type, unsigned i } 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 = SOUND_MANAGER_ERROR_INTERNAL; + else + LOGI("level[%u]", *level); + + LOGI("dbus_ret[%s] ret[0x%x]", dbus_ret, ret); LEAVE: g_variant_unref(result); @@ -1339,7 +1364,7 @@ int _set_volume_level(const char *direction, const char *volume_type, unsigned i } 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 = SOUND_MANAGER_ERROR_INTERNAL; else { @@ -1349,6 +1374,8 @@ int _set_volume_level(const char *direction, const char *volume_type, unsigned i LOGE("vconf_set_int(%s) failed..ret[%d]\n", volume_path, vret); } + LOGI("dbus_ret[%s] ret[0x%x]", dbus_ret, ret); + LEAVE: g_variant_unref(result); g_object_unref(conn); @@ -1394,16 +1421,19 @@ int _get_current_volume_type(const char *direction, char **volume_type) } 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 = SOUND_MANAGER_ERROR_NONE;//LCOV_EXCL_LINE *volume_type = strdup(dbus_volume_type);//LCOV_EXCL_LINE + LOGI("volume_type[%s]", *volume_type); } else if (!strncmp("STREAM_MANAGER_RETURN_ERROR_NO_STREAM", dbus_ret, strlen(dbus_ret))) { ret = SOUND_MANAGER_ERROR_NO_PLAYING_SOUND; } else { ret = SOUND_MANAGER_ERROR_INTERNAL;//LCOV_EXCL_LINE } + LOGI("dbus_ret[%s] ret[0x%x]", dbus_ret, ret); + LEAVE: g_variant_unref(result); g_object_unref(conn); @@ -1448,7 +1478,7 @@ int _get_current_media_routing_path(const char *direction, sound_device_type_e * } g_variant_get(result, "(&s&s)", &dbus_device_type, &dbus_ret); - LOGI("g_dbus_connection_call_sync() success, method return value is (%s, %s)", dbus_device_type, dbus_ret); + if (!strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret))) { if (_convert_device_type_str_to_enum(dbus_device_type, device_type) < 0) ret = SOUND_MANAGER_ERROR_INTERNAL;//LCOV_EXCL_LINE @@ -1459,6 +1489,8 @@ int _get_current_media_routing_path(const char *direction, sound_device_type_e * ret = SOUND_MANAGER_ERROR_INTERNAL; } + LOGI("dbus_ret[%s] ret[0x%x]", dbus_ret, ret); + LEAVE: g_variant_unref(result); g_object_unref(conn); @@ -1538,7 +1570,7 @@ int _is_device_running_by_id(int device_id, bool *is_running) } else { g_variant_get(result, "(b)", &_is_running); *is_running = (bool)_is_running; - LOGI("device(id:%d) is (%s)", device_id, *is_running ? "Running" : "Not running"); + LOGI("device_id[%d] is [%s]", device_id, *is_running ? "Running" : "Not running"); } LEAVE: @@ -1595,9 +1627,8 @@ int _get_supported_sample_formats(int device_id, sound_sample_format_e **formats } while (g_variant_iter_loop(iter, "&s", &format_str)) { - if (_convert_sample_format_str_to_enum((const char *)format_str, &format)) + if (_convert_sample_format_str_to_enum((const char *)format_str, &format) != SOUND_MANAGER_ERROR_NONE) continue; - LOGI("%s(enum:%u) is supported", format_str, format); elem_num++; sm_formats[elem_num - 1] = format; } @@ -1618,6 +1649,8 @@ int _get_supported_sample_formats(int device_id, sound_sample_format_e **formats *num = elem_num; + LOGI("num[%d]", *num); + LEAVE: g_variant_iter_free(iter); g_variant_unref(result); @@ -1694,7 +1727,7 @@ int _get_sample_format(int device_id, sound_sample_format_e *format) goto LEAVE; } g_variant_get(result, "(&s)", &format_str); - if (!(ret = _convert_sample_format_str_to_enum((const char *)format_str, &format_e))) + if ((ret = _convert_sample_format_str_to_enum((const char *)format_str, &format_e)) == SOUND_MANAGER_ERROR_NONE) *format = format_e; g_variant_unref(result); @@ -1752,9 +1785,8 @@ int _get_supported_sample_rates(int device_id, sound_sample_rate_e **rates, unsi } while (g_variant_iter_loop(iter, "u", &rate)) { - if (_convert_sample_rate_to_enum(rate, &rate_e)) + if (_convert_sample_rate_to_enum(rate, &rate_e) != SOUND_MANAGER_ERROR_NONE) continue; - LOGI("%u(enum:%u) is supported", rate, rate_e); elem_num++; sm_rates[elem_num - 1] = rate_e; } @@ -1775,6 +1807,8 @@ int _get_supported_sample_rates(int device_id, sound_sample_rate_e **rates, unsi *num = elem_num; + LOGI("num[%d]", *num); + LEAVE: g_variant_iter_free(iter); g_variant_unref(result); @@ -1851,7 +1885,7 @@ int _get_sample_rate(int device_id, sound_sample_rate_e *rate) goto LEAVE; } g_variant_get(result, "(u)", &_rate); - if (!(ret = _convert_sample_rate_to_enum(_rate, &rate_e))) + if ((ret = _convert_sample_rate_to_enum(_rate, &rate_e)) == SOUND_MANAGER_ERROR_NONE) *rate = rate_e; g_variant_unref(result); @@ -1929,6 +1963,8 @@ int _get_avoid_resampling(int device_id, bool *enabled) *enabled = (bool)_enabled; g_variant_unref(result); + LOGI("enabled[%d]", *enabled); + LEAVE: g_object_unref(conn); @@ -2012,6 +2048,8 @@ int _get_media_stream_only(int device_id, bool *enabled) g_variant_unref(result); + LOGI("enabled[%d]", *enabled); + LEAVE: g_object_unref(conn); @@ -2786,8 +2824,9 @@ int _set_volume_ratio(uint32_t stream_index, sound_stream_direction_e direction, g_error_free(err); 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_INVALID_ARGUMENT", dbus_ret, strlen(dbus_ret))) ret = SOUND_MANAGER_ERROR_INVALID_PARAMETER; else if (!strncmp("STREAM_MANAGER_RETURN_ERROR_NO_STREAM", dbus_ret, strlen(dbus_ret))) @@ -2795,6 +2834,8 @@ int _set_volume_ratio(uint32_t stream_index, sound_stream_direction_e direction, else if (strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret))) ret = SOUND_MANAGER_ERROR_INTERNAL; + LOGI("dbus_ret[%s] ret[0x%x]", dbus_ret, ret); + LEAVE: g_variant_unref(result); g_object_unref(conn); @@ -2900,13 +2941,13 @@ int _activate_ducking(uint32_t stream_index, bool enable, const char *target_str 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_INVALID_STATE", dbus_ret, strlen(dbus_ret))) ret = SOUND_MANAGER_ERROR_INVALID_STATE; else if (strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret))) ret = SOUND_MANAGER_ERROR_INTERNAL; + LOGI("dbus_ret[%s] ret[0x%x]", dbus_ret, ret); + LEAVE: g_variant_unref(result); g_object_unref(conn); @@ -2955,17 +2996,14 @@ int _get_ducking_state(sound_pa_info_s *pa_info, bool *is_ducked) g_variant_get(result, "(b&s)", &_is_ducked, &dbus_ret); - LOGI("dbus return value is (%s)", dbus_ret); - if (!strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret))) { *is_ducked = (bool)_is_ducked; - LOGI("is_ducked %u", *is_ducked); + LOGI("is_ducked[%d]", *is_ducked); } else { ret = SOUND_MANAGER_ERROR_INTERNAL; } - if (strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret))) - ret = SOUND_MANAGER_ERROR_INTERNAL; + LOGI("dbus_ret[%s] ret[0x%x]", dbus_ret, ret); LEAVE: g_variant_unref(result); @@ -3023,7 +3061,7 @@ static int __invoke_ipc_set_preferred_device_id(sound_stream_info_s *stream_info LOGI("Preferred device(id:%d, direction:%s) is set to PA context(%u)", device_id, direction_str, stream_info->pa_info.index); 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_DEVICE_NOT_FOUND", dbus_ret, strlen(dbus_ret))) ret = SOUND_MANAGER_ERROR_INVALID_PARAMETER; else if (!strncmp("STREAM_MANAGER_RETURN_POLICY", dbus_ret, strlen(dbus_ret))) @@ -3031,6 +3069,8 @@ static int __invoke_ipc_set_preferred_device_id(sound_stream_info_s *stream_info else if (strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret))) ret = SOUND_MANAGER_ERROR_INTERNAL; + LOGI("dbus_ret[%s] ret[0x%x]", dbus_ret, ret); + g_variant_unref(result); if (ret) goto LEAVE; @@ -3161,8 +3201,6 @@ int _get_preferred_device(sound_stream_info_s *stream_info, int *in_device_id, i g_variant_get(result, "(uu&s)", &_in_device_id, &_out_device_id, &dbus_ret); - LOGI("dbus return value is (%s)", dbus_ret); - if (!strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret))) { if (in_device_id) { if (stream_info->preferred_device_info.in != _in_device_id) { @@ -3186,6 +3224,8 @@ int _get_preferred_device(sound_stream_info_s *stream_info, int *in_device_id, i ret = SOUND_MANAGER_ERROR_INTERNAL; } + LOGI("dbus_ret[%s] ret[0x%x]", dbus_ret, ret); + LEAVE: g_variant_unref(result); g_object_unref(conn); @@ -3240,7 +3280,7 @@ static int __invoke_ipc_set_preemptive_device(sound_stream_type_e stream_type, s LOGI("Preemptive device(id:%d, direction:%s) is set", device_id, direction_str); 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_INVALID_ARGUMENT", dbus_ret, strlen(dbus_ret))) ret = SOUND_MANAGER_ERROR_INVALID_PARAMETER; else if (!strncmp("STREAM_MANAGER_RETURN_POLICY", dbus_ret, strlen(dbus_ret))) @@ -3248,6 +3288,8 @@ static int __invoke_ipc_set_preemptive_device(sound_stream_type_e stream_type, s else if (strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret))) ret = SOUND_MANAGER_ERROR_INTERNAL; + LOGI("dbus_ret[%s] ret[0x%x]", dbus_ret, ret); + g_variant_unref(result); if (ret) goto LEAVE; @@ -3295,8 +3337,6 @@ static int __invoke_ipc_get_preemptive_device(sound_stream_type_e stream_type, i } g_variant_get(result, "(uu&s)", &_in_device_id, &_out_device_id, &dbus_ret); - LOGI("dbus return value is (%s)", dbus_ret); - if (!strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret))) { if (in_device_id) { *in_device_id = _in_device_id; @@ -3310,6 +3350,8 @@ static int __invoke_ipc_get_preemptive_device(sound_stream_type_e stream_type, i ret = SOUND_MANAGER_ERROR_INTERNAL; } + LOGI("dbus_ret[%s] ret[0x%x]", dbus_ret, ret); + LEAVE: g_variant_unref(result); g_object_unref(conn); @@ -3383,8 +3425,6 @@ int _get_latest_stream_pid(int stream_type, unsigned int *pid) g_variant_get(result, "(u&s)", &_pid, &dbus_ret); - LOGI("dbus return value is (%s)", dbus_ret); - if (!strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret))) *pid = _pid; else if (!strncmp("STREAM_MANAGER_RETURN_ERROR_NO_STREAM", dbus_ret, strlen(dbus_ret))) @@ -3392,6 +3432,8 @@ int _get_latest_stream_pid(int stream_type, unsigned int *pid) else ret = SOUND_MANAGER_ERROR_INTERNAL; + LOGI("dbus_ret[%s] ret[0x%x]", dbus_ret, ret); + LEAVE: if (builder_for_stream_types) g_variant_builder_unref(builder_for_stream_types); -- 2.34.1