/*
-* Copyright (c) 2011-2016 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
/* client list */
static GList *g_client_list = NULL;
-/* pthread mutex */
-static pthread_mutex_t g_allocated_handle_mutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_mutex_t g_client_list_mutex = PTHREAD_MUTEX_INITIALIZER;
-
/* private functions */
static int __client_generate_uid(int pid)
{
- int uid = 0;
-
- pthread_mutex_lock(&g_allocated_handle_mutex);
g_allocated_handle++;
if (g_allocated_handle > g_max_handle) {
}
/* generate uid, handle number should be smaller than 1000 */
- uid = pid * 1000 + g_allocated_handle;
- pthread_mutex_unlock(&g_allocated_handle_mutex);
-
- return uid;
+ return pid * 1000 + g_allocated_handle;
}
int tts_client_new(tts_h* tts)
free(client);
return TTS_ERROR_OUT_OF_MEMORY;
}
- temp->handle = __client_generate_uid(getpid());
+ temp->handle = __client_generate_uid(getpid());
/* initialize client data */
client->tts = temp;
- client->pid = getpid();
+ client->pid = getpid();
client->uid = temp->handle;
client->current_utt_id = 0;
client->supported_voice_user_data = NULL;
client->mode = TTS_MODE_DEFAULT;
- client->before_state = TTS_STATE_CREATED;
- client->current_state = TTS_STATE_CREATED;
+ client->before_state = TTS_STATE_CREATED;
+ client->current_state = TTS_STATE_CREATED;
client->cb_ref_count = 0;
client->text_repeat = NULL;
- pthread_mutex_lock(&g_client_list_mutex);
g_client_list = g_list_append(g_client_list, client);
- pthread_mutex_unlock(&g_client_list_mutex);
*tts = temp;
GList *iter = NULL;
tts_client_s *data = NULL;
- pthread_mutex_lock(&g_client_list_mutex);
/* if list have item */
if (g_list_length(g_client_list) > 0) {
/* Get a first item */
g_list_free(iter);
- pthread_mutex_unlock(&g_client_list_mutex);
SLOG(LOG_ERROR, TAG_TTSC, "Client destroy : uid(%d)", uid);
return TTS_ERROR_NONE;
}
iter = g_list_next(iter);
}
}
- pthread_mutex_unlock(&g_client_list_mutex);
SLOG(LOG_ERROR, TAG_TTSC, "Fail to destroy client : handle is not valid");
return TTS_ERROR_INVALID_PARAMETER;
GList *iter = NULL;
tts_client_s *data = NULL;
- pthread_mutex_lock(&g_client_list_mutex);
if (g_list_length(g_client_list) > 0) {
/* Get a first item */
iter = g_list_first(g_client_list);
while (NULL != iter) {
data = iter->data;
- if (tts->handle == data->tts->handle) {
- pthread_mutex_unlock(&g_client_list_mutex);
+ if (tts->handle == data->tts->handle)
return data;
- }
/* Next item */
iter = g_list_next(iter);
}
}
- pthread_mutex_unlock(&g_client_list_mutex);
SLOG(LOG_ERROR, TAG_TTSC, "handle is not valid");
return NULL;
GList *iter = NULL;
tts_client_s *data = NULL;
- pthread_mutex_lock(&g_client_list_mutex);
if (g_list_length(g_client_list) > 0) {
/* Get a first item */
iter = g_list_first(g_client_list);
while (NULL != iter) {
data = iter->data;
if (uid == data->uid) {
- pthread_mutex_unlock(&g_client_list_mutex);
return data;
}
}
}
- pthread_mutex_unlock(&g_client_list_mutex);
SLOG(LOG_WARN, TAG_TTSC, "uid is not valid");
return NULL;
int tts_client_get_size()
{
- pthread_mutex_lock(&g_client_list_mutex);
- int size = g_list_length(g_client_list);
- pthread_mutex_unlock(&g_client_list_mutex);
-
- return size;
+ return g_list_length(g_client_list);
}
int tts_client_use_callback(tts_client_s* client)
tts_client_s *data = NULL;
int number = 0;
- pthread_mutex_lock(&g_client_list_mutex);
if (g_list_length(g_client_list) > 0) {
/* Get a first item */
iter = g_list_first(g_client_list);
iter = g_list_next(iter);
}
}
- pthread_mutex_unlock(&g_client_list_mutex);
return number;
}
tts_client_s *data = NULL;
int number = 0;
- pthread_mutex_lock(&g_client_list_mutex);
if (g_list_length(g_client_list) > 0) {
/* Get a first item */
iter = g_list_first(g_client_list);
iter = g_list_next(iter);
}
}
- pthread_mutex_unlock(&g_client_list_mutex);
return number;
}
-// FIXME: remove this function
GList* tts_client_get_client_list()
{
return g_client_list;