speechd-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 03/09] replace EPunctMode with SPDPunctuation


From: Andrei Kholodnyi
Subject: [PATCH 03/09] replace EPunctMode with SPDPunctuation
Date: Fri, 1 Oct 2010 23:50:58 +0200

both enums are identical, replace internal EPunctMode enum with
public SPDPunctuation enum

moved SPDPunctuation declaration from libspeechd.h to speechd_types.h
to make it available for internal modules

make speechd_type.h header public since it is included now in libspeechd.h
---
 include/Makefile.am         |    3 ++-
 include/spd_utils.h         |    4 ++--
 include/speechd_types.h     |   13 ++++++-------
 src/api/c/libspeechd.h      |    8 ++------
 src/clients/say/Makefile.am |    2 +-
 src/common/spd_conv.c       |   18 +++++++++---------
 src/modules/espeak.c        |   10 +++++-----
 src/modules/festival.c      |    4 ++--
 src/modules/generic.c       |   10 +++++-----
 src/modules/ibmtts.c        |    6 +++---
 src/modules/ivona.c         |   10 +++++-----
 src/modules/module_utils.h  |    4 ++--
 src/server/configuration.c  |    4 ++--
 src/server/parse.c          |    8 ++++----
 src/server/set.c            |    4 ++--
 src/server/set.h            |    6 +++---
 src/server/speechd.h        |    2 +-
 src/tests/Makefile.am       |    2 +-
 18 files changed, 57 insertions(+), 61 deletions(-)

diff --git a/include/Makefile.am b/include/Makefile.am
index 8d8df94..fe1f6de 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -1,4 +1,5 @@
 ## Process this file with automake to produce Makefile.in
 
-noinst_HEADERS = speechd_types.h spd_utils.h
+noinst_HEADERS = spd_utils.h
 
+include_HEADERS = speechd_types.h
diff --git a/include/spd_utils.h b/include/spd_utils.h
index 3255cec..11bdc00 100644
--- a/include/spd_utils.h
+++ b/include/spd_utils.h
@@ -32,8 +32,8 @@ ssize_t spd_getline(char **lineptr, size_t * n, FILE * f);
 
 char* spd_voice2str(EVoiceType voice);
 EVoiceType spd_str2voice(char* str);
-char* spd_punct2str(EPunctMode punct);
-EPunctMode spd_str2punct(char* str);
+char* spd_punct2str(SPDPunctuation punct);
+SPDPunctuation spd_str2punct(char* str);
 char* spd_spell2str(ESpellMode spell);
 ESpellMode spd_str2spell(char* str);
 char* spd_cap2str(ECapLetRecogn recogn);
diff --git a/include/speechd_types.h b/include/speechd_types.h
index 2f3a32d..a6786db 100644
--- a/include/speechd_types.h
+++ b/include/speechd_types.h
@@ -23,6 +23,12 @@
 #ifndef SPEECHD_TYPES_H
 #define SPEECHD_TYPES_H
 
+typedef enum {
+    SPD_PUNCT_ALL = 0,
+    SPD_PUNCT_NONE = 1,
+    SPD_PUNCT_SOME = 2
+} SPDPunctuation;
+
 typedef enum
     {                  /* Type of voice */
        NO_VOICE = 0,
@@ -60,13 +66,6 @@ typedef enum
 
 typedef enum
     {
-       PUNCT_NONE = 0,
-       PUNCT_ALL = 1,
-       PUNCT_SOME = 2
-    }EPunctMode;
-
-typedef enum
-    {
        SPELLING_OFF = 0,
        SPELLING_ON = 1
     }ESpellMode;
diff --git a/src/api/c/libspeechd.h b/src/api/c/libspeechd.h
index 62a8348..1353377 100644
--- a/src/api/c/libspeechd.h
+++ b/src/api/c/libspeechd.h
@@ -29,6 +29,8 @@
 #include <stddef.h>
 #include <pthread.h>
 
+#include <speechd_types.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -43,12 +45,6 @@ extern "C" {
 /* --------------------- Public data types ------------------------ */
 
 typedef enum{
-    SPD_PUNCT_ALL = 0,
-    SPD_PUNCT_NONE = 1,
-    SPD_PUNCT_SOME = 2
-}SPDPunctuation;
-
-typedef enum{
     SPD_CAP_NONE = 0,
     SPD_CAP_SPELL = 1,
     SPD_CAP_ICON = 2
diff --git a/src/clients/say/Makefile.am b/src/clients/say/Makefile.am
index e32ebbf..d8636ad 100644
--- a/src/clients/say/Makefile.am
+++ b/src/clients/say/Makefile.am
@@ -1,6 +1,6 @@
 ## Process this file with automake to produce Makefile.in
 
-inc_local = -I$(top_srcdir)/src/api/c
+inc_local = -I$(top_srcdir)/include -I$(top_srcdir)/src/api/c
 c_api = $(top_builddir)/src/api/c
 
 bin_PROGRAMS = spd-say
diff --git a/src/common/spd_conv.c b/src/common/spd_conv.c
index b2cc447..4f516e6 100644
--- a/src/common/spd_conv.c
+++ b/src/common/spd_conv.c
@@ -70,29 +70,29 @@ spd_str2voice(char* str)
 }
 
 char*
-spd_punct2str(EPunctMode punct)
+spd_punct2str(SPDPunctuation punct)
 {
     char *str;
 
     switch (punct)
         {
-        case PUNCT_NONE: str = strdup("none"); break;
-        case PUNCT_ALL: str = strdup("all"); break;
-        case PUNCT_SOME: str = strdup("some"); break;
+        case SPD_PUNCT_NONE: str = strdup("none"); break;
+        case SPD_PUNCT_ALL: str = strdup("all"); break;
+        case SPD_PUNCT_SOME: str = strdup("some"); break;
         default: str = NULL;
         }
 
     return str;
 }
 
-EPunctMode
+SPDPunctuation
 spd_str2punct(char* str)
 {
-    EPunctMode punct;
+    SPDPunctuation punct;
 
-    if (!strcmp(str, "none")) punct = PUNCT_NONE;
-    else if (!strcmp(str, "all")) punct = PUNCT_ALL;
-    else if (!strcmp(str, "some")) punct = PUNCT_SOME;
+    if (!strcmp(str, "none")) punct = SPD_PUNCT_NONE;
+    else if (!strcmp(str, "all")) punct = SPD_PUNCT_ALL;
+    else if (!strcmp(str, "some")) punct = SPD_PUNCT_SOME;
     else punct = -1;
 
     return punct;
diff --git a/src/modules/espeak.c b/src/modules/espeak.c
index 8d0ddc0..7ff1a0f 100644
--- a/src/modules/espeak.c
+++ b/src/modules/espeak.c
@@ -157,7 +157,7 @@ static int uri_callback(int type, const char *uri, const 
char *base);
 static void espeak_set_rate(signed int rate);
 static void espeak_set_pitch(signed int pitch);
 static void espeak_set_volume(signed int volume);
-static void espeak_set_punctuation_mode(EPunctMode punct_mode);
+static void espeak_set_punctuation_mode(SPDPunctuation punct_mode);
 static void espeak_set_cap_let_recogn(ECapLetRecogn cap_mode);
 
 #if 0
@@ -662,17 +662,17 @@ espeak_set_pitch(signed int pitch)
 }
 
 static void
-espeak_set_punctuation_mode(EPunctMode punct_mode)
+espeak_set_punctuation_mode(SPDPunctuation punct_mode)
 {
        espeak_PUNCT_TYPE espeak_punct_mode = espeakPUNCT_SOME;
        switch (punct_mode)  {
-       case PUNCT_ALL:
+       case SPD_PUNCT_ALL:
                espeak_punct_mode = espeakPUNCT_ALL;
                break;
-       case PUNCT_SOME:
+       case SPD_PUNCT_SOME:
                espeak_punct_mode = espeakPUNCT_SOME;
                break;
-       case PUNCT_NONE:
+       case SPD_PUNCT_NONE:
                espeak_punct_mode = espeakPUNCT_NONE;
                break;
        }
diff --git a/src/modules/festival.c b/src/modules/festival.c
index 2cac800..97b20af 100644
--- a/src/modules/festival.c
+++ b/src/modules/festival.c
@@ -141,7 +141,7 @@ void festival_set_pitch(signed int pitch);
 void festival_set_voice(EVoiceType voice);
 void festival_set_synthesis_voice(char* synthesis_voice);
 void festival_set_language(char* language);
-void festival_set_punctuation_mode(EPunctMode punct);
+void festival_set_punctuation_mode(SPDPunctuation punct);
 void festival_set_cap_let_recogn(ECapLetRecogn recogn);
 void festival_set_volume(signed int volume);
 
@@ -835,7 +835,7 @@ festival_set_volume(signed int volume)
 }
 
 void
-festival_set_punctuation_mode(EPunctMode punct)
+festival_set_punctuation_mode(SPDPunctuation punct)
 {
     char *punct_mode;
     punct_mode = spd_punct2str(punct);
diff --git a/src/modules/generic.c b/src/modules/generic.c
index faf8e8b..12017b6 100644
--- a/src/modules/generic.c
+++ b/src/modules/generic.c
@@ -63,7 +63,7 @@ void generic_set_pitch(signed int pitch);
 void generic_set_voice(EVoiceType voice);
 void generic_set_language(char* language);
 void generic_set_volume(signed int volume);
-void generic_set_punct(EPunctMode punct);
+void generic_set_punct(SPDPunctuation punct);
 
 /* Fill the module_info structure with pointers to this modules functions */
 
@@ -617,17 +617,17 @@ generic_set_voice(EVoiceType voice)
 }
 
 void
-generic_set_punct(EPunctMode punct)
+generic_set_punct(SPDPunctuation punct)
 {
-    if (punct == PUNCT_NONE){
+    if (punct == SPD_PUNCT_NONE){
         generic_msg_punct_str = g_strdup((char*) GenericPunctNone);
        return;
     }
-    else if (punct == PUNCT_SOME){
+    else if (punct == SPD_PUNCT_SOME){
        generic_msg_punct_str = g_strdup((char*) GenericPunctSome);
        return;
     }
-    else if (punct == PUNCT_ALL){
+    else if (punct == SPD_PUNCT_ALL){
        generic_msg_punct_str = g_strdup((char*) GenericPunctAll);
        return;
     }
diff --git a/src/modules/ibmtts.c b/src/modules/ibmtts.c
index e51a5c2..826e9f3 100644
--- a/src/modules/ibmtts.c
+++ b/src/modules/ibmtts.c
@@ -255,7 +255,7 @@ static void ibmtts_set_language_and_voice(char *lang, 
EVoiceType voice, char* di
 static void ibmtts_set_synthesis_voice(char *);
 static void ibmtts_set_rate(signed int rate);
 static void ibmtts_set_pitch(signed int pitch);
-static void ibmtts_set_punctuation_mode(EPunctMode punct_mode);
+static void ibmtts_set_punctuation_mode(SPDPunctuation punct_mode);
 static void ibmtts_set_volume(signed int pitch);
 
 /* Internal function prototypes for synthesis thread. */
@@ -979,7 +979,7 @@ _ibmtts_synth(void* nothing)
                 eciSetParam(eciHandle, eciTextMode, eciTextModeDefault);
                 break;
             case MSGTYPE_SPELL:
-                if (PUNCT_NONE != msg_settings.punctuation_mode)
+                if (SPD_PUNCT_NONE != msg_settings.punctuation_mode)
                     eciSetParam(eciHandle, eciTextMode, eciTextModeAllSpell);
                 else
                     eciSetParam(eciHandle, eciTextMode, eciTextModeAlphaSpell);
@@ -1103,7 +1103,7 @@ ibmtts_set_pitch(signed int pitch)
 }
 
 static void
-ibmtts_set_punctuation_mode(EPunctMode punct_mode)
+ibmtts_set_punctuation_mode(SPDPunctuation punct_mode)
 {
     const char* fmt = "`Pf%d%s";
     size_t len = strlen(fmt) + strlen(IbmttsPunctuationList) + sizeof('\0');
diff --git a/src/modules/ivona.c b/src/modules/ivona.c
index ff9fbe1..bfdb463 100644
--- a/src/modules/ivona.c
+++ b/src/modules/ivona.c
@@ -67,7 +67,7 @@ static int ivona_get_msgpart(struct dumbtts_conf *conf, 
EMessageType type,
                      int cap_mode, char *delimeters, int punct_mode,
                      char *punct_some);
 static void ivona_set_volume(signed int volume);
-static void ivona_set_punctuation_mode(EPunctMode punct_mode);
+static void ivona_set_punctuation_mode(SPDPunctuation punct_mode);
 static void ivona_set_cap_let_recogn(ECapLetRecogn cap_mode);
 
 static void* _ivona_speak(void*);
@@ -604,17 +604,17 @@ ivona_set_cap_let_recogn(ECapLetRecogn cap_mode)
 }
 
 static void
-ivona_set_punctuation_mode(EPunctMode punct_mode)
+ivona_set_punctuation_mode(SPDPunctuation punct_mode)
 {
        ivona_punct_mode=1;
        switch (punct_mode)  {
-       case PUNCT_ALL:
+       case SPD_PUNCT_ALL:
                ivona_punct_mode=2;
                break;
-       case PUNCT_SOME:
+       case SPD_PUNCT_SOME:
                ivona_punct_mode=1;
                break;
-       case PUNCT_NONE:
+       case SPD_PUNCT_NONE:
                ivona_punct_mode=0;
                break;
        }
diff --git a/src/modules/module_utils.h b/src/modules/module_utils.h
index def27e5..2a8a088 100644
--- a/src/modules/module_utils.h
+++ b/src/modules/module_utils.h
@@ -52,7 +52,7 @@ typedef struct{
     signed int pitch;
     signed int volume;
 
-    EPunctMode punctuation_mode;
+    SPDPunctuation punctuation_mode;
     ESpellMode spelling_mode;
     ECapLetRecogn cap_let_recogn;
 
@@ -95,7 +95,7 @@ int module_num_dc_options;
  msg_settings.rate = 0;\
  msg_settings.pitch = 0;\
  msg_settings.volume = 0;\
- msg_settings.punctuation_mode = PUNCT_NONE;\
+ msg_settings.punctuation_mode = SPD_PUNCT_NONE;\
  msg_settings.spelling_mode = SPELLING_OFF;\
  msg_settings.cap_let_recogn = RECOGN_NONE;\
  msg_settings.language = NULL;\
diff --git a/src/server/configuration.c b/src/server/configuration.c
index 6edc2f1..980580a 100644
--- a/src/server/configuration.c
+++ b/src/server/configuration.c
@@ -189,7 +189,7 @@ GLOBAL_FDSET_OPTION_CB_INT(DefaultPauseContext, 
pause_context, 1, "")
 
 GLOBAL_FDSET_OPTION_CB_SPECIAL(DefaultPriority, priority, int, spd_str2prio)
 GLOBAL_FDSET_OPTION_CB_SPECIAL(DefaultVoiceType, voice, EVoiceType, 
spd_str2voice)
-GLOBAL_FDSET_OPTION_CB_SPECIAL(DefaultPunctuationMode, punctuation_mode, 
EPunctMode, spd_str2punct)
+GLOBAL_FDSET_OPTION_CB_SPECIAL(DefaultPunctuationMode, punctuation_mode, 
SPDPunctuation, spd_str2punct)
 GLOBAL_FDSET_OPTION_CB_SPECIAL(DefaultCapLetRecognition, cap_let_recogn, 
ECapLetRecogn, spd_str2cap)
 
 SPEECHD_OPTION_CB_STR_M(CommunicationMethod, communication_method)
@@ -439,7 +439,7 @@ void
 load_default_global_set_options()
 {
     GlobalFDSet.priority = 3;
-    GlobalFDSet.punctuation_mode = PUNCT_NONE;
+    GlobalFDSet.punctuation_mode = SPD_PUNCT_NONE;
     GlobalFDSet.spelling_mode = 0;
     GlobalFDSet.rate = 0;
     GlobalFDSet.pitch = 0;
diff --git a/src/server/parse.c b/src/server/parse.c
index 09806c3..e89ac29 100644
--- a/src/server/parse.c
+++ b/src/server/parse.c
@@ -514,14 +514,14 @@ parse_set(const char *buf, const int bytes, const int fd, 
const TSpeechDSock *sp
     }
     else if (TEST_CMD(set_sub, "punctuation")){
         char *punct_s;
-        EPunctMode punctuation_mode;
+        SPDPunctuation punctuation_mode;
 
         NOT_ALLOWED_INSIDE_BLOCK();
         GET_PARAM_STR(punct_s, 3, CONV_DOWN);
 
-        if(TEST_CMD(punct_s,"all")) punctuation_mode = PUNCT_ALL;
-        else if(TEST_CMD(punct_s,"some")) punctuation_mode = PUNCT_SOME;       
 
-        else if(TEST_CMD(punct_s,"none")) punctuation_mode = PUNCT_NONE;       
 
+        if(TEST_CMD(punct_s,"all")) punctuation_mode = SPD_PUNCT_ALL;
+        else if(TEST_CMD(punct_s,"some")) punctuation_mode = SPD_PUNCT_SOME;
+        else if(TEST_CMD(punct_s,"none")) punctuation_mode = SPD_PUNCT_NONE;
         else{
             g_free(punct_s);
             return g_strdup(ERR_PARAMETER_INVALID);
diff --git a/src/server/set.c b/src/server/set.c
index fd71a7e..ecb9327 100644
--- a/src/server/set.c
+++ b/src/server/set.c
@@ -164,10 +164,10 @@ set_voice_uid(int uid, char *voice)
     return 0;
 }
 
-SET_SELF_ALL(EPunctMode, punctuation_mode)
+SET_SELF_ALL(SPDPunctuation, punctuation_mode)
 
 int
-set_punctuation_mode_uid(int uid, EPunctMode punctuation)
+set_punctuation_mode_uid(int uid, SPDPunctuation punctuation)
 {
     TFDSetElement *settings;
        
diff --git a/src/server/set.h b/src/server/set.h
index 73a3482..1fbb45a 100644
--- a/src/server/set.h
+++ b/src/server/set.h
@@ -44,7 +44,7 @@ int set_spelling_uid(int uid, ESpellMode spelling);
 int set_output_module_self(int uid, char *output_module);
 int set_voice_uid(int uid, char *voice);
 int set_synthesis_voice_uid(int uid, char *synthesis_voice);
-int set_punctuation_mode_uid(int uid, EPunctMode punctuation);
+int set_punctuation_mode_uid(int uid, SPDPunctuation punctuation);
 int set_capital_letter_recognition_uid(int uid, ECapLetRecogn recogn);
 int set_output_module_uid(int uid, char* output_module);
 int set_ssml_mode_uid(int uid, int ssml_mode);
@@ -65,7 +65,7 @@ int set_output_module_self(int fd, char *output_module);
 int set_client_name_self(int fd, char *client_name);
 int set_voice_self(int fd, char *voice);
 int set_synthesis_voice_self(int fd, char *synthesis_voice);
-int set_punctuation_mode_self(int fd, EPunctMode punctuation);
+int set_punctuation_mode_self(int fd, SPDPunctuation punctuation);
 int set_capital_letter_recognition_self(int fd, ECapLetRecogn recogn);
 int set_ssml_mode_self(int fd, int ssml_mode);
 int set_notification_self(int fd, char *type, int val);
@@ -84,7 +84,7 @@ int set_spelling_all(ESpellMode spelling);
 int set_output_module_all(char* output_module);
 int set_voice_all(char *voice);
 int set_synthesis_voice_all(char *synthesis_voice);
-int set_punctuation_mode_all(EPunctMode punctuation);
+int set_punctuation_mode_all(SPDPunctuation punctuation);
 int set_capital_letter_recognition_all(ECapLetRecogn recogn);
 int set_ssml_mode_all(int ssml_mode);
 int set_pause_context_all(int pause_context);
diff --git a/src/server/speechd.h b/src/server/speechd.h
index f5424f9..cb094ee 100644
--- a/src/server/speechd.h
+++ b/src/server/speechd.h
@@ -84,7 +84,7 @@ typedef struct{
     signed int rate;           /* Speed of voice from <-100;+100>, 0 is the 
default */
     signed int pitch;          /* Pitch of voice from <-100;+100>, 0 is the 
default */
     signed int volume;         /* Volume of voice from <-100;+100), 0 is the 
default */
-    EPunctMode punctuation_mode;       /* Punctuation mode: 0, 1 or 2
+    SPDPunctuation punctuation_mode;   /* Punctuation mode: 0, 1 or 2
                                    0   -       no punctuation
                                    1   -       all punctuation
                                    2   -       only user-selected punctuation 
*/
diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
index a4d25a6..1a24925 100644
--- a/src/tests/Makefile.am
+++ b/src/tests/Makefile.am
@@ -2,7 +2,7 @@
 
 c_api = $(top_builddir)/src/api/c
 
-AM_CPPFLAGS = -I$(top_srcdir)/src/api/c
+AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src/api/c
 
 bin_PROGRAMS = long_message clibrary clibrary2 run_test connection_recovery
 
-- 
1.6.0.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]