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 /* initialize client data */
33 g_client_info->recognition_result_cb = NULL;
34 g_client_info->recognition_result_user_data = NULL;
36 g_client_info->result_time_cb = NULL;
37 g_client_info->result_time_user_data = NULL;
39 g_client_info->state_changed_cb = NULL;
40 g_client_info->state_changed_user_data = NULL;
42 g_client_info->supported_lang_cb = NULL;
43 g_client_info->supported_lang_user_data = NULL;
45 g_client_info->current_engine_id = -1;
47 g_client_info->time_info = NULL;
49 g_client_info->before_state = STT_FILE_STATE_READY;
50 g_client_info->current_state = STT_FILE_STATE_READY;
52 g_client_info->cb_ref_count = 0;
57 int stt_file_client_destroy()
59 if (NULL == g_client_info) {
60 SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Client info is NULL");
61 return STT_FILE_ERROR_INVALID_STATE;
63 while (0 != g_client_info->cb_ref_count) {
64 /* wait for release callback function */
75 stt_file_client_s* stt_file_client_get()
80 int stt_file_client_use_callback(stt_file_client_s* client)
82 client->cb_ref_count++;
86 int stt_file_client_not_use_callback(stt_file_client_s* client)
88 client->cb_ref_count--;
92 int stt_file_client_get_use_callback(stt_file_client_s* client)
94 return client->cb_ref_count;