*/
#include "ttsd_main.h"
-#include "ttsd_server.h"
#include "ttsd_data.h"
#include "ttsd_ipc.h"
#include "ttsd_player.h"
return TTSD_ERROR_OPERATION_FAILED;
}
- ttsd_data_foreach_clients(__stop_all_client_callback, nullptr);
g_player_thread->requestStop();
+ ttsd_data_foreach_clients(__stop_all_client_callback, nullptr);
SLOG(LOG_DEBUG, tts_tag(), "[Player SUCCESS] player all stop!!");
- return 0;
+ return TTSD_ERROR_NONE;
}
int ttsd_player_get_background_volume_ratio(double* ratio)
return TTSD_ERROR_NONE;
}
-bool __get_client_cb(int pid, unsigned int uid, app_tts_state_e state, void* user_data)
+static bool __get_client_cb(int pid, unsigned int uid, app_tts_state_e state, void* user_data)
{
+ if (0 > ttsd_data_is_client(uid)) {
+ SLOG(LOG_ERROR, tts_tag(), "[Server] Client(%d) is not valid.", uid);
+ ttsd_data_delete_client(uid);
+ return true;
+ }
+
/* clear client data */
ttsd_data_clear_data(uid);
if (APP_STATE_READY != state) {
ttsd_data_set_client_state(uid, APP_STATE_READY);
-
- /* send message */
- if (0 != ttsdc_ipc_send_set_state_message(pid, uid, APP_STATE_READY)) {
- /* remove client */
- ttsd_data_delete_client(uid);
- }
+ ttsdc_ipc_send_set_state_message(pid, uid, APP_STATE_READY);
}
return true;
}
-void __config_changed_cb(tts_config_type_e type, const char* str_param, int int_param, double double_param)
+static void __stop_all_client()
+{
+ SLOG(LOG_INFO, tts_tag(), "[Server] Send to stop all requests");
+
+ ttsd_engine_cancel_synthesis();
+ ttsd_set_synth_control(TTSD_SYNTHESIS_CONTROL_EXPIRED);
+
+ /* stop all player */
+ ttsd_player_all_stop();
+
+ /* send interrupt message to all clients */
+ ttsd_data_foreach_clients(__get_client_cb, NULL);
+}
+
+static void __config_changed_cb(tts_config_type_e type, const char* str_param, int int_param, double double_param)
{
switch (type) {
case TTS_CONFIG_TYPE_ENGINE:
return;
}
- /* stop all player */
- ttsd_player_all_stop();
-
- /* send interrupt message to all clients */
- ttsd_data_foreach_clients(__get_client_cb, NULL);
-
- ttsd_engine_cancel_synthesis();
-
+ __stop_all_client();
break;
}
return;
}
-int ttsd_send_all_stop()
-{
- SLOG(LOG_INFO, tts_tag(), "[Server] Send to stop all requests");
-
- /* stop all player */
- ttsd_player_all_stop();
-
- /* send interrupt message to all clients */
- ttsd_data_foreach_clients(__get_client_cb, NULL);
-
- return TTSD_ERROR_NONE;
-}
-
/*
* Server APIs
*/
int ttsd_send_result(ttse_result_event_e event, const void* data, unsigned int data_size, ttse_audio_type_e audio_type, int rate, void* user_data);
int ttsd_send_error(ttse_error_e error, const char* msg);
-int ttsd_send_all_stop();
int ttsd_set_private_data_set_cb(ttse_private_data_set_cb callback);
int ttsd_set_private_data_requested_cb(ttse_private_data_requested_cb callback);