From 2e6d2b69b7bc516adb8c4b795e88de773fe1249d Mon Sep 17 00:00:00 2001 From: Jaechul Lee Date: Thu, 9 Feb 2023 10:26:58 +0900 Subject: [PATCH] Add noise-suppression APIs Turning on/off noise suppression APIs are added. [Version] 0.7.3 [Issue Type] New Feature Change-Id: I1917eb4afb541552252e7ec78a33f0475ccffc8a Signed-off-by: Jaechul Lee --- include/sound_manager_internal.h | 30 +++++++++++++++++++++++ include/sound_manager_internal_tv.h | 30 +++++++++++++++++++++++ include/sound_manager_private.h | 5 ++++ packaging/capi-media-sound-manager.spec | 2 +- src/sound_manager_internal.c | 12 +++++++++- src/sound_manager_private.c | 32 ++++++++++++++++++++++++- 6 files changed, 108 insertions(+), 3 deletions(-) diff --git a/include/sound_manager_internal.h b/include/sound_manager_internal.h index 9ba9e8a..6a59c9b 100644 --- a/include/sound_manager_internal.h +++ b/include/sound_manager_internal.h @@ -1241,6 +1241,36 @@ int sound_manager_set_echo_cancel_reference_device(sound_stream_info_h stream_in */ int sound_manager_get_echo_cancel_reference_device(sound_stream_info_h stream_info, int *device_id); +/** + * @internal + * @brief Sets noise suppression status + * @since_tizen 7.5 + * @param[in] stream_info The handle of stream information + * @param[in] enable The 'noise_suppression' property value to set: (@c true = enable, @c false = disable) + * @return @c 0 on success, + * otherwise a negative error value + * @retval #SOUND_MANAGER_ERROR_NONE Success + * @retval #SOUND_MANAGER_ERROR_POLICY Noncompliance with the sound system policy + * @see sound_manager_create_stream_information() + * @see sound_manager_get_noise_suppression() + */ +int sound_manager_set_noise_suppression(sound_stream_info_h stream_info, bool enable); + +/** + * @internal + * @brief Gets noise suppression status + * @since_tizen 7.5 + * @param[in] stream_info The handle of stream information + * @param[out] enabled The 'noise_suppression' property value : (@c true = enable, @c false = disable) + * @return @c 0 on success, + * otherwise a negative error value + * @retval #SOUND_MANAGER_ERROR_NONE Success + * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @see sound_manager_create_stream_information() + * @see sound_manager_set_noise_suppression() + */ +int sound_manager_get_noise_suppression(sound_stream_info_h stream_info, bool *enabled); + /** * @internal * @brief Set force hdmi route diff --git a/include/sound_manager_internal_tv.h b/include/sound_manager_internal_tv.h index 82b399a..bc9e427 100644 --- a/include/sound_manager_internal_tv.h +++ b/include/sound_manager_internal_tv.h @@ -1196,6 +1196,36 @@ int sound_manager_set_echo_cancel_reference_device(sound_stream_info_h stream_in */ int sound_manager_get_echo_cancel_reference_device(sound_stream_info_h stream_info, int *device_id); +/** + * @internal + * @brief Sets noise suppression status + * @since_tizen 7.5 + * @param[in] stream_info The handle of stream information + * @param[in] enable The 'noise_suppression' property value to set: (@c true = enable, @c false = disable) + * @return @c 0 on success, + * otherwise a negative error value + * @retval #SOUND_MANAGER_ERROR_NONE Success + * @retval #SOUND_MANAGER_ERROR_POLICY Noncompliance with the sound system policy + * @see sound_manager_create_stream_information() + * @see sound_manager_get_noise_suppression() + */ +int sound_manager_set_noise_suppression(sound_stream_info_h stream_info, bool enable); + +/** + * @internal + * @brief Gets noise suppression status + * @since_tizen 7.5 + * @param[in] stream_info The handle of stream information + * @param[out] enabled The 'noise_suppression' property value : (@c true = enable, @c false = disable) + * @return @c 0 on success, + * otherwise a negative error value + * @retval #SOUND_MANAGER_ERROR_NONE Success + * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @see sound_manager_create_stream_information() + * @see sound_manager_set_noise_suppression() + */ +int sound_manager_get_noise_suppression(sound_stream_info_h stream_info, bool *enabled); + /** * @internal * @brief Gets the host volume level specified for a particular sound type. diff --git a/include/sound_manager_private.h b/include/sound_manager_private.h index 16f1364..912c6d2 100644 --- a/include/sound_manager_private.h +++ b/include/sound_manager_private.h @@ -212,6 +212,7 @@ typedef struct _sound_stream_info_s { manual_route_info_s manual_route_info; preferred_device_info_s preferred_device_info; int echo_cancel_reference_device; + bool noise_suppression; pthread_mutex_t focus_state_mutex; pthread_mutex_t focus_cb_mutex; pthread_mutex_t vstream_mutex; @@ -403,6 +404,10 @@ int _set_echo_cancel_reference_device(sound_stream_info_s *stream_info, sound_de int _get_echo_cancel_reference_device(sound_stream_info_s *stream_info, int *device_id); +int _set_noise_suppression(sound_stream_info_s *stream_info, bool enable); + +int _get_noise_suppression(sound_stream_info_s *stream_info, bool *enable); + int _set_rpi_playback_route(sound_rpi_playback_route_type type); int _get_rpi_playback_route(sound_rpi_playback_route_type *type); diff --git a/packaging/capi-media-sound-manager.spec b/packaging/capi-media-sound-manager.spec index e512f2e..a4a502f 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.7.2 +Version: 0.7.3 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/sound_manager_internal.c b/src/sound_manager_internal.c index c369aa6..58e0c2a 100644 --- a/src/sound_manager_internal.c +++ b/src/sound_manager_internal.c @@ -937,6 +937,16 @@ int sound_manager_get_echo_cancel_reference_device(sound_stream_info_h stream_in return _get_echo_cancel_reference_device((sound_stream_info_s*)stream_info, device_id); } +int sound_manager_set_noise_suppression(sound_stream_info_h stream_info, bool enable) +{ + return _set_noise_suppression((sound_stream_info_s*)stream_info, enable); +} + +int sound_manager_get_noise_suppression(sound_stream_info_h stream_info, bool *enabled) +{ + return _get_noise_suppression((sound_stream_info_s*)stream_info, enabled); +} + int sound_manager_set_rpi_playback_route(sound_rpi_playback_route_type type) { return _set_rpi_playback_route(type); @@ -994,4 +1004,4 @@ int sound_manager_get_current_media_playback_device_id(int *device_id) SM_ARG_CHECK(device_id); return _get_current_media_routing_path("out", device_id, &unused); -} \ No newline at end of file +} diff --git a/src/sound_manager_private.c b/src/sound_manager_private.c index 126674a..27ed606 100644 --- a/src/sound_manager_private.c +++ b/src/sound_manager_private.c @@ -2524,6 +2524,36 @@ int _get_echo_cancel_reference_device(sound_stream_info_s *stream_info, int *dev return SOUND_MANAGER_ERROR_NONE; } +int _set_noise_suppression(sound_stream_info_s *stream_info, bool enable) +{ + SM_ARG_CHECK(stream_info); + + if (!stream_info->stream_conf_info.avail_in_devices[0]) { + LOGE("stream_info[%p, %s] does not support any input devices", stream_info, stream_info->stream_type); + return SOUND_MANAGER_ERROR_POLICY; + } + + stream_info->noise_suppression = enable; + + LOGI("stream_info[%p, %s] noise_suppression[%d]", + stream_info, stream_info->stream_type, stream_info->noise_suppression); + + return SOUND_MANAGER_ERROR_NONE; +} + +int _get_noise_suppression(sound_stream_info_s *stream_info, bool *enabled) +{ + SM_ARG_CHECK(stream_info); + SM_ARG_CHECK(enabled); + + *enabled = stream_info->noise_suppression; + + LOGI("stream_info[%p, %s] noise_suppression[%d]", + stream_info, stream_info->stream_type, *enabled); + + return SOUND_MANAGER_ERROR_NONE; +} + int _set_rpi_playback_route(sound_rpi_playback_route_type type) { int ret; @@ -3893,4 +3923,4 @@ int _get_host_volume_level(const char *direction, const char *volume_type, unsig return ret; } -//LCOV_EXCL_STOP \ No newline at end of file +//LCOV_EXCL_STOP -- 2.34.1