From f594c9f3410aad9f751b1e3dda28fee1427b414b Mon Sep 17 00:00:00 2001 From: sooyeon Date: Wed, 13 Mar 2024 18:29:03 +0900 Subject: [PATCH] Set sound stream info regardless of TTS mode - Issue: In Tizen 7.0 FHub, there is a case that TTS sound volume becomes low. When the sound focus is not acquired, the sound stream info is not set, either. - Solution: Regardless of TTS mode, we made the sound stream info set. Change-Id: I5a8cfbcc65dafc8e7f3c0e9b39000e0686330de4 Signed-off-by: sooyeon --- server/AudioStream.cpp | 34 ++++++++++++++++++++++++++++------ server/AudioStream.h | 1 + server/ttsd_player.cpp | 1 + 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/server/AudioStream.cpp b/server/AudioStream.cpp index 5dd41c17..2e80c3fb 100644 --- a/server/AudioStream.cpp +++ b/server/AudioStream.cpp @@ -71,6 +71,7 @@ int AudioStream::setAudioFormat(ttse_audio_type_e type, int rate) if (__focusAquired) { acquireSoundFocus(); + setSoundStreamInfo(); } __state = AUDIO_STATE_READY; @@ -102,12 +103,6 @@ int AudioStream::acquireSoundFocus() SLOG(LOG_DEBUG, tts_tag(), "[AudioStream] Success to acquire focus"); } - ret = audio_out_set_sound_stream_info(__audioHandle, __streamInfo); - if (AUDIO_IO_ERROR_NONE != ret) { - SLOG(LOG_WARN, tts_tag(), "[AudioStream] Fail to set stream info. ret(%s)", get_error_message(ret)); - return TTSD_ERROR_OPERATION_FAILED; - } - __focusAquired = true; return TTSD_ERROR_NONE; } @@ -140,6 +135,33 @@ int AudioStream::releaseSoundFocus() return TTSD_ERROR_NONE; } +int AudioStream::setSoundStreamInfo() +{ + if (isAudioHandleValid() == false) { + int ret = createAudioHandle(__audioType, __audioRate); + if (TTSD_ERROR_NONE != ret) { + SLOG(LOG_ERROR, tts_tag(), "[AudioStream] Fail to create the audio handle. ret(%s)", get_error_message(ret)); + return TTSD_ERROR_OPERATION_FAILED; + } + } + + if (isStreamInfoValid() == false) { + int ret = createSoundStreamInfo(); + if (TTSD_ERROR_NONE != ret) { + SLOG(LOG_ERROR, tts_tag(), "[AudioStream] Fail to create the stream info. ret(%s)", get_error_message(ret)); + return TTSD_ERROR_OPERATION_FAILED; + } + } + + int ret = audio_out_set_sound_stream_info(__audioHandle, __streamInfo); + if (AUDIO_IO_ERROR_NONE != ret) { + SLOG(LOG_WARN, tts_tag(), "[AudioStream] Fail to set stream info. ret(%s)", get_error_message(ret)); + return TTSD_ERROR_OPERATION_FAILED; + } + + return TTSD_ERROR_NONE; +} + int AudioStream::prepareAudioOut() { if (__prepared) { diff --git a/server/AudioStream.h b/server/AudioStream.h index 8ae0a079..bddb88bb 100644 --- a/server/AudioStream.h +++ b/server/AudioStream.h @@ -37,6 +37,7 @@ public: int setAudioFormat(ttse_audio_type_e type, int rate); int acquireSoundFocus(); int releaseSoundFocus(); + int setSoundStreamInfo(); int prepareAudioOut(); int unprepareAudioOut(); void waitForPlay(); diff --git a/server/ttsd_player.cpp b/server/ttsd_player.cpp index e84f10b9..195a6c5f 100644 --- a/server/ttsd_player.cpp +++ b/server/ttsd_player.cpp @@ -146,6 +146,7 @@ static void __set_policy_for_playing(unsigned int uid) if (TTSD_MODE_DEFAULT == mode || TTSD_MODE_INTERRUPT == mode) g_audio_stream->acquireSoundFocus(); + g_audio_stream->setSoundStreamInfo(); g_background_volume->applyVolumeRatio(); g_is_set_policy = true; SLOG(LOG_ERROR, tts_tag(), "[BG] g_is_set_policy(%d)", static_cast(g_is_set_policy.load())); -- 2.34.1