From aaceb7d6b99be2e1f1e309ed4a70a897de26601f Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Fri, 5 Aug 2022 15:07:23 +0900 Subject: [PATCH] Refactor vc_mgr_ducking module implementation This patch includes these features: - Use predefined macro instead of magic number - Use error enum value instead of magic number - Enhance log content for debugging and changed function name. - Use cpp for implementing vc_mgr_ducking module for future enahancement. - Create unit functions in vc_mgr_ducking module for higher maintainability. - Add sound stream type for ducking TTS sound volume. Change-Id: I0d7d7d4bbe7d8aaa89546f127eba8a853b9e45d2 Signed-off-by: Suyeon Hwang --- client/CMakeLists.txt | 2 +- client/vc_mgr.c | 26 +++-- client/vc_mgr_ducking.c | 223 -------------------------------------- client/vc_mgr_ducking.cpp | 217 +++++++++++++++++++++++++++++++++++++ client/vc_mgr_ducking.h | 16 +++ common/vc_defs.h | 6 + 6 files changed, 254 insertions(+), 236 deletions(-) delete mode 100644 client/vc_mgr_ducking.c create mode 100644 client/vc_mgr_ducking.cpp diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 7b3a3d2..9d11b1f 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -44,7 +44,7 @@ SET(MANAGER_SRCS vc_mgr_tidl.c vc_mgr_proxy.c vc_mgr_stub.c - vc_mgr_ducking.c + vc_mgr_ducking.cpp ../common/vc_cmd_db.c ../common/vc_command.c ../common/vc_command_util.c diff --git a/client/vc_mgr.c b/client/vc_mgr.c index 1dce319..cef9eb4 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -3787,7 +3787,7 @@ int vc_mgr_recover_system_volume(void) int vc_mgr_change_background_volume(vc_background_volume_event_e event) { - SLOG(LOG_INFO, TAG_VCM, "[Manager] Change system volume"); + SLOG(LOG_INFO, TAG_VCM, "[Manager] Change background volume. event(%d)", event); int ret; ret = __check_mgr_feature_privilege(); @@ -3801,7 +3801,7 @@ int vc_mgr_change_background_volume(vc_background_volume_event_e event) vc_state_e state = VC_STATE_NONE; ret = vc_mgr_client_get_client_state(g_vc_m, &state); - if (0 != ret) { + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -3813,12 +3813,12 @@ int vc_mgr_change_background_volume(vc_background_volume_event_e event) double ratio = 0.0; if (VC_BACKGROUND_VOLUME_EVENT_CHANGE_FOR_FARFIELD == event) - ratio = 0.0; + ratio = VC_MGR_DEFAULT_FARFIELD_DUCKING_RATIO; else if (VC_BACKGROUND_VOLUME_EVENT_CHANGE_FOR_NEARFIELD == event) - ratio = 0.7; + ratio = VC_MGR_DEFAULT_NEARFIELD_DUCKING_RATIO; ret = vc_mgr_ducking_activate(ratio); - if (0 != ret) + if (VC_ERROR_NONE != ret) SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to change volume"); else SLOG(LOG_INFO, TAG_VCM, "[DEBUG] Success to change volume"); @@ -3827,21 +3827,21 @@ int vc_mgr_change_background_volume(vc_background_volume_event_e event) int vc_mgr_change_background_volume_by_ratio(double ratio) { - SLOG(LOG_INFO, TAG_VCM, "[Manager] Change system volume"); + SLOG(LOG_INFO, TAG_VCM, "[Manager] Change background volume. ratio(%f)", ratio); int ret; ret = __check_mgr_feature_privilege(); if (VC_ERROR_NONE != ret) return ret; - if (0.0 > ratio || 1.0 < ratio) { + if (VC_MGR_MINIMUM_DUCKING_RATIO > ratio || VC_MGR_MAXIMUM_DUCKING_RATIO < ratio) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] ratio is invalid parameter (%lf)", ratio); return VC_ERROR_INVALID_PARAMETER; } vc_state_e state = VC_STATE_NONE; ret = vc_mgr_client_get_client_state(g_vc_m, &state); - if (0 != ret) { + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -3852,16 +3852,17 @@ int vc_mgr_change_background_volume_by_ratio(double ratio) } ret = vc_mgr_ducking_activate(ratio); - if (0 != ret) + if (VC_ERROR_NONE != ret) SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to set ratio"); else SLOG(LOG_INFO, TAG_VCM, "[DEBUG] Success to set ratio"); + return ret; } int vc_mgr_reset_background_volume(void) { - SLOG(LOG_INFO, TAG_VCM, "[Manager] recover system volume"); + SLOG(LOG_INFO, TAG_VCM, "[Manager] Recover background volume"); int ret; ret = __check_mgr_feature_privilege(); @@ -3870,7 +3871,7 @@ int vc_mgr_reset_background_volume(void) vc_state_e state = VC_STATE_NONE; ret = vc_mgr_client_get_client_state(g_vc_m, &state); - if (0 != ret) { + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -3881,9 +3882,10 @@ int vc_mgr_reset_background_volume(void) } ret = vc_mgr_ducking_deactivate(); - if (0 != ret) + if (VC_ERROR_NONE != ret) SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to recover volume"); else SLOG(LOG_INFO, TAG_VCM, "[DEBUG] Success to recover volume"); + return ret; } diff --git a/client/vc_mgr_ducking.c b/client/vc_mgr_ducking.c deleted file mode 100644 index 316cafc..0000000 --- a/client/vc_mgr_ducking.c +++ /dev/null @@ -1,223 +0,0 @@ -/* -* Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved -* -* Licensed under the Apache License, Version 2.0 (the License); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an AS IS BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "vc_main.h" -#include "voice_control_common.h" -#include "vc_mgr_ducking.h" -#include - -#define SND_MGR_DUCKING_DURATION 500 - -/* for changing volume on each sound stream */ -static sound_stream_ducking_h g_media_stream_h = NULL; -static sound_stream_ducking_h g_system_stream_h = NULL; -static sound_stream_ducking_h g_notification_stream_h = NULL; -static sound_stream_ducking_h g_alarm_stream_h = NULL; - -static char *__get_ducking_stream(sound_stream_type_e stream_type); -static int __activate_ducking_sound_stream(sound_stream_type_e type, sound_stream_ducking_h header, double ratio); -static int __deactivate_ducking_sound_stream(sound_stream_type_e type, sound_stream_ducking_h header); - -int vc_mgr_ducking_create(void) -{ - int ret = VC_ERROR_NONE; - - if (g_media_stream_h) { - SLOG(LOG_INFO, TAG_VCM, "Ducking handle for media stream is already created"); - } else { - ret = sound_manager_create_stream_ducking(SOUND_STREAM_TYPE_MEDIA, NULL, NULL, &g_media_stream_h); - if (SOUND_MANAGER_ERROR_NONE != ret) { - g_media_stream_h = NULL; - SLOG(LOG_ERROR, TAG_VCM, "Fail to create stream ducking for type media, ret(%d)", ret); - return ret; - } - } - - if (g_system_stream_h) { - SLOG(LOG_INFO, TAG_VCM, "Ducking handle for system stream is already created"); - } else { - ret = sound_manager_create_stream_ducking(SOUND_STREAM_TYPE_SYSTEM, NULL, NULL, &g_system_stream_h); - if (SOUND_MANAGER_ERROR_NONE != ret) { - sound_manager_destroy_stream_ducking(g_media_stream_h); - g_media_stream_h = NULL; - g_system_stream_h = NULL; - SLOG(LOG_ERROR, TAG_VCM, "Fail to create stream ducking for type system, ret(%d)", ret); - return ret; - } - } - - if (g_notification_stream_h) { - SLOG(LOG_INFO, TAG_VCM, "Ducking handle for notification stream is already created"); - } else { - ret = sound_manager_create_stream_ducking(SOUND_STREAM_TYPE_NOTIFICATION, NULL, NULL, &g_notification_stream_h); - if (SOUND_MANAGER_ERROR_NONE != ret) { - sound_manager_destroy_stream_ducking(g_media_stream_h); - sound_manager_destroy_stream_ducking(g_system_stream_h); - g_media_stream_h = NULL; - g_system_stream_h = NULL; - g_notification_stream_h = NULL; - SLOG(LOG_ERROR, TAG_VCM, "Fail to create stream ducking for type notification, ret(%d)", ret); - return ret; - } - } - - if (g_alarm_stream_h) { - SLOG(LOG_INFO, TAG_VCM, "Ducking handle for alarm stream is already created"); - } else { - ret = sound_manager_create_stream_ducking(SOUND_STREAM_TYPE_ALARM, NULL, NULL, &g_alarm_stream_h); - if (SOUND_MANAGER_ERROR_NONE != ret) { - sound_manager_destroy_stream_ducking(g_media_stream_h); - sound_manager_destroy_stream_ducking(g_system_stream_h); - sound_manager_destroy_stream_ducking(g_system_stream_h); - g_media_stream_h = NULL; - g_system_stream_h = NULL; - g_notification_stream_h = NULL; - g_alarm_stream_h = NULL; - SLOG(LOG_ERROR, TAG_VCM, "Fail to create stream ducking for type media, ret(%d)", ret); - return ret; - } - } - - return VC_ERROR_NONE; -} - -int vc_mgr_ducking_destroy(void) -{ - int ret = VC_ERROR_NONE; - - if (g_media_stream_h) { - ret = sound_manager_destroy_stream_ducking(g_media_stream_h); - if (SOUND_MANAGER_ERROR_NONE != ret) - SLOG(LOG_WARN, TAG_VCM, "Fail to destroy media stream ducking, ret(%d)", ret); - g_media_stream_h = NULL; - } else { - SLOG(LOG_INFO, TAG_VCM, "[Volume INFO] Ducking handle for media stream is already created"); - } - - if (g_system_stream_h) { - ret = sound_manager_destroy_stream_ducking(g_system_stream_h); - if (SOUND_MANAGER_ERROR_NONE != ret) - SLOG(LOG_WARN, TAG_VCM, "[Volume WARNING] Fail to destroy system stream ducking, ret(%d)", ret); - g_system_stream_h = NULL; - } else { - SLOG(LOG_INFO, TAG_VCM, "[Volume INFO] Ducking handle for system stream is already created"); - } - - if (g_notification_stream_h) { - ret = sound_manager_destroy_stream_ducking(g_notification_stream_h); - if (SOUND_MANAGER_ERROR_NONE != ret) - SLOG(LOG_WARN, TAG_VCM, "[Volume WARNING] Fail to destroy notification stream ducking, ret(%d)", ret); - g_notification_stream_h = NULL; - } else { - SLOG(LOG_INFO, TAG_VCM, "[Volume INFO] Ducking handle for notification stream is already created"); - } - - if (g_alarm_stream_h) { - ret = sound_manager_destroy_stream_ducking(g_alarm_stream_h); - if (SOUND_MANAGER_ERROR_NONE != ret) - SLOG(LOG_WARN, TAG_VCM, "[Volume WARNING] Fail to destroy alarm stream ducking, ret(%d)", ret); - g_alarm_stream_h = NULL; - } else { - SLOG(LOG_INFO, TAG_VCM, "[Volume INFO] Ducking handle for alarm stream is already created"); - } - - return VC_ERROR_NONE; -} - -int vc_mgr_ducking_activate(double ratio) -{ - SLOG(LOG_INFO, TAG_VCM, "vc_mgr_ducking_activate ratio(%lf)", ratio); - - int ret = VC_ERROR_NONE; - ret = __activate_ducking_sound_stream(SOUND_STREAM_TYPE_MEDIA, g_media_stream_h, ratio); - if (SOUND_MANAGER_ERROR_NONE != ret) - return ret; - ret = __activate_ducking_sound_stream(SOUND_STREAM_TYPE_SYSTEM, g_system_stream_h, ratio); - if (SOUND_MANAGER_ERROR_NONE != ret) - return ret; - ret = __activate_ducking_sound_stream(SOUND_STREAM_TYPE_NOTIFICATION, g_notification_stream_h, ratio); - if (SOUND_MANAGER_ERROR_NONE != ret) - return ret; - ret = __activate_ducking_sound_stream(SOUND_STREAM_TYPE_ALARM, g_alarm_stream_h, ratio); - return ret; -} - -int vc_mgr_ducking_deactivate(void) -{ - SLOG(LOG_INFO, TAG_VCM, "vc_mgr_ducking_deactivate"); - - int ret = VC_ERROR_NONE; - ret = __deactivate_ducking_sound_stream(SOUND_STREAM_TYPE_MEDIA, g_media_stream_h); - if (SOUND_MANAGER_ERROR_NONE != ret) - return ret; - ret = __deactivate_ducking_sound_stream(SOUND_STREAM_TYPE_SYSTEM, g_system_stream_h); - if (SOUND_MANAGER_ERROR_NONE != ret) - return ret; - ret = __deactivate_ducking_sound_stream(SOUND_STREAM_TYPE_NOTIFICATION, g_notification_stream_h); - if (SOUND_MANAGER_ERROR_NONE != ret) - return ret; - ret = __deactivate_ducking_sound_stream(SOUND_STREAM_TYPE_ALARM, g_alarm_stream_h); - return ret; -} - -static char *__get_ducking_stream(sound_stream_type_e stream_type) -{ - if (SOUND_STREAM_TYPE_MEDIA == stream_type) - return "Media stream"; - else if (SOUND_STREAM_TYPE_SYSTEM == stream_type) - return "System stream"; - else if (SOUND_STREAM_TYPE_NOTIFICATION == stream_type) - return "Notification stream"; - else if (SOUND_STREAM_TYPE_ALARM == stream_type) - return "Alarm stream"; - return "Non matched stream"; -} - -static int __activate_ducking_sound_stream(sound_stream_type_e type, sound_stream_ducking_h header, double ratio) -{ - bool is_ducked = false; - int ret = SOUND_MANAGER_ERROR_NONE; - ret = sound_manager_is_ducked(header, &is_ducked); - if (is_ducked) { - SLOG(LOG_DEBUG, TAG_VCM, "The %s is already ducked", __get_ducking_stream(type)); - return ret; - } - - ret = sound_manager_activate_ducking(header, SND_MGR_DUCKING_DURATION, ratio); - if (SOUND_MANAGER_ERROR_NONE != ret) - SLOG(LOG_ERROR, TAG_VCM, "Fail to activate ducking for %s", __get_ducking_stream(type)); - else - SLOG(LOG_INFO, TAG_VCM, "Activate ducking for %s", __get_ducking_stream(type)); - return ret; -} - -static int __deactivate_ducking_sound_stream(sound_stream_type_e type, sound_stream_ducking_h header) -{ - bool is_ducked = false; - int ret = SOUND_MANAGER_ERROR_NONE; - ret = sound_manager_is_ducked(header, &is_ducked); - if (false == is_ducked) { - SLOG(LOG_DEBUG, TAG_VCM, "The %s is already recovered from ducking", __get_ducking_stream(type)); - return ret; - } - - ret = sound_manager_deactivate_ducking(header); - if (SOUND_MANAGER_ERROR_NONE != ret) - SLOG(LOG_ERROR, TAG_VCM, "Fail to deactivate ducking for %s", __get_ducking_stream(type)); - else - SLOG(LOG_INFO, TAG_VCM, "Deactivate ducking for %s", __get_ducking_stream(type)); - return ret; -} diff --git a/client/vc_mgr_ducking.cpp b/client/vc_mgr_ducking.cpp new file mode 100644 index 0000000..f8e8756 --- /dev/null +++ b/client/vc_mgr_ducking.cpp @@ -0,0 +1,217 @@ +/* +* Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved +* +* Licensed under the Apache License, Version 2.0 (the License); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an AS IS BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include + +#include "vc_main.h" + +#include "vc_mgr_ducking.h" + +#define SND_MGR_DUCKING_DURATION 500 + +/* for changing volume on each sound stream */ +static sound_stream_ducking_h g_media_stream_h = nullptr; +static sound_stream_ducking_h g_system_stream_h = nullptr; +static sound_stream_ducking_h g_notification_stream_h = nullptr; +static sound_stream_ducking_h g_alarm_stream_h = nullptr; +static sound_stream_ducking_h g_voice_information_stream_h = nullptr; + +static bool g_is_created = false; + + +static const char *__get_ducking_stream(sound_stream_type_e stream_type) +{ + if (SOUND_STREAM_TYPE_MEDIA == stream_type) + return "Media stream"; + else if (SOUND_STREAM_TYPE_SYSTEM == stream_type) + return "System stream"; + else if (SOUND_STREAM_TYPE_NOTIFICATION == stream_type) + return "Notification stream"; + else if (SOUND_STREAM_TYPE_ALARM == stream_type) + return "Alarm stream"; + else if (SOUND_STREAM_TYPE_VOICE_INFORMATION == stream_type) + return "Voice information stream"; + + return "Non matched stream"; +} + +static sound_stream_ducking_h __create_ducking_handle(sound_stream_type_e type) +{ + sound_stream_ducking_h ducking_handle = nullptr; + + int ret = sound_manager_create_stream_ducking(type, nullptr, nullptr, &ducking_handle); + if (SOUND_MANAGER_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to create stream ducking. type(%d) ret(%d/%s)", type, ret, get_error_message(ret)); + return nullptr; + } + + SLOG(LOG_INFO, TAG_VCM, "Create ducking handle. type(%d) handle(%p)", type, ducking_handle); + return ducking_handle; +} + +static void __destroy_ducking_handle(sound_stream_ducking_h ducking_handle) +{ + if (nullptr == ducking_handle) { + return; + } + + int ret = sound_manager_destroy_stream_ducking(ducking_handle); + SLOG(LOG_WARN, TAG_VCM, "Destroy ducking handle. handle(%p) ret(%d/%s)", ducking_handle, ret, get_error_message(ret)); +} + +static bool __is_all_ducking_handle_valid() +{ + if (nullptr == g_media_stream_h || nullptr == g_system_stream_h || nullptr == g_notification_stream_h || + nullptr == g_alarm_stream_h || nullptr == g_voice_information_stream_h) { + return false; + } + + return true; +} + +static void __destroy_all_ducking_handle() +{ + __destroy_ducking_handle(g_media_stream_h); + __destroy_ducking_handle(g_system_stream_h); + __destroy_ducking_handle(g_notification_stream_h); + __destroy_ducking_handle(g_alarm_stream_h); + __destroy_ducking_handle(g_voice_information_stream_h); + + g_media_stream_h = nullptr; + g_system_stream_h = nullptr; + g_notification_stream_h = nullptr; + g_alarm_stream_h = nullptr; + g_voice_information_stream_h = nullptr; +} + +int vc_mgr_ducking_create(void) +{ + if (g_is_created) { + SLOG(LOG_INFO, TAG_VCM, "All ducking handle is already created"); + return VC_ERROR_NONE; + } + + g_media_stream_h = __create_ducking_handle(SOUND_STREAM_TYPE_MEDIA); + g_system_stream_h = __create_ducking_handle(SOUND_STREAM_TYPE_SYSTEM); + g_notification_stream_h = __create_ducking_handle(SOUND_STREAM_TYPE_NOTIFICATION); + g_alarm_stream_h = __create_ducking_handle(SOUND_STREAM_TYPE_ALARM); + g_voice_information_stream_h = __create_ducking_handle(SOUND_STREAM_TYPE_VOICE_INFORMATION); + + if (false == __is_all_ducking_handle_valid()) { + __destroy_all_ducking_handle(); + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to create ducking handles"); + return VC_ERROR_OPERATION_FAILED; + } + + g_is_created = true; + return VC_ERROR_NONE; +} + +int vc_mgr_ducking_destroy(void) +{ + __destroy_all_ducking_handle(); + + g_is_created = false; + return VC_ERROR_NONE; +} + +static int __activate_ducking_sound_stream(sound_stream_type_e type, sound_stream_ducking_h header, double ratio) +{ + bool is_ducked = false; + int ret = SOUND_MANAGER_ERROR_NONE; + ret = sound_manager_is_ducked(header, &is_ducked); + if (is_ducked) { + SLOG(LOG_DEBUG, TAG_VCM, "The %s is already ducked", __get_ducking_stream(type)); + return ret; + } + + ret = sound_manager_activate_ducking(header, SND_MGR_DUCKING_DURATION, ratio); + if (SOUND_MANAGER_ERROR_NONE != ret) + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to activate ducking for %s", __get_ducking_stream(type)); + else + SLOG(LOG_INFO, TAG_VCM, "Activate ducking for %s", __get_ducking_stream(type)); + + return ret; +} + +int vc_mgr_ducking_activate(double ratio) +{ + SLOG(LOG_INFO, TAG_VCM, "vc_mgr_ducking_activate ratio(%lf)", ratio); + + int ret = VC_ERROR_NONE; + ret = __activate_ducking_sound_stream(SOUND_STREAM_TYPE_MEDIA, g_media_stream_h, ratio); + if (SOUND_MANAGER_ERROR_NONE != ret) + return ret; + + ret = __activate_ducking_sound_stream(SOUND_STREAM_TYPE_SYSTEM, g_system_stream_h, ratio); + if (SOUND_MANAGER_ERROR_NONE != ret) + return ret; + + ret = __activate_ducking_sound_stream(SOUND_STREAM_TYPE_NOTIFICATION, g_notification_stream_h, ratio); + if (SOUND_MANAGER_ERROR_NONE != ret) + return ret; + + ret = __activate_ducking_sound_stream(SOUND_STREAM_TYPE_ALARM, g_alarm_stream_h, ratio); + if (SOUND_MANAGER_ERROR_NONE != ret) + return ret; + + ret = __activate_ducking_sound_stream(SOUND_STREAM_TYPE_VOICE_INFORMATION, g_voice_information_stream_h, ratio); + return ret; +} + +static int __deactivate_ducking_sound_stream(sound_stream_type_e type, sound_stream_ducking_h header) +{ + bool is_ducked = false; + int ret = SOUND_MANAGER_ERROR_NONE; + ret = sound_manager_is_ducked(header, &is_ducked); + if (false == is_ducked) { + SLOG(LOG_DEBUG, TAG_VCM, "The %s is already recovered from ducking", __get_ducking_stream(type)); + return ret; + } + + ret = sound_manager_deactivate_ducking(header); + if (SOUND_MANAGER_ERROR_NONE != ret) + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to deactivate ducking for %s", __get_ducking_stream(type)); + else + SLOG(LOG_INFO, TAG_VCM, "Deactivate ducking for %s", __get_ducking_stream(type)); + + return ret; +} + +int vc_mgr_ducking_deactivate(void) +{ + SLOG(LOG_INFO, TAG_VCM, "vc_mgr_ducking_deactivate"); + + int ret = VC_ERROR_NONE; + ret = __deactivate_ducking_sound_stream(SOUND_STREAM_TYPE_MEDIA, g_media_stream_h); + if (SOUND_MANAGER_ERROR_NONE != ret) + return ret; + + ret = __deactivate_ducking_sound_stream(SOUND_STREAM_TYPE_SYSTEM, g_system_stream_h); + if (SOUND_MANAGER_ERROR_NONE != ret) + return ret; + + ret = __deactivate_ducking_sound_stream(SOUND_STREAM_TYPE_NOTIFICATION, g_notification_stream_h); + if (SOUND_MANAGER_ERROR_NONE != ret) + return ret; + + ret = __deactivate_ducking_sound_stream(SOUND_STREAM_TYPE_ALARM, g_alarm_stream_h); + if (SOUND_MANAGER_ERROR_NONE != ret) + return ret; + + ret = __deactivate_ducking_sound_stream(SOUND_STREAM_TYPE_VOICE_INFORMATION, g_voice_information_stream_h); + return ret; +} diff --git a/client/vc_mgr_ducking.h b/client/vc_mgr_ducking.h index 3e55099..a511585 100644 --- a/client/vc_mgr_ducking.h +++ b/client/vc_mgr_ducking.h @@ -1,3 +1,19 @@ +/* +* Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved +* +* Licensed under the Apache License, Version 2.0 (the License); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an AS IS BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + #ifndef __VC_MGR_DUCKING_H__ #define __VC_MGR_DUCKING_H__ diff --git a/common/vc_defs.h b/common/vc_defs.h index 6cc4728..327038d 100644 --- a/common/vc_defs.h +++ b/common/vc_defs.h @@ -271,6 +271,12 @@ extern "C" { #define VC_ENGINE_APPID_LEN 256 #define VC_TIDL_RETRY_COUNT 100 +#define VC_MGR_DEFAULT_FARFIELD_DUCKING_RATIO 0.0 +#define VC_MGR_DEFAULT_NEARFIELD_DUCKING_RATIO 0.7 +#define VC_MGR_MINIMUM_DUCKING_RATIO 0.0 +#define VC_MGR_MAXIMUM_DUCKING_RATIO 1.0 + + #define VC_FEATURE_PATH "tizen.org/feature/speech.control" #define VC_MGR_FEATURE_PATH "tizen.org/feature/speech.control_manager" #define VC_MIC_FEATURE_PATH "tizen.org/feature/microphone" -- 2.34.1