used_voice.lang = strdup(lang);
used_voice.vctype = type;
- g_app_list[index].m_used_voice.insert(g_app_list[index].m_used_voice.end(), used_voice);
+ try {
+ iter = g_app_list[index].m_used_voice.insert(g_app_list[index].m_used_voice.end(), used_voice);
+ } catch (const std::bad_alloc&) {
+ SLOG(LOG_ERROR, tts_tag(), "[DATA][ERROR] Fail to insert m_used_voice (bad_alloc)");
+ return -1;
+ }
+ SLOG(LOG_ERROR, tts_tag(), "[DATA] lang(%s), vctype(%d)", iter->lang, iter->vctype);
#ifdef DATA_DEBUG
__data_show_used_voice_list(index);
/* mutex is locked */
pthread_mutex_lock(&g_speak_data_mutex);
- g_app_list[index].m_speak_data.insert(g_app_list[index].m_speak_data.end(), data);
+ std::list<speak_data_s*>::iterator iter;
+
+ try {
+ iter = g_app_list[index].m_speak_data.insert(g_app_list[index].m_speak_data.end(), data);
+ } catch (const std::bad_alloc&) {
+ SLOG(LOG_ERROR, tts_tag(), "[DATA][ERROR] Fail to insert m_speak_data (bad_alloc)");
+ pthread_mutex_unlock(&g_speak_data_mutex);
+
+ return TTSD_ERROR_OUT_OF_MEMORY;
+ }
+ SLOG(LOG_ERROR, tts_tag(), "[DATA][%p] utt_id(%d), text(%s), lang(%s), vctype(%d), speed(%d)",
+ *iter, (*iter)->utt_id, (*iter)->text, (*iter)->lang, (*iter)->vctype, (*iter)->speed);
if (1 == data->utt_id)
g_app_list[index].utt_id_stopped = 0;
/* mutex is locked */
pthread_mutex_lock(&g_sound_data_mutex);
- g_app_list[index].m_wav_data.insert(g_app_list[index].m_wav_data.end(), data);
+ std::list<sound_data_s*>::iterator iter;
+
+ try {
+ iter = g_app_list[index].m_wav_data.insert(g_app_list[index].m_wav_data.end(), data);
+ } catch (const std::bad_alloc&) {
+ SLOG(LOG_ERROR, tts_tag(), "[DATA][ERROR] Fail to insert m_sound_data (bad_alloc)");
+ pthread_mutex_unlock(&g_sound_data_mutex);
+
+ return TTSD_ERROR_OUT_OF_MEMORY;
+ }
+ SLOG(LOG_ERROR, tts_tag(), "[DATA][%p] utt_id(%d), data(%p)", *iter, (*iter)->utt_id, (*iter)->data);
#ifdef DATA_DEBUG
__data_show_sound_list(index);
SLOG(LOG_INFO, tts_tag(), "[Server] Add queue, lang(%s), vctype(%d), speed(%d), uttid(%d), credential(%s)", lang, voice_type, speed, utt_id, credential);
/* if state is APP_STATE_READY , APP_STATE_PAUSED , only need to add speak data to queue*/
- if (0 != ttsd_data_add_speak_data(uid, speak_data)) {
+ int ret = -1;
+ ret = ttsd_data_add_speak_data(uid, speak_data);
+ if (0 != ret) {
SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to add speak data");
if (NULL != temp_lang) {
free(temp_lang);
speak_data = NULL;
}
- return TTSD_ERROR_OPERATION_FAILED;
+ return ret;
}
if (0 != ttsd_data_set_used_voice(uid, temp_lang, temp_type)) {