Set sound stream info regardless of TTS mode 15/307815/2
authorsooyeon <sooyeon.kim@samsung.com>
Wed, 13 Mar 2024 09:29:03 +0000 (18:29 +0900)
committersooyeon <sooyeon.kim@samsung.com>
Wed, 13 Mar 2024 11:26:37 +0000 (20:26 +0900)
- 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 <sooyeon.kim@samsung.com>
server/AudioStream.cpp
server/AudioStream.h
server/ttsd_player.cpp

index 5dd41c17dcc7f76d573ae1f60a58e1d530e44385..2e80c3fb43796631b61498e57a4780f5c70ed55e 100644 (file)
@@ -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) {
index 8ae0a079751febd4ac23090eb20da9c783f69357..bddb88bb7f8a6299ada1e31d96e375fba958de72 100644 (file)
@@ -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();
index e84f10b9470922dc26abd14a4676685cfaffcffd..195a6c5fc00f1460487e1e171f67c4c9553ed06e 100644 (file)
@@ -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<int>(g_is_set_policy.load()));