From 412a4deb5e65c4000c135b5e08867fdbaea7a279 Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Fri, 24 Jul 2020 18:33:45 +0900 Subject: [PATCH] Fix to change background volume when it is changed by tts_setting Change-Id: If61fd67ad6b8e8cc998682523cc57a4b47e7e5b5 Signed-off-by: sooyeon.kim --- client/tts.c | 6 +++--- server/ttsd_player.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/client/tts.c b/client/tts.c index d601ea0..7228ee0 100644 --- a/client/tts.c +++ b/client/tts.c @@ -1043,9 +1043,9 @@ int __tts_cb_hello(int uid, int ret, int credential_needed) } else { /* success to connect tts-daemon */ if (TTS_CREDENTIAL_NEEDED_ALREADY_INITIALIZED != credential_needed) { - client->credential_needed = credential_needed; - SLOG(LOG_ERROR, TAG_TTSC, "Supported options : credential(%s)", credential_needed ? "need" : "no need"); - } + client->credential_needed = credential_needed; + SLOG(LOG_ERROR, TAG_TTSC, "Supported options : credential(%s)", credential_needed ? "need" : "no need"); + } } client->before_state = client->current_state; diff --git a/server/ttsd_player.c b/server/ttsd_player.c index e2d0d72..6895f25 100644 --- a/server/ttsd_player.c +++ b/server/ttsd_player.c @@ -1520,7 +1520,35 @@ int ttsd_player_set_background_volume_ratio(double ratio) { SLOG(LOG_INFO, tts_tag(), "[Player DEBUG] ttsd_player_set_background_volume_ratio : %lf", ratio); + double prev_ratio = g_bg_volume_ratio; g_bg_volume_ratio = ratio; + + if (g_bg_volume_ratio != prev_ratio) { + SLOG(LOG_DEBUG, tts_tag(), "[Player DEBUG] Check whether sound is ducked and Change volume. as-is(%lf), to-be(%lf)", prev_ratio, g_bg_volume_ratio); + + bool is_ducked = false; + int ret = sound_manager_is_ducked(g_media_stream_ducking, &is_ducked); + if (0 == ret && true == is_ducked) { + __deactivate_ducking_sound_stream(SOUND_STREAM_TYPE_MEDIA, g_media_stream_ducking); + __activate_ducking_sound_stream(SOUND_STREAM_TYPE_MEDIA, g_media_stream_ducking); + } + ret = sound_manager_is_ducked(g_system_stream_ducking, &is_ducked); + if (0 == ret && true == is_ducked) { + __deactivate_ducking_sound_stream(SOUND_STREAM_TYPE_SYSTEM, g_system_stream_ducking); + __activate_ducking_sound_stream(SOUND_STREAM_TYPE_SYSTEM, g_system_stream_ducking); + } + ret = sound_manager_is_ducked(g_notification_stream_ducking, &is_ducked); + if (0 == ret && true == is_ducked) { + __deactivate_ducking_sound_stream(SOUND_STREAM_TYPE_NOTIFICATION, g_notification_stream_ducking); + __activate_ducking_sound_stream(SOUND_STREAM_TYPE_NOTIFICATION, g_notification_stream_ducking); + } + ret = sound_manager_is_ducked(g_alarm_stream_ducking, &is_ducked); + if (0 == ret && true == is_ducked) { + __deactivate_ducking_sound_stream(SOUND_STREAM_TYPE_ALARM, g_alarm_stream_ducking); + __activate_ducking_sound_stream(SOUND_STREAM_TYPE_ALARM, g_alarm_stream_ducking); + } + } + return TTSD_ERROR_NONE; } -- 2.7.4