2 * Copyright (c) 2011-2016 Samsung Electronics Co., Ltd All Rights Reserved
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 * http://www.apache.org/licenses/LICENSE-2.0
7 * Unless required by applicable law or agreed to in writing, software
8 * distributed under the License is distributed on an "AS IS" BASIS,
9 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 * See the License for the specific language governing permissions and
11 * limitations under the License.
19 #include "stt_file_client.h"
21 static stt_file_client_s* g_client_info = NULL;
23 int stt_file_client_new()
25 if (NULL != g_client_info) {
26 SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Already allocated client info");
27 return STT_FILE_ERROR_INVALID_STATE;
30 g_client_info = (stt_file_client_s*)calloc(1, sizeof(stt_file_client_s));
32 SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Fail to allocate memory");
33 return STT_FILE_ERROR_OUT_OF_MEMORY;
36 /* initialize client data */
37 g_client_info->recognition_result_cb = NULL;
38 g_client_info->recognition_result_user_data = NULL;
40 g_client_info->result_time_cb = NULL;
41 g_client_info->result_time_user_data = NULL;
43 g_client_info->state_changed_cb = NULL;
44 g_client_info->state_changed_user_data = NULL;
46 g_client_info->supported_lang_cb = NULL;
47 g_client_info->supported_lang_user_data = NULL;
49 g_client_info->current_engine_id = -1;
51 g_client_info->time_info = NULL;
53 g_client_info->before_state = STT_FILE_STATE_READY;
54 g_client_info->current_state = STT_FILE_STATE_READY;
56 g_client_info->cb_ref_count = 0;
61 int stt_file_client_destroy()
63 if (NULL == g_client_info) {
64 SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Client info is NULL");
65 return STT_FILE_ERROR_INVALID_STATE;
67 while (0 != g_client_info->cb_ref_count) {
68 /* wait for release callback function */
79 stt_file_client_s* stt_file_client_get()
84 int stt_file_client_use_callback(stt_file_client_s* client)
86 client->cb_ref_count++;
90 int stt_file_client_not_use_callback(stt_file_client_s* client)
92 client->cb_ref_count--;
96 int stt_file_client_get_use_callback(stt_file_client_s* client)
98 return client->cb_ref_count;