if (mFocusAquired) {
acquireSoundFocus();
+ setSoundStreamInfo();
}
mState = AUDIO_STATE_READY;
SLOG(LOG_DEBUG, tts_tag(), "[AudioStream] Success to acquire focus");
}
- ret = audio_out_set_sound_stream_info(mAudioHandle, mStreamInfo);
- 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;
- }
-
mFocusAquired = true;
return TTSD_ERROR_NONE;
}
return TTSD_ERROR_NONE;
}
+int AudioStream::setSoundStreamInfo()
+{
+ if (isAudioHandleValid() == false) {
+ int ret = createAudioHandle(mAudioType, mAudioRate);
+ 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(mAudioHandle, mStreamInfo);
+ 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 (mPrepared) {
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()));