/*
-* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved
+* Copyright (c) 2011-2016 Samsung Electronics Co., Ltd All Rights Reserved
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
{
tts_client_s* client = NULL;
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());
/* initialize client data */
client->state_changed_cb = NULL;
client->state_changed_user_data = NULL;
-
+
client->utt_started_cb = NULL;
client->utt_started_user_data = NULL;
client->utt_completeted_cb = NULL;
client->cb_ref_count = 0;
+ client->utt_id = 0;
+ client->reason = 0;
+ client->err_msg = NULL;
+
+ client->conn_timer = NULL;
+
+ client->credential = NULL;
+ client->credential_needed = false;
+ client->internal = false;
+
+ client->text_repeat = NULL;
+
g_client_list = g_list_append(g_client_list, client);
*tts = temp;
- SECURE_SLOG(LOG_DEBUG, TAG_TTSC, "[Success] Create client object : uid(%d)", client->uid);
+ SLOG(LOG_DEBUG, TAG_TTSC, "[Success] Create client object : uid(%d)", client->uid);
- return 0;
+ return TTS_ERROR_NONE;
}
int tts_client_destroy(tts_h tts)
{
if (tts == NULL) {
SLOG(LOG_ERROR, TAG_TTSC, "Input parameter is NULL");
- return 0;
- }
+ return TTS_ERROR_INVALID_PARAMETER;
+ }
GList *iter = NULL;
tts_client_s *data = NULL;
if (tts->handle == data->tts->handle) {
g_client_list = g_list_remove_link(g_client_list, iter);
- while (0 != data->cb_ref_count)
- {
+ while (0 != data->cb_ref_count) {
/* wait for release callback function */
}
+
+ if (NULL != data->err_msg) {
+ free(data->err_msg);
+ data->err_msg = NULL;
+ }
+
+ if (NULL != data->credential) {
+ free(data->credential);
+ data->credential = NULL;
+ }
+
+ if (NULL != data->text_repeat) {
+ free(data->text_repeat);
+ data->text_repeat = NULL;
+ }
+
free(data);
free(tts);
- return 0;
+ data = NULL;
+ tts = NULL;
+
+ SLOG(LOG_DEBUG, TAG_TTSC, "Client destroy");
+ g_list_free(iter);
+
+ return TTS_ERROR_NONE;
}
/* Next item */
}
SLOG(LOG_ERROR, TAG_TTSC, "Fail to destroy client : handle is not valid");
- return -1;
+ return TTS_ERROR_INVALID_PARAMETER;
}
tts_client_s* tts_client_get(tts_h tts)
GList* tts_client_get_client_list()
{
return g_client_list;
-}
\ No newline at end of file
+}