}
}
- return ret;
+ return ret;
}
}
if (200 < cnt) {
SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Wrong request, there's no pcm data");
+ vc_mgr_data_clear_feedback_data(&feedback_data);
return;
}
cnt++;
SLOG(LOG_INFO, TAG_VCM, "[INFO] Finish to wait for new feedback data come");
/* resume feedback thread */
+ vc_mgr_data_clear_feedback_data(&feedback_data);
continue;
}
int vc_mgr_data_clear_feedback_data(vc_feedback_data_s** data)
{
- SLOG(LOG_DEBUG, TAG_VCM, "[DATA] clear feedback data");
+ SLOG(LOG_DEBUG, TAG_VCM, "[DATA] clear feedback data, empty(%d)", g_feedback_data.empty());
pthread_mutex_lock(&g_feedback_data_mutex);
if (!g_feedback_data.empty()) {
- SLOG(LOG_DEBUG, TAG_VCM, "[DEBUG] pid(%d), utt_id(%d), data(%p) size(%d) rate(%d)", (*data)->pid, (*data)->utt_id, (*data)->data, (*data)->data_size, (*data)->rate);
+ if (NULL != *data) {
+ SLOG(LOG_DEBUG, TAG_VCM, "[DEBUG] pid(%d), utt_id(%d), data(%p) size(%d) rate(%d)", (*data)->pid, (*data)->utt_id, (*data)->data, (*data)->data_size, (*data)->rate);
- if (NULL != (*data)->data) {
- free((*data)->data);
- (*data)->data = NULL;
- }
+ if (NULL != (*data)->data) {
+ free((*data)->data);
+ (*data)->data = NULL;
+ }
- free(*data);
- *data = NULL;
+ free(*data);
+ *data = NULL;
+ }
}
pthread_mutex_unlock(&g_feedback_data_mutex);
-/*
- * 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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/**
+ * Copyright (c) 2011-2018 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifndef __VOICE_CONTROL_INTERNAL_H__
/**
-* @brief Called when client gets the asr recognition result from vc-daemon.
-*
-* @param[in] event The result event
-* @param[in] result ASR text
-* @param[in] user_data The user data passed from the callback registration function
-*
-* @return @c true when asr result is consumed \n @c false to propagate.
-*
-* @pre An application registers callback function using vc_mgr_set_pre_result_cb().
-*
-* @see vc_widget_set_asr_result_cb()
-* @see vc_widget_unset_asr_result_cb()
-*/
+ * @brief Called when client gets the asr recognition result from vc-daemon.
+ *
+ * @param[in] event The result event
+ * @param[in] result ASR text
+ * @param[in] user_data The user data passed from the callback registration function
+ *
+ * @return @c true when asr result is consumed \n @c false to propagate.
+ *
+ * @pre An application registers callback function using vc_mgr_set_pre_result_cb().
+ *
+ * @see vc_widget_set_asr_result_cb()
+ * @see vc_widget_unset_asr_result_cb()
+ */
typedef bool (*vc_asr_result_cb)(vc_result_event_e event, const char* result, void *user_data);
/**
-/*
-* Copyright (c) 2011-2018 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
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an AS IS BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+/**
+ * Copyright (c) 2011-2018 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifndef __VOICE_CONTROL_MANAGER_H__
/* for TTS feedback */
/**
-* @brief Called when engine sends audio formats necessary for playing TTS feedback
-* @since_tizen 5.0
-*
-* @param[in] rate Audio sampling rate
-* @param[in] channel Audio channel (e.g. #VC_AUDIO_CHANNEL_MONO, #VC_AUDIO_CHANNEL_STEREO)
-* @param[in] audio_type Audio type (e.g. #VC_AUDIO_TYPE_PCM_S16_LE, #VC_AUDIO_TYPE_PCM_U8)
-* @param[in] user_data The user data passed from the callback registration function
-*
-* @pre An application registers callback function using vc_mgr_set_feedback_audio_format_cb().
-*
-* @see vc_mgr_set_feedback_audio_format_cb()
-* @see vc_mgr_unset_feedback_audio_format_cb()
-*/
+ * @brief Called when engine sends audio formats necessary for playing TTS feedback
+ * @since_tizen 5.0
+ *
+ * @param[in] rate Audio sampling rate
+ * @param[in] channel Audio channel (e.g. #VC_AUDIO_CHANNEL_MONO, #VC_AUDIO_CHANNEL_STEREO)
+ * @param[in] audio_type Audio type (e.g. #VC_AUDIO_TYPE_PCM_S16_LE, #VC_AUDIO_TYPE_PCM_U8)
+ * @param[in] user_data The user data passed from the callback registration function
+ *
+ * @pre An application registers callback function using vc_mgr_set_feedback_audio_format_cb().
+ *
+ * @see vc_mgr_set_feedback_audio_format_cb()
+ * @see vc_mgr_unset_feedback_audio_format_cb()
+ */
typedef void (*vc_mgr_feedback_audio_format_cb)(int rate, vc_audio_channel_e channel, vc_audio_type_e audio_type, void *user_data);
/**
-* @brief Called when engine sends audio streaming for TTS feedback
-* @since_tizen 5.0
-*
-* @param[in] event TTS feedback event (e.g. #VC_FEEDBACK_EVENT_START, #VC_FEEDBACK_EVENT_CONTINUE)
-* @param[in] buffer Audio streaming data
-* @param[in] len Length of the audio streaming data
-* @param[in] user_data The user data passed from the callback registration function
-*
-* @pre An application registers callback function using vc_mgr_set_feedback_streaming_cb().
-*
-* @see vc_mgr_set_feedback_streaming_cb()
-* @see vc_mgr_unset_feedback_streaming_cb()
-*/
+ * @brief Called when engine sends audio streaming for TTS feedback
+ * @since_tizen 5.0
+ *
+ * @remarks The @a buffer must be released with free() by you when you no longer need it.
+ *
+ * @param[in] event TTS feedback event (e.g. #VC_FEEDBACK_EVENT_START, #VC_FEEDBACK_EVENT_CONTINUE)
+ * @param[in] buffer Audio streaming data
+ * @param[in] len Length of the audio streaming data
+ * @param[in] user_data The user data passed from the callback registration function
+ *
+ * @pre An application registers callback function using vc_mgr_set_feedback_streaming_cb().
+ *
+ * @see vc_mgr_set_feedback_streaming_cb()
+ * @see vc_mgr_unset_feedback_streaming_cb()
+ */
typedef void (*vc_mgr_feedback_streaming_cb)(vc_feedback_event_e event, char* buffer, int len, void *user_data);
/**
-* @brief Called when the vc client sends audio streaming for TTS feedback
-* @since_tizen 5.0
-*
-* @remarks The @a buffer must be released with free() by you when you no longer need it.
-*
-* @param[in] pid The process id of the vc client
-* @param[in] utt_id The utterance id
-* @param[in] event TTS feedback event (e.g. #VC_FEEDBACK_EVENT_START, #VC_FEEDBACK_EVENT_CONTINUE)
-* @param[in] buffer Audio streaming data
-* @param[in] len Length of the audio streaming data
-* @param[in] user_data The user data passed from the callback registration function
-*
-* @pre An application registers callback function using vc_mgr_set_vc_tts_streaming_cb().
-*
-* @see vc_mgr_set_vc_tts_streaming_cb()
-* @see vc_mgr_unset_vc_tts_streaming_cb()
-*/
+ * @brief Called when the vc client sends audio streaming for TTS feedback
+ * @since_tizen 5.0
+ *
+ * @remarks The @a buffer must be released with free() by you when you no longer need it.
+ *
+ * @param[in] pid The process id of the vc client
+ * @param[in] utt_id The utterance id
+ * @param[in] event TTS feedback event (e.g. #VC_FEEDBACK_EVENT_START, #VC_FEEDBACK_EVENT_CONTINUE)
+ * @param[in] buffer Audio streaming data
+ * @param[in] len Length of the audio streaming data
+ * @param[in] user_data The user data passed from the callback registration function
+ *
+ * @pre An application registers callback function using vc_mgr_set_vc_tts_streaming_cb().
+ *
+ * @see vc_mgr_set_vc_tts_streaming_cb()
+ * @see vc_mgr_unset_vc_tts_streaming_cb()
+ */
typedef void (*vc_mgr_vc_tts_streaming_cb)(int pid, int utt_id, vc_feedback_event_e event, char* buffer, int len, void *user_data);
/**
VCD_STATE_READY = 1,
VCD_STATE_RECORDING = 2,
VCD_STATE_PROCESSING = 3,
- VCD_STATE_UPDATING = 4
+ VCD_STATE_SYNTHESIZING = 4,
+ VCD_STATE_UPDATING = 5
} vcd_state_e;
typedef enum {
/* for TTS feedback */
int vcd_send_feedback_audio_format(int rate, vce_audio_channel_e channel, vce_audio_type_e audio_type)
{
- SLOG(LOG_INFO, TAG_VCD, "[Server DEBUG] Engine - Send TTS feedback audio format");
+ SLOG(LOG_INFO, TAG_VCD, "[Server DEBUG] Engine - Send TTS feedback audio format, g_current_uid(%d)", g_current_uid);
/* send TTS feedback audio format to VC manager */
int ret = VCD_ERROR_NONE;
int pid = g_current_uid / 1000;
if (-1 == g_current_uid || vcd_client_manager_get_pid() == pid) {
- ret = vcdc_send_feedback_audio_format_to_manager(vcd_client_manager_get_pid(), rate, channel, audio_type);
- if (VCD_ERROR_NONE != ret) {
- SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send TTS feedback audio format to VC manager");
- }
+ ret = vcdc_send_feedback_audio_format_to_manager(vcd_client_manager_get_pid(), rate, channel, audio_type);
+ if (VCD_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send TTS feedback audio format to VC manager");
+ }
} else {
SLOG(LOG_INFO, TAG_VCD, "[Server INFO] Do not send TTS feedback audio format to VC manager");
}
if (-1 == g_current_uid && VCE_FEEDBACK_EVENT_START == event) {
g_current_utt_id = (g_current_utt_id + 1) % 1000;
g_current_uid = vcd_client_manager_get_pid() * 1000 + g_current_utt_id;
- SLOG(LOG_INFO, TAG_VCD, "[Server info] set current uid and utt_id as manager pid");
+ SLOG(LOG_INFO, TAG_VCD, "[Server info] set current uid and utt_id as manager pid(%d)", vcd_client_manager_get_pid());
}
int ret = VCD_ERROR_NONE;
int pid = g_current_uid / 1000;
int utt_id = g_current_uid % 1000;
- SLOG(LOG_INFO, TAG_VCD, "[Server DEBUG] Engine - Send TTS feedback streaming to pid(%d), is_mgr_client(%d)", pid, (pid == vcd_client_manager_get_pid() ? true : false));
+ SLOG(LOG_INFO, TAG_VCD, "[Server DEBUG] Engine - Send TTS feedback streaming event(%d), uid(%d), is_mgr_client(%d)", event, g_current_uid, (pid == vcd_client_manager_get_pid() ? true : false));
if (pid == vcd_client_manager_get_pid()) {
/* send TTS feedback streaming to manager client */
} else {
/* send TTS feedback streaming to client */
ret = vcdc_send_feedback_streaming(pid, utt_id, event, buffer, len);
- if (VCD_ERROR_NONE != ret) {
+ if (VCD_ERROR_NONE != ret) {
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send TTS feedback streaming to client");
- }
+ }
}
if (VCE_FEEDBACK_EVENT_FINISH == event) {
/* reset current uid */
g_current_uid = -1;
+
+ /* Set service state to ready if state is synthesizing */
+ vcd_state_e state = vcd_config_get_service_state();
+ if (VCD_STATE_SYNTHESIZING == state) {
+ vcd_config_set_service_state(VCD_STATE_READY);
+ }
+ SLOG(LOG_INFO, TAG_VCD, "[Server info] feedback streaming finish event, reset current uid & service state(%d)", vcd_config_get_service_state());
}
return ret;
}
/* 1. check current state */
vcd_state_e state = vcd_config_get_service_state();
- if (VCD_STATE_READY != state) {
- SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Current state is not ready");
+ if (VCD_STATE_READY != state && VCD_STATE_SYNTHESIZING != state) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Current state is not ready and not synthesizine, state(%d)", state);
return VCD_ERROR_INVALID_STATE;
}
if (-1 == vcd_client_manager_get_pid()) {
return VCD_ERROR_INVALID_PARAMETER;
}
vcd_state_e state = vcd_config_get_service_state();
- if (VCD_STATE_READY != state) {
- SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Current state is not ready");
+ if (VCD_STATE_READY != state && VCD_STATE_SYNTHESIZING != state) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Current state is not ready and not synthesizing, state(%d)", state);
return VCD_ERROR_INVALID_STATE;
}
}
vcd_state_e state = vcd_config_get_service_state();
- if (VCD_STATE_READY != state) {
- SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Current state is not ready");
+ if (VCD_STATE_READY != state && VCD_STATE_SYNTHESIZING != state) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Current state is not ready and not synthesizing, state(%d)", state);
return VCD_ERROR_INVALID_STATE;
}
while (1) {
int ret = -1;
+ int cnt = 0;
/* Get tts text data */
ret = vcd_data_get_first_tts_text_data(&tts_text_data);
continue;
}
+ while (1) {
+ vcd_state_e state = vcd_config_get_service_state();
+ if (VCD_STATE_READY != state) {
+ if (0 == cnt++ % 10)
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Waiting to request TTS, state(%d)", state);
+ usleep(100000);
+ continue;
+ }
+ break;
+ }
+
+ /* Set service state to synthesizing */
+ vcd_config_set_service_state(VCD_STATE_SYNTHESIZING);
+
+ /* Set current uid */
+ g_current_uid = tts_text_data->uid;
+
/* Request tts to engine */
ret = vcd_engine_request_tts(tts_text_data->pid, tts_text_data->utt_id, tts_text_data->text, tts_text_data->language);
if (0 != ret) {
}
vcd_state_e state = vcd_config_get_service_state();
- if (VCD_STATE_READY != state) {
+ if (VCD_STATE_READY != state && VCD_STATE_SYNTHESIZING != state) {
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Current state is not ready, state(%d)", state);
return VCD_ERROR_INVALID_STATE;
}
+ int uid = -1;
g_current_utt_id = (g_current_utt_id + 1) % 1000;
*utt_id = g_current_utt_id;
if (0 == to_vcm) {
- g_current_uid = pid * 1000 + g_current_utt_id;
+ uid = pid * 1000 + g_current_utt_id;
} else {
- g_current_uid = vcd_client_manager_get_pid() * 1000 + g_current_utt_id;
+ uid = vcd_client_manager_get_pid() * 1000 + g_current_utt_id;
}
SLOG(LOG_INFO, TAG_VCD, "[Server INFO] pid(%d), text(%s), language(%s), to_vcm(%d), ", pid, text, language, to_vcm);
- SLOG(LOG_INFO, TAG_VCD, "[Server INFO] current_uid(%d), current_utt_id(%d)", g_current_uid, g_current_utt_id);
+ SLOG(LOG_INFO, TAG_VCD, "[Server INFO] current_uid(%d), current_utt_id(%d)", uid, g_current_utt_id);
vc_tts_text_data_s* tts_text_data;
tts_text_data = (vc_tts_text_data_s*)calloc(1, sizeof(vc_tts_text_data_s));
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to callocate memory ");
return VCD_ERROR_OUT_OF_MEMORY;
}
- tts_text_data->uid = g_current_uid;
+ tts_text_data->uid = uid;
tts_text_data->pid = pid;
tts_text_data->utt_id = g_current_utt_id;
tts_text_data->text = strdup(text);
}
vcd_state_e state = vcd_config_get_service_state();
- if (VCD_STATE_READY != state) {
+ if (VCD_STATE_READY != state && VCD_STATE_SYNTHESIZING != state) {
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Current state is not ready, state(%d)", state);
return VCD_ERROR_INVALID_STATE;
}
}
vcd_state_e state = vcd_config_get_service_state();
- if (VCD_STATE_READY != state) {
- SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Current state is not ready");
+ if (VCD_STATE_READY != state && VCD_STATE_SYNTHESIZING != state) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Current state is not ready and not synthesizing, state(%d)", state);
return VCD_ERROR_INVALID_STATE;
}