Add feature checking logic for engine API 05/288905/1
authorSuyeon Hwang <stom.hwang@samsung.com>
Thu, 16 Feb 2023 08:53:17 +0000 (17:53 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Fri, 24 Feb 2023 08:13:29 +0000 (17:13 +0900)
- Issue:
Most of the engine API did not return 'not supported error' when the
device does not support the TTS feature.

- Solution:
This patch adds feature checking logic to the beginning of each API
implementation. Through this change, each API will properly check the
required feature and return error. And this behavior is matched to the
description of each API.

Change-Id: I744cb3bbeb6670f3fdfedc1ecd3f9d710f822be2
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
include/ttse.h
server/ttse.c

index 32c52a228a1c9a7b76aa21a81cae8faf79ce71f7..e14a59637e8437c859a2ebfdb82bb58450dd218b 100755 (executable)
@@ -394,7 +394,7 @@ typedef int (*ttse_private_data_requested_cb)(const char* key, char** data);
 *          This callback function is called when the activated TTS modes are changed.
 * @since_tizen 7.0
 * @remarks This callback function is optional and is registered using ttse_set_activated_mode_changed_cb().
-* @param[in] activated_mode The activated TTS modes by connected clients, values of ttse_mode_mask_e combined with bitwise 'or'.
+* @param[in] activated_mode The activated TTS modes by connected clients, values of #ttse_mode_mask_e combined with bitwise 'or'.
 * @see ttse_set_activated_mode_changed_cb()
 * @see ttse_get_activated_mode()
 */
@@ -440,9 +440,9 @@ typedef struct {
 * @return This function returns zero on success,
 *         or negative with error code on failure
 * @retval #TTSE_ERROR_NONE Successful
+* @retval #TTSE_ERROR_NOT_SUPPORTED Not supported
 * @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
-* @retval #TTSE_ERROR_NOT_SUPPORTED Not supported
 * @see ttse_request_callback_s
 * @code
 #include <ttse.h>
@@ -538,8 +538,8 @@ int ttse_terminate(void);
 * @return @c 0 on success,
 *         otherwise a negative error value
 * @retval #TTSE_ERROR_NONE Successful
-* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #TTSE_ERROR_NOT_SUPPORTED Not supported
+* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
 */
 int ttse_get_speed_range(int* min, int* normal, int* max);
@@ -555,8 +555,8 @@ int ttse_get_speed_range(int* min, int* normal, int* max);
 * @return @c 0 on success,
 *         otherwise a negative error value
 * @retval #TTSE_ERROR_NONE Successful
-* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #TTSE_ERROR_NOT_SUPPORTED Not supported
+* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
 */
 int ttse_get_pitch_range(int* min, int* normal, int* max);
@@ -576,8 +576,8 @@ int ttse_get_pitch_range(int* min, int* normal, int* max);
 * @return @c 0 on success,
 *         otherwise a negative error value
 * @retval #TTSE_ERROR_NONE Successful
-* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #TTSE_ERROR_NOT_SUPPORTED Not supported
+* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
 * @pre The ttse_main() function should be invoked before this function is called.
 *         ttse_start_synthesis_cb() will invoke this function.
@@ -607,8 +607,8 @@ int ttse_send_result(ttse_result_event_e event, const void* data, unsigned int d
 * @return @c 0 on success,
 *         otherwise a negative error value
 * @retval #TTSE_ERROR_NONE Successful
-* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #TTSE_ERROR_NOT_SUPPORTED Not supported
+* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
 * @pre The ttse_main() function should be invoked before this function is called.
 */
@@ -623,8 +623,8 @@ int ttse_send_error(ttse_error_e error, const char* msg);
 * @return @c 0 on success,
 *         otherwise a negative error value
 * @retval #TTSE_ERROR_NONE Successful
-* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #TTSE_ERROR_NOT_SUPPORTED Not supported
+* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
 * @pre The ttse_main() function should be invoked before this function is called.
 * @see ttse_private_data_set_cb()
@@ -640,8 +640,8 @@ int ttse_set_private_data_set_cb(ttse_private_data_set_cb callback_func);
 * @return @c 0 on success,
 *         otherwise a negative error value
 * @retval #TTSE_ERROR_NONE Successful
-* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #TTSE_ERROR_NOT_SUPPORTED Not supported
+* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
 * @pre The ttse_main() function should be invoked before this function is called.
 * @see ttse_private_data_requested_cb()
@@ -656,7 +656,7 @@ int ttse_set_private_data_requested_cb(ttse_private_data_requested_cb callback_f
 *          @a activated_mode has the same bit sequence as '#TTSE_MODE_MASK_DEFAULT | #TTSE_MODE_MASK_SCREEN_READER'.
 *          Using this API, the engine can get the activated TTS modes information.
 * @since_tizen 7.0
-* @param[out] activated_mode The activated TTS mode by connected clients, values of ttse_mode_mask_e combined with bitwise 'or'.
+* @param[out] activated_mode The activated TTS mode by connected clients, values of #ttse_mode_mask_e combined with bitwise 'or'.
 * @return @c 0 on success,
 *         otherwise a negative error value
 * @retval #TTSE_ERROR_NONE Successful
index 584490033fa51be81b15dd114d8a18d8252e0cbc..ba01bc0007559d4d787cdc29044ecfab2c48267b 100755 (executable)
@@ -36,7 +36,7 @@ const char* tts_tag()
        return "ttsd";
 }
 
-static bool __is_feature_enabled()
+static bool is_feature_enabled()
 {
        if (1 == g_feature_enabled) {
                return true;
@@ -123,6 +123,10 @@ static bool __is_test_app()
 
 int ttse_main(int argc, char** argv, ttse_request_callback_s *callback)
 {
+       if (false == is_feature_enabled()) {
+               return TTSE_ERROR_NOT_SUPPORTED;
+       }
+
        g_is_terminated = false;
 
        if (!ecore_init()) {
@@ -164,6 +168,10 @@ int ttse_main(int argc, char** argv, ttse_request_callback_s *callback)
 
 int ttse_terminate(void)
 {
+       if (false == is_feature_enabled()) {
+               return TTSE_ERROR_NOT_SUPPORTED;
+       }
+
        if (true == g_is_terminated) {
                SLOG(LOG_INFO, tts_tag(), "[INFO] ttse_terminate() is already invoked.");
                return TTSE_ERROR_NONE;
@@ -185,6 +193,10 @@ int ttse_terminate(void)
 
 int ttse_get_speed_range(int* min, int* normal, int* max)
 {
+       if (false == is_feature_enabled()) {
+               return TTSE_ERROR_NOT_SUPPORTED;
+       }
+
        if (NULL == min || NULL == normal || NULL == max) {
                SLOG(LOG_ERROR, tts_tag(), "[ERROR] Input parameter is null");
                return TTSE_ERROR_INVALID_PARAMETER;
@@ -199,6 +211,10 @@ int ttse_get_speed_range(int* min, int* normal, int* max)
 
 int ttse_get_pitch_range(int* min, int* normal, int* max)
 {
+       if (false == is_feature_enabled()) {
+               return TTSE_ERROR_NOT_SUPPORTED;
+       }
+
        if (NULL == min || NULL == normal || NULL == max) {
                SLOG(LOG_ERROR, tts_tag(), "[ERROR] Input parameter is null");
                return TTSE_ERROR_INVALID_PARAMETER;
@@ -213,6 +229,10 @@ int ttse_get_pitch_range(int* min, int* normal, int* max)
 
 int ttse_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)
 {
+       if (false == is_feature_enabled()) {
+               return TTSE_ERROR_NOT_SUPPORTED;
+       }
+
        int ret;
 
        if (NULL == data) {
@@ -230,6 +250,10 @@ int ttse_send_result(ttse_result_event_e event, const void* data, unsigned int d
 
 int ttse_send_error(ttse_error_e error, const char* msg)
 {
+       if (false == is_feature_enabled()) {
+               return TTSE_ERROR_NOT_SUPPORTED;
+       }
+
        int ret;
 
        ret = ttsd_send_error(error, msg);
@@ -243,6 +267,10 @@ int ttse_send_error(ttse_error_e error, const char* msg)
 
 int ttse_set_private_data_set_cb(ttse_private_data_set_cb callback_func)
 {
+       if (false == is_feature_enabled()) {
+               return TTSE_ERROR_NOT_SUPPORTED;
+       }
+
        if (NULL == callback_func) {
                SLOG(LOG_ERROR, tts_tag(), "[ERROR] Invalid parameter");
                return TTSE_ERROR_INVALID_PARAMETER;
@@ -259,6 +287,10 @@ int ttse_set_private_data_set_cb(ttse_private_data_set_cb callback_func)
 
 int ttse_set_private_data_requested_cb(ttse_private_data_requested_cb callback_func)
 {
+       if (false == is_feature_enabled()) {
+               return TTSE_ERROR_NOT_SUPPORTED;
+       }
+
        if (NULL == callback_func) {
                SLOG(LOG_ERROR, tts_tag(), "[ERROR] Invalid parameter");
                return TTSE_ERROR_INVALID_PARAMETER;
@@ -275,7 +307,7 @@ int ttse_set_private_data_requested_cb(ttse_private_data_requested_cb callback_f
 
 int ttse_get_activated_mode(int* activated_mode)
 {
-       if (false == __is_feature_enabled()) {
+       if (false == is_feature_enabled()) {
                return TTSE_ERROR_NOT_SUPPORTED;
        }
 
@@ -299,7 +331,7 @@ int ttse_get_activated_mode(int* activated_mode)
 
 int ttse_set_activated_mode_changed_cb(ttse_activated_mode_changed_cb callback)
 {
-       if (false == __is_feature_enabled()) {
+       if (false == is_feature_enabled()) {
                return TTSE_ERROR_NOT_SUPPORTED;
        }