Fix PLM issue(P121126-2493) and API is added
authorKwangyoun Kim <ky85.kim@samsung.com>
Mon, 28 Jan 2013 08:33:31 +0000 (17:33 +0900)
committerKwangyoun Kim <ky85.kim@samsung.com>
Mon, 28 Jan 2013 08:33:31 +0000 (17:33 +0900)
Change-Id: I62c503094a70dbef37019b42dfefb6bea079e60f

client/tts.c
client/tts.h
client/tts_client.c
client/tts_client.h
client/tts_setting.c
debian/changelog
server/ttsd_player.cpp

index 3b99caf..9792862 100755 (executable)
@@ -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;
 }
 
index bd8065f..cc6411b 100755 (executable)
@@ -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
index cd1c380..f0346dd 100755 (executable)
@@ -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; 
 
index 5c005ba..11856f1 100755 (executable)
@@ -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;
 
index 3e27ec2..020314b 100755 (executable)
@@ -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;
index ac0ddc5..82260c8 100644 (file)
@@ -1,3 +1,10 @@
+tts (0.1.1-45slp2+1) unstable; urgency=low
+
+  * Fix PLM issue(P121126-2493)
+  * API is added
+
+ -- Kwangyoun Kim <ky85.kim@samsung.com>  Mon, 28 Jan 2013 17:31:31 +0900
+
 tts (0.1.1-44slp2+1) unstable; urgency=low
 
   * Fix PLM issue(P130121-3243)
index 0695ae1..6e3ae01 100755 (executable)
@@ -14,6 +14,7 @@
 
 #include <mm_types.h>
 #include <mm_player.h>
+#include <mm_player_internal.h>
 #include <mm_error.h>
 #include <Ecore.h>
 
@@ -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) {