From dde7c95aa2fc5c3e28dfb25d734e28a0b359d54a Mon Sep 17 00:00:00 2001 From: Kwangyoun Kim Date: Mon, 28 Jan 2013 17:33:31 +0900 Subject: [PATCH] Fix PLM issue(P121126-2493) and API is added Change-Id: I62c503094a70dbef37019b42dfefb6bea079e60f --- client/tts.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++--- client/tts.h | 47 ++++++++++++++++++++++++++-- client/tts_client.c | 1 + client/tts_client.h | 3 +- client/tts_setting.c | 7 +++-- debian/changelog | 7 +++++ server/ttsd_player.cpp | 6 ++++ 7 files changed, 145 insertions(+), 9 deletions(-) diff --git a/client/tts.c b/client/tts.c index 3b99caf..9792862 100755 --- a/client/tts.c +++ b/client/tts.c @@ -117,6 +117,80 @@ int tts_destroy(tts_h tts) return TTS_ERROR_NONE; } +int tts_set_mode(tts_h tts, tts_mode_e mode) +{ + SLOG(LOG_DEBUG, TAG_TTSC, "===== Set TTS mode"); + + tts_client_s* client = tts_client_get(tts); + + /* check handle */ + if (NULL == client) { + SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not available"); + SLOG(LOG_DEBUG, TAG_TTSC, "====="); + SLOG(LOG_DEBUG, TAG_TTSC, " "); + return TTS_ERROR_INVALID_PARAMETER; + } + + /* check state */ + if (client->current_state != TTS_STATE_CREATED) { + SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Invalid State: Current state is not 'CREATED'"); + SLOG(LOG_DEBUG, TAG_TTSC, "====="); + SLOG(LOG_DEBUG, TAG_TTSC, " "); + return TTS_ERROR_INVALID_STATE; + } + + if (TTS_MODE_DEFAULT <= mode && mode <= TTS_MODE_SCREEN_READER) { + client->mode = mode; + } else { + SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] mode is not valid : %d", mode); + SLOG(LOG_DEBUG, TAG_TTSC, "====="); + SLOG(LOG_DEBUG, TAG_TTSC, " "); + return TTS_ERROR_INVALID_PARAMETER; + } + + SLOG(LOG_DEBUG, TAG_TTSC, "====="); + SLOG(LOG_DEBUG, TAG_TTSC, " "); + + return TTS_ERROR_NONE; +} + +int tts_get_mode(tts_h tts, tts_mode_e* mode) +{ + SLOG(LOG_DEBUG, TAG_TTSC, "===== Get TTS mode"); + + tts_client_s* client = tts_client_get(tts); + + /* check handle */ + if (NULL == client) { + SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not available"); + SLOG(LOG_DEBUG, TAG_TTSC, "====="); + SLOG(LOG_DEBUG, TAG_TTSC, " "); + return TTS_ERROR_INVALID_PARAMETER; + } + + /* check state */ + if (client->current_state != TTS_STATE_CREATED) { + SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Invalid State: Current state is not 'CREATED'"); + SLOG(LOG_DEBUG, TAG_TTSC, "====="); + SLOG(LOG_DEBUG, TAG_TTSC, " "); + return TTS_ERROR_INVALID_STATE; + } + + if (NULL == mode) { + SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input parameter(mode) is NULL"); + SLOG(LOG_DEBUG, TAG_TTSC, "====="); + SLOG(LOG_DEBUG, TAG_TTSC, " "); + return TTS_ERROR_INVALID_PARAMETER; + } + + *mode = client->mode; + + SLOG(LOG_DEBUG, TAG_TTSC, "====="); + SLOG(LOG_DEBUG, TAG_TTSC, " "); + + return TTS_ERROR_NONE; +} + static Eina_Bool __tts_connect_daemon(void *data) { SLOG(LOG_DEBUG, TAG_TTSC, "===== Connect daemon"); @@ -181,7 +255,6 @@ static Eina_Bool __tts_connect_daemon(void *data) return EINA_FALSE; } - int tts_prepare(tts_h tts) { SLOG(LOG_DEBUG, TAG_TTSC, "===== Prepare TTS"); @@ -997,7 +1070,6 @@ int tts_unset_error_cb(tts_h tts) int __get_cmd_line(char *file, char *buf) { FILE *fp = NULL; - int i; fp = fopen(file, "r"); if (fp == NULL) { @@ -1006,9 +1078,12 @@ int __get_cmd_line(char *file, char *buf) } memset(buf, 0, 256); - fgets(buf, 256, fp); + if (NULL == fgets(buf, 256, fp)) { + SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to fget command line"); + fclose(fp); + return -1; + } fclose(fp); - return 0; } diff --git a/client/tts.h b/client/tts.h index bd8065f..cc6411b 100755 --- a/client/tts.h +++ b/client/tts.h @@ -47,6 +47,15 @@ typedef enum { } tts_error_e; /** +* @brief Enumerations of tts mode. +*/ +typedef enum { + TTS_MODE_DEFAULT = 0, /**< Default mode for normal application */ + TTS_MODE_NOTIFICATION, /**< Notification mode */ + TTS_MODE_SCREEN_READER /**< Screen reader mode */ +}tts_mode_e; + +/** * @brief Enumerations of speaking speed. */ typedef enum { @@ -56,7 +65,7 @@ typedef enum { TTS_SPEED_NORMAL, /**< Normal */ TTS_SPEED_FAST, /**< Fast */ TTS_SPEED_VERY_FAST /**< Very fast */ -} tts_speed_e; +}tts_speed_e; /** * @brief Enumerations of voice type. @@ -69,7 +78,7 @@ typedef enum { TTS_VOICE_TYPE_USER1, /**< Engine defined */ TTS_VOICE_TYPE_USER2, /**< Engine defined */ TTS_VOICE_TYPE_USER3 /**< Engine defined */ -} tts_voice_type_e; +}tts_voice_type_e; /** * @brief Enumerations of state. @@ -198,6 +207,40 @@ int tts_create(tts_h* tts); int tts_destroy(tts_h tts); /** +* @brief Set tts mode. +* +* @param[in] tts The handle for TTS +* @param[in] mode The mode +* +* @return 0 on success, otherwise a negative error value +* @retval #TTS_ERROR_NONE Successful +* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #TTS_ERROR_INVALID_STATE Invalid state +* +* @pre The state should be #TTS_STATE_CREATED. +* +* @see tts_get_mode() +*/ +int tts_set_mode(tts_h tts, tts_mode_e mode); + +/** +* @brief Get tts mode. +* +* @param[in] tts The handle for TTS +* @param[out] mode The mode +* +* @return 0 on success, otherwise a negative error value +* @retval #TTS_ERROR_NONE Successful +* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #TTS_ERROR_INVALID_STATE Invalid state +* +* @pre The state should be #TTS_STATE_CREATED. +* +* @see tts_set_mode() +*/ +int tts_get_mode(tts_h tts, tts_mode_e* mode); + +/** * @brief Connects the daemon asynchronously. * * @param[in] tts The handle for TTS diff --git a/client/tts_client.c b/client/tts_client.c index cd1c380..f0346dd 100755 --- a/client/tts_client.c +++ b/client/tts_client.c @@ -59,6 +59,7 @@ int tts_client_new(tts_h* tts) client->error_cb = NULL; client->error_user_data = NULL; + client->mode = TTS_MODE_DEFAULT; client->before_state = TTS_STATE_CREATED; client->current_state = TTS_STATE_CREATED; diff --git a/client/tts_client.h b/client/tts_client.h index 5c005ba..11856f1 100755 --- a/client/tts_client.h +++ b/client/tts_client.h @@ -40,7 +40,8 @@ typedef struct { tts_error_cb error_cb; void* error_user_data; - /* state */ + /* mode & state */ + tts_mode_e mode; tts_state_e before_state; tts_state_e current_state; diff --git a/client/tts_setting.c b/client/tts_setting.c index 3e27ec2..020314b 100755 --- a/client/tts_setting.c +++ b/client/tts_setting.c @@ -528,7 +528,6 @@ int tts_setting_set_engine_setting(const char* key, const char* value) int __setting_get_cmd_line(char *file, char *buf) { FILE *fp = NULL; - int i; fp = fopen(file, "r"); if (fp == NULL) { @@ -537,7 +536,11 @@ int __setting_get_cmd_line(char *file, char *buf) } memset(buf, 0, 256); - fgets(buf, 256, fp); + if (NULL == fgets(buf, 256, fp)) { + SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail fgets command line"); + fclose(fp); + return -1; + } fclose(fp); return 0; diff --git a/debian/changelog b/debian/changelog index ac0ddc5..82260c8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +tts (0.1.1-45slp2+1) unstable; urgency=low + + * Fix PLM issue(P121126-2493) + * API is added + + -- Kwangyoun Kim Mon, 28 Jan 2013 17:31:31 +0900 + tts (0.1.1-44slp2+1) unstable; urgency=low * Fix PLM issue(P130121-3243) diff --git a/server/ttsd_player.cpp b/server/ttsd_player.cpp index 0695ae1..6e3ae01 100755 --- a/server/ttsd_player.cpp +++ b/server/ttsd_player.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -1045,6 +1046,11 @@ int __set_and_start(player_s* player) return -1; } + ret = mm_player_ignore_session(player->player_handle); + if (MM_ERROR_NONE != ret) { + SLOG(LOG_WARN, TAG_TTSD, "[Player WARNING] fail mm_player_ignore_session() : %x", ret); + } + /* realize and start mm player */ ret = mm_player_realize(player->player_handle); if (MM_ERROR_NONE != ret) { -- 2.7.4