client->supported_voice_user_data = user_data;
}
-static inline void __reset_client_data(tts_client_s* client) {
- client->tts = NULL;
- client->pid = INVALID_HANDLE;
- client->uid = INVALID_HANDLE;
- client->current_utt_id = 0;
-
- client->state_changed_cb = NULL;
- client->state_changed_user_data = NULL;
-
- client->utt_started_cb = NULL;
- client->utt_started_user_data = NULL;
- client->utt_completed_cb = NULL;
- client->utt_completed_user_data = NULL;
-
- client->error_cb = NULL;
- client->error_user_data = NULL;
- client->default_voice_changed_cb = NULL;
- client->default_voice_changed_user_data = NULL;
- client->supported_voice_cb = NULL;
- client->supported_voice_user_data = NULL;
-
- client->mode = TTS_MODE_DEFAULT;
- client->before_state = TTS_STATE_CREATED;
- client->current_state = TTS_STATE_CREATED;
-
- client->cb_ref_count = 0;
-
- client->utt_id = 0;
- client->reason = 0;
- client->err_msg = NULL;
-
- client->hello_timer = NULL;
- client->start_listening = false;
-
- client->credential = NULL;
- client->credential_needed = false;
- client->internal = false;
-
- client->text_repeat = NULL;
-
- client->notify_error_timer = NULL;
- client->notify_state_timer = NULL;
-}
-
int tts_client_new(tts_h* tts)
{
- tts_client_s* client = NULL;
- client = (tts_client_s*)calloc(1, sizeof(tts_client_s));
+ tts_client_s* client = (tts_client_s*)calloc(1, sizeof(tts_client_s));
if (NULL == client) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to allocate memory");
return TTS_ERROR_OUT_OF_MEMORY;
}
+
tts_h temp = (tts_h)calloc(1, sizeof(struct tts_s));
if (NULL == temp) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to allocate memory");
free(client);
return TTS_ERROR_OUT_OF_MEMORY;
}
+
temp->handle = __client_generate_uid(getpid());
temp->connected = false;
+ temp->rpc_h = NULL;
/* initialize client data */
- __reset_client_data(client);
client->tts = temp;
client->pid = getpid();
client->uid = temp->handle;
/* wait for release callback function */
}
- if (NULL != data->err_msg) {
- free(data->err_msg);
- }
-
- if (NULL != data->credential) {
- free(data->credential);
- }
+ int uid = data->uid;
- if (NULL != data->text_repeat) {
- free(data->text_repeat);
- }
+ free(data->err_msg);
+ free(data->credential);
+ free(data->text_repeat);
+ memset(data, 0, sizeof(tts_client_s));
- __reset_client_data(data);
- int uid = data->uid;
free(data);
- free(tts);
-
data = NULL;
+
+ free(tts);
tts = NULL;
g_list_free(iter);