Cause: FFV callback was called, although audio type of sending audio was from Blutetooth.
Solution: Provides a way to set audio type on client side.
Change-Id: If9d2177cfe7aa61bba9fa0480ea750ea9c0d7ceb
}
client->internal_state = STT_INTERNAL_STATE_STARTING;
- ret = stt_dbus_request_start(client->uid, temp, type, client->silence, appid, client->credential);
+ ret = stt_dbus_request_start(client->uid, temp, type, client->silence, appid, client->credential, client->audio_id);
if (0 != ret) {
SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to start : %s", __stt_get_error_code(ret)); //LCOV_EXCL_LINE
client->internal_state = STT_INTERNAL_STATE_NONE;
return STT_ERROR_NONE;
}
+
+int stt_set_audio_type(stt_h stt, const char *audio_id)
+{
+ stt_client_s* client = NULL;
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
+ return temp;
+
+ RETVM_IF(NULL == audio_id, STT_ERROR_INVALID_PARAMETER, "[ERROR] Input parameter is NULL");
+ RETVM_IF(STT_STATE_CREATED != client->current_state && client->current_state != STT_STATE_READY, STT_ERROR_INVALID_STATE, "[ERROR] Current state(%d) is not 'Created' or 'Ready'", client->current_state);
+
+ SLOG(LOG_INFO, TAG_STTC, "[INFO] Set audio type(%s)", audio_id);
+
+ if (NULL != client->audio_id) {
+ free(client->audio_id);
+ client->audio_id = NULL;
+ }
+
+ client->audio_id = strdup(audio_id);
+
+ return STT_ERROR_NONE;
+}
+
+int stt_get_audio_type(stt_h stt, char **audio_id)
+{
+ stt_client_s* client = NULL;
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
+ return temp;
+
+ RETVM_IF(NULL == audio_id, STT_ERROR_INVALID_PARAMETER, "[ERROR] Input parameter is NULL");
+ RETVM_IF(STT_STATE_CREATED != client->current_state && client->current_state != STT_STATE_READY, STT_ERROR_INVALID_STATE, "[ERROR] Current state(%d) is not 'Created' or 'Ready'", client->current_state);
+
+ *audio_id = strdup(client->audio_id);
+ SLOG(LOG_INFO, TAG_STTC, "[SUCCESS] Get audio type(%s)", *audio_id);
+
+ return STT_ERROR_NONE;
+}
+
//LCOV_EXCL_STOP
#include "stt_client.h"
+#include "stt_internal.h"
#define MUTEX_TIME 3
client->current_engine_id = NULL;
client->credential = NULL;
-
+#ifdef TV_PRODUCT
+ client->audio_id = strdup(STT_AUDIO_ID_BLUETOOTH);
+#else
+ client->audio_id = strdup(STT_AUDIO_ID_NONE);
+#endif
client->silence_supported = false;
client->silence = STT_OPTION_SILENCE_DETECTION_AUTO;
data->credential = NULL;
}
+ if (NULL != data->audio_id) {
+ free(data->audio_id);
+ data->audio_id = NULL;
+ }
+
free(data);
free(stt);
data = NULL;
char* current_engine_id;
char* credential;
+ char* audio_id;
/* option */
bool silence_supported;
return ret;
}
-int stt_dbus_request_start(unsigned int uid, const char* lang, const char* type, int silence, const char* appid, const char* credential)
+int stt_dbus_request_start(unsigned int uid, const char* lang, const char* type, int silence, const char* appid, const char* credential, const char* audio_id)
{
if (NULL == lang || NULL == type || NULL == appid) {
SLOG(LOG_ERROR, TAG_STTC, "Input parameter is NULL"); //LCOV_EXCL_LINE
DBUS_TYPE_INT32, &silence,
DBUS_TYPE_STRING, &appid,
DBUS_TYPE_STRING, &temp,
+ DBUS_TYPE_STRING, &audio_id,
DBUS_TYPE_INVALID);
int ret = __stt_dbus_send_message_without_reply(msg, STT_METHOD_START);
int stt_dbus_request_unset_stop_sound(unsigned int uid);
-int stt_dbus_request_start(unsigned int uid, const char* lang, const char* type, int silence, const char* appid, const char* credential);
+int stt_dbus_request_start(unsigned int uid, const char* lang, const char* type, int silence, const char* appid, const char* credential, const char* audio_id);
int stt_dbus_request_stop(unsigned int uid);
/* Stt engine */
static sttengine_s *g_engine = NULL;
static bool g_is_from_lib = false;
+static char* g_audio_type = NULL;
/* Callback functions */
static stt_engine_result_cb g_result_cb = NULL;
return 0;
}
+int stt_engine_get_audio_type(char** audio_type)
+{
+ RETVM_IF(NULL == audio_type, STTE_ERROR_INVALID_PARAMETER, "[Engine ERROR] Invalid Parameter");
+
+ *audio_type = strdup(g_audio_type);
+
+ SLOG(LOG_INFO, TAG_STTE, "[Engine Info] get audio type(%s)", *audio_type);
+
+ return 0;
+}
+
int stt_engine_set_audio_type(const char* audio_type)
{
RETVM_IF(NULL == audio_type, STTE_ERROR_INVALID_PARAMETER, "[Engine ERROR] Invalid Parameter");
if (0 != ret) {
SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Fail to set audio type, ret(%d)", ret);
}
+ if (NULL != g_audio_type) {
+ free(g_audio_type);
+ g_audio_type = NULL;
+ }
+ g_audio_type = strdup(audio_type);
} else {
SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] There's no set audio function)");
}
int stt_engine_set_private_data_requested_cb(stte_private_data_requested_cb private_data_requested_cb, void* user_data);
+int stt_engine_get_audio_type(char** audio_type);
+
int stt_engine_set_audio_type(const char* audio_type);
int stt_engine_set_audio_type_set_cb(stte_audio_type_cb audio_type_set_cb, void* user_data);
STT_SYSTEM_VOLUME_EVENT_RECOVER /**< Recover system volume event */
} stt_system_volume_event_e;
+#define STT_AUDIO_ID_BLUETOOTH "STT_AUDIO_ID_BLUETOOTH" /**< Bluetooth audio id */
+
+#define STT_AUDIO_ID_WIFI "STT_AUDIO_ID_WIFI" /**< Wifi audio id */
+
+#define STT_AUDIO_ID_NONE "STT_AUDIO_ID_NONE" /**< None audio id */
+
/**
* @brief Sets server STT.
* @details Using this API, the application can set server STT with a @a key as a @a user_data
*/
int stt_recover_system_volume(stt_h stt);
+/**
+ * @brief Sets a type of audio-in.
+ * @since_tizen 7.0
+ *
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ *
+ * @param[in] audio_id The audio type (e.g. #STT_AUDIO_ID_BLUETOOTH or #STT_AUDIO_ID_FFV)
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STT_ERROR_NONE Successful
+ * @retval #STT_ERROR_NOT_SUPPORTED STT not supported
+ * @retval #STT_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STT_ERROR_INVALID_STATE Invalid state
+ * @retval #STT_ERROR_OPERATION_FAILED Operation failure
+ *
+ * @pre The state should be #STT_STATE_CREATED or #STT_STATE_READY.
+ *
+ * @see stt_get_audio_type()
+ */
+int stt_set_audio_type(stt_h stt, const char *audio_id);
+
+/**
+ * @brief Gets a type of audio-in.
+ * @since_tizen 7.0
+ *
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ *
+ * @remarks audio_id must be released using free() when it is no longer required.
+ *
+ * @param[out] audio_id The audio id (e.g. #STT_AUDIO_ID_BLUETOOTH or USB device ID)
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STT_ERROR_NONE Successful
+ * @retval #STT_ERROR_NOT_SUPPORTED STT not supported
+ * @retval #STT_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STT_ERROR_INVALID_STATE Invalid state
+ *
+ * @pre The state should be #STT_STATE_CREATED or #STT_STATE_READY.
+ *
+ * @see stt_set_audio_type()
+ */
+int stt_get_audio_type(stt_h stt, char **audio_id);
+
#ifdef __cplusplus
}
#endif
hnd = tmp->data;
return hnd->app_agreed;
}
+
+int sttd_client_get_audio_id(unsigned int uid, char** audio_id)
+{
+ if (NULL == audio_id) {
+ SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] audio_id is NULL");
+ return STTD_ERROR_INVALID_PARAMETER;
+ }
+
+ GSList *tmp = NULL;
+ client_info_s* hnd = NULL;
+
+ tmp = __client_get_item(uid);
+ if (NULL == tmp) {
+ return STTD_ERROR_INVALID_PARAMETER;
+ }
+
+ hnd = tmp->data;
+ if (NULL != hnd->audio_id) {
+ *audio_id = strdup(hnd->audio_id);
+ } else {
+ *audio_id = NULL;
+ }
+
+ return 0;
+}
+
+int sttd_client_set_audio_id(unsigned int uid, const char* audio_id)
+{
+ GSList *tmp = NULL;
+ client_info_s* hnd = NULL;
+
+ tmp = __client_get_item(uid);
+ if (NULL == tmp) {
+ SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] uid(%u) is NOT valid", uid);
+ return STTD_ERROR_INVALID_PARAMETER;
+ }
+
+ hnd = tmp->data;
+ if (NULL != hnd->audio_id) {
+ free(hnd->audio_id);
+ }
+
+ if (NULL != audio_id) {
+ hnd->audio_id = strdup(audio_id);
+ SLOG(LOG_DEBUG, TAG_STTD, "[Client Data] Audio ID : %s", hnd->audio_id);
+ } else {
+ hnd->audio_id = NULL;
+ }
+
+ return 0;
+}
\ No newline at end of file
unsigned int uid;
char* start_beep;
char* stop_beep;
+ char* audio_id;
app_state_e state;
/* Ecore_Timer* timer; */
bool stt_client_get_app_agreed(unsigned int uid);
+int sttd_client_get_audio_id(unsigned int uid, char** audio_id);
+
+int sttd_client_set_audio_id(unsigned int uid, const char* audio_id);
#ifdef __cplusplus
}
char* appid;
int silence;
char* credential;
+ char* audio_id;
int ret = STTD_ERROR_OPERATION_FAILED;
dbus_message_get_args(msg, &err,
DBUS_TYPE_INT32, &silence,
DBUS_TYPE_STRING, &appid,
DBUS_TYPE_STRING, &credential,
+ DBUS_TYPE_STRING, &audio_id,
DBUS_TYPE_INVALID);
SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT Start");
dbus_error_free(&err);
ret = STTD_ERROR_OPERATION_FAILED;
} else {
- SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt start : uid(%u), lang(%s), type(%s), silence(%d) appid(%s) credential(%s)"
- , uid, lang, type, silence, appid, credential);
- ret = sttd_server_start(uid, lang, type, silence, appid, credential);
+ SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt start : uid(%u), lang(%s), type(%s), silence(%d) appid(%s) credential(%s) audio_id(%s)"
+ , uid, lang, type, silence, appid, credential, audio_id);
+ ret = sttd_server_start(uid, lang, type, silence, appid, credential, audio_id);
}
if (0 <= ret) {
return 0;
}
+int sttd_engine_agent_get_audio_type(char** audio_type)
+{
+ int tmp = __sttd_engine_agent_check_precondition();
+ if (STTD_ERROR_NONE != tmp)
+ return tmp;
+
+ SLOG(LOG_INFO, TAG_STTD, "[Server Info] Get audio type");
+
+ int ret;
+ ret = stt_engine_get_audio_type(audio_type);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] get audio type error(%d)", ret);
+ }
+ return ret;
+}
+
int sttd_engine_agent_set_audio_type(const char* audio_type)
{
int tmp = __sttd_engine_agent_check_precondition();
int sttd_engine_agent_send_speech_status(stte_speech_status_e status, void* user_data);
+int sttd_engine_agent_get_audio_type(char** audio_type);
+
int sttd_engine_agent_set_audio_type(const char* audio_type);
static int g_stream_focus_id;
-static bool g_is_set_audio_type = false;
-
#ifdef TV_FFV_MODE
farfield_voice_h g_farfieldvoice_h = NULL;
#endif
}
if (NULL != g_audio_cb) {
- if (false == g_is_set_audio_type) {
- sttd_engine_agent_set_audio_type(STTE_AUDIO_ID_BLUETOOTH);
- g_is_set_audio_type = true;
+ char* audio_type = NULL;
+ int ret = sttd_engine_agent_get_audio_type(&audio_type);
+ if (STTD_ERROR_NONE == ret) {
+ if (0 != strncmp(audio_type, STTE_AUDIO_ID_BLUETOOTH, strlen(audio_type))) {
+ SLOG(LOG_INFO, TAG_STTD, "[Recorder] BT callback is not mapped with audio_type(%s)", audio_type);
+ free(audio_type);
+ return;
+ }
+ free(audio_type);
+ audio_type = NULL;
}
if (0 != g_audio_cb((void*)voice_data->audio_buf, (unsigned int)voice_data->length)) {
return;
}
- if (false == g_is_set_audio_type) {
- sttd_engine_agent_set_audio_type(STTE_AUDIO_ID_FFV);
- g_is_set_audio_type = true;
+ char* audio_type = NULL;
+ int ret = sttd_engine_agent_get_audio_type(&audio_type);
+ if (STTD_ERROR_NONE == ret) {
+ if (0 != strncmp(audio_type, STTE_AUDIO_ID_FFV, strlen(audio_type))) {
+ SLOG(LOG_INFO, TAG_STTD, "[Recorder] FFV callback is not mapped with audio_type(%s)", audio_type);
+ free(audio_type);
+ return;
+ }
+ free(audio_type);
+ audio_type = NULL;
}
if (0 == g_buffer_count % 50) {
g_farfieldvoice_h = farfield_voice_init();
if (NULL == g_farfieldvoice_h) {
SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to init farfield_voice_init");
- } else {
- SLOG(LOG_INFO, TAG_STTD, "[Recorder INFO] Register farfield voice audio callback");
- farfield_voice_register_audio_cb(g_farfieldvoice_h, _ffv_audio_function_cb, NULL);
}
#endif
g_recorder = NULL;
}
+ int ret = sttd_engine_agent_set_audio_type(NULL);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to set audio type(NULL)");
+ return ret;
+ }
+
#ifdef __UNUSED_CODES__
/* Remove all recorder */
GSList *iter = NULL;
SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to create audio handle : %d", ret);
return STTD_ERROR_OPERATION_FAILED;
}
-#else
- if (BT_ERROR_NONE != bt_hid_set_audio_data_receive_cb(_bt_hid_audio_data_receive_cb, NULL)) {
- SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail bt_hid_set_audio_data_receive_cb()");
- return STTD_ERROR_OPERATION_FAILED;
- }
#endif
stt_recorder_s* recorder;
if (STTD_RECORDER_STATE_RECORDING == g_recorder_state)
return 0;
+ char* client_audio_id = NULL;
+ int ret = sttd_client_get_audio_id(uid, &client_audio_id);
+ if (STTD_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to get audio id: %d", ret);
+ return ret;
+ }
+
+ char* engine_audio_id = NULL;
+ ret = sttd_engine_agent_get_audio_type(&engine_audio_id);
+ if (STTD_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to get audio id: %d", ret);
+ free(client_audio_id);
+ return ret;
+ }
+
+ if (0 != strncmp(client_audio_id, engine_audio_id, strlen(client_audio_id))) {
+ ret = sttd_engine_agent_set_audio_type(client_audio_id);
+ if (STTD_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to get audio id: %d", ret);
+ free(client_audio_id);
+ free(engine_audio_id);
+ return ret;
+ }
+
+#ifdef TV_FFV_MODE
+ if (0 == strncmp(client_audio_id, STTE_AUDIO_ID_FFV, strlen(client_audio_id))) {
+ if (NULL != g_farfieldvoice_h) {
+ SLOG(LOG_INFO, TAG_STTD, "[Recorder INFO] Register farfield voice audio callback");
+ farfield_voice_register_audio_cb(g_farfieldvoice_h, _ffv_audio_function_cb, NULL);
+ }
+ }
+#endif
+#ifdef TV_BT_MODE
+ if (0 == strncmp(client_audio_id, STTE_AUDIO_ID_BLUETOOTH, strlen(client_audio_id))) {
+ if (BT_ERROR_NONE != bt_hid_set_audio_data_receive_cb(_bt_hid_audio_data_receive_cb, NULL)) {
+ SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail bt_hid_set_audio_data_receive_cb()");
+ return STTD_ERROR_OPERATION_FAILED;
+ }
+ }
+#endif
+ }
+
+ free(client_audio_id);
+ free(engine_audio_id);
+ client_audio_id = NULL;
+ engine_audio_id = NULL;
+
#ifndef TV_BT_MODE
- int ret = -1;
+ ret = -1;
/* Check engine id is valid */
if (NULL == g_recorder) {
SLOG(LOG_WARN, TAG_STTD, "[Recorder WARNING] Engine id is not valid");
SLOG(LOG_WARN, TAG_STTD, "[Recorder WARNING] Enter critical section");
pthread_mutex_lock(&sttd_audio_in_handle_mutex);
- g_is_set_audio_type = false;
sttd_engine_agent_set_audio_type(STTE_AUDIO_ID_NONE);
/* Check engine id is valid */
return ret;
}
-int sttd_server_start(unsigned int uid, const char* lang, const char* recognition_type, int silence, const char* appid, const char* credential)
+int sttd_server_start(unsigned int uid, const char* lang, const char* recognition_type, int silence, const char* appid, const char* credential, const char* audio_id)
{
if (NULL == lang || NULL == recognition_type) {
SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Input parameter is NULL");
return ret;
}
+ ret = sttd_client_set_audio_id(uid, audio_id);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to set audio_id(%s)", audio_id);
+ if (NULL != sound) free(sound);
+ return ret;
+ }
+
if (0 != stt_client_set_current_recognition(uid)) {
SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Current STT is busy because of recording or processing");
if (NULL != sound) free(sound);
int sttd_server_get_audio_volume(unsigned int uid, float* current_volume);
-int sttd_server_start(unsigned int uid, const char* lang, const char* recognition_type, int silence, const char* appid, const char* credential);
+int sttd_server_start(unsigned int uid, const char* lang, const char* recognition_type, int silence, const char* appid, const char* credential, const char* audio_id);
int sttd_server_stop(unsigned int uid);