[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 8/9] moved module_main.c from ivona.c to Makefile.am
From: |
Andrei Kholodnyi |
Subject: |
[PATCH 8/9] moved module_main.c from ivona.c to Makefile.am |
Date: |
Sun, 5 Sep 2010 01:42:26 +0200 |
---
src/modules/Makefile.am | 2 +-
src/modules/ivona.c | 18 +++++--------
src/modules/ivona_client.c | 58 +++++++++++++++++++++++++------------------
3 files changed, 42 insertions(+), 36 deletions(-)
diff --git a/src/modules/Makefile.am b/src/modules/Makefile.am
index 263401d..aa39c52 100644
--- a/src/modules/Makefile.am
+++ b/src/modules/Makefile.am
@@ -50,7 +50,7 @@ sd_espeak_SOURCES = espeak.c module_main.c module_utils.c
module_utils.h
sd_espeak_LDFLAGS = @RPATH@ '$(spdlibdir)'
sd_espeak_LDADD = -lsdaudio -lespeak -ldotconf @glib_libs@ @SNDFILE_LIBS@
@gthread_libs@ @EXTRA_ESPEAK_LIBS@
-sd_ivona_SOURCES = ivona.c module_utils.c module_utils.h
+sd_ivona_SOURCES = ivona.c ivona_client.c module_main.c module_utils.c
module_utils.h
sd_ivona_LDFLAGS = @RPATH@ '$(spdlibdir)'
sd_ivona_LDADD = -lsdaudio -ldumbtts -lpthread -ldotconf @glib_libs@
@SNDFILE_LIBS@ @gthread_libs@
diff --git a/src/modules/ivona.c b/src/modules/ivona.c
index 68e10de..d1a744b 100644
--- a/src/modules/ivona.c
+++ b/src/modules/ivona.c
@@ -43,6 +43,10 @@
#define DEBUG_MODULE 1
DECLARE_DEBUG();
+#define IVONA_CACHE_SIZE 256
+#define IVONA_CACHE_MAX_SAMPLES 65536
+#define IVONA_CACHE_MAX_STRLEN 11
+
/* Thread and process control */
static int ivona_speaking = 0;
@@ -80,8 +84,6 @@ MOD_OPTION_1_STR(IvonaSpeakerName);
static struct dumbtts_conf *ivona_conf;
-#include "ivona_client.c"
-
/* Public functions */
int
@@ -126,7 +128,7 @@ module_init(char **status_info)
info = g_string_new("");
/* Init Ivona */
- if (ivona_init_sock()) {
+ if (ivona_init_sock(IvonaServerHost, IvonaServerPort)) {
DBG("Couldn't init socket parameters");
*status_info = strdup("Can't initialize socket. "
"Check server host/port.");
@@ -338,7 +340,7 @@ _ivona_speak(void* nothing)
DBG("Got icon");
}
if (!audio && !icon[0]) {
- if(!msg || !*msg || ivona_get_msgpart(&msg,&icon,&buf,&len)) {
+ if(!msg || !*msg || ivona_get_msgpart(ivona_conf,
ivona_message_type, &msg,&icon,&buf,&len,ivona_cap_mode, IvonaDelimiters,
ivona_punct_mode, IvonaPunctuationSome)) {
ivona_speaking=0;
if (ivona_stop) module_report_event_stop();
else module_report_event_end();
@@ -381,7 +383,7 @@ _ivona_speak(void* nothing)
break;
}
if (icon[0]) {
- play_icon(icon);
+ play_icon(IvonaSoundIconPath, icon);
if (ivona_stop) {
ivona_speaking=0;
module_report_event_stop();
@@ -466,9 +468,3 @@ ivona_set_punctuation_mode(EPunctMode punct_mode)
break;
}
}
-
-
-
-#include "module_main.c"
-
-
diff --git a/src/modules/ivona_client.c b/src/modules/ivona_client.c
index ab7423c..7d920c9 100644
--- a/src/modules/ivona_client.c
+++ b/src/modules/ivona_client.c
@@ -21,27 +21,37 @@
*
*/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <fcntl.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
+#include <unistd.h>
+
+#include <glib.h>
+#include <libdumbtts.h>
+
+#include "fdset.h"
+#include "module_utils.h"
static struct sockaddr_in sinadr;
-static char *ivona_get_wave_from_cache(char *to_say,int *nsamples);
-static void ivona_store_wave_in_cache(char *to_say,char *wave,int nsamples);
+char *ivona_get_wave_from_cache(char *to_say,int *nsamples);
+void ivona_store_wave_in_cache(char *to_say,char *wave,int nsamples);
-int ivona_init_sock(void)
+int ivona_init_sock(char *host, int port)
{
- if (!inet_aton(IvonaServerHost,&sinadr.sin_addr)) {
- struct hostent *h = gethostbyname(IvonaServerHost);
+ if (!inet_aton(host,&sinadr.sin_addr)) {
+ struct hostent *h = gethostbyname(host);
if (!h) return -1;
memcpy(&sinadr.sin_addr, h->h_addr, sizeof(struct in_addr));
endhostent();
}
sinadr.sin_family = AF_INET;
- sinadr.sin_port = htons(IvonaServerPort);
+ sinadr.sin_port = htons(port);
return 0;
}
@@ -81,7 +91,7 @@ static int get_unichar(char **str)
return wc;
}
-int ivona_get_msgpart(char **msg,char *icon,char **buf,int *len)
+int ivona_get_msgpart(struct dumbtts_conf *conf, EMessageType type, char
**msg,char *icon,char **buf,int *len, int cap_mode, char *delimeters, int
punct_mode, char * punct_some)
{
int rc;
int isicon;
@@ -94,8 +104,8 @@ int ivona_get_msgpart(char **msg,char *icon,char **buf,int
*len)
isicon=0;
icon[0]=0;
if (*buf) **buf=0;
- DBG("Ivona message %s type %d\n",*msg,ivona_message_type);
- switch(ivona_message_type) {
+ DBG("Ivona message %s type %d\n",*msg,type);
+ switch(type) {
case MSGTYPE_SOUND_ICON:
if (strlen(*msg)<63) {
strcpy(icon,*msg);
@@ -113,11 +123,11 @@ int ivona_get_msgpart(char **msg,char *icon,char
**buf,int *len)
*msg=NULL;
return 1;
}
-
n=dumbtts_WCharString(ivona_conf,wc,*buf,*len,ivona_cap_mode,&isicon);
+ n=dumbtts_WCharString(conf,wc,*buf,*len,cap_mode,&isicon);
if (n>0) {
*len=n+128;
*buf=xrealloc(*buf,*len);
-
n=dumbtts_WCharString(ivona_conf,wc,*buf,*len,ivona_cap_mode,&isicon);
+
n=dumbtts_WCharString(conf,wc,*buf,*len,cap_mode,&isicon);
}
if (n) {
*msg=NULL;
@@ -129,21 +139,21 @@ int ivona_get_msgpart(char **msg,char *icon,char
**buf,int *len)
case MSGTYPE_KEY:
case MSGTYPE_CHAR:
- if (ivona_message_type == MSGTYPE_KEY) {
-
n=dumbtts_KeyString(ivona_conf,*msg,*buf,*len,ivona_cap_mode,&isicon);
+ if (type == MSGTYPE_KEY) {
+
n=dumbtts_KeyString(conf,*msg,*buf,*len,cap_mode,&isicon);
}
else {
-
n=dumbtts_CharString(ivona_conf,*msg,*buf,*len,ivona_cap_mode,&isicon);
+
n=dumbtts_CharString(conf,*msg,*buf,*len,cap_mode,&isicon);
}
DBG("Got n=%d",n);
if (n>0) {
*len=n+128;
*buf=xrealloc(*buf,*len);
- if (ivona_message_type == MSGTYPE_KEY) {
-
n=dumbtts_KeyString(ivona_conf,*msg,*buf,*len,ivona_cap_mode,&isicon);
+ if (type == MSGTYPE_KEY) {
+
n=dumbtts_KeyString(conf,*msg,*buf,*len,cap_mode,&isicon);
}
else {
-
n=dumbtts_CharString(ivona_conf,*msg,*buf,*len,ivona_cap_mode,&isicon);
+
n=dumbtts_CharString(conf,*msg,*buf,*len,cap_mode,&isicon);
}
}
*msg=NULL;
@@ -153,7 +163,7 @@ int ivona_get_msgpart(char **msg,char *icon,char **buf,int
*len)
case MSGTYPE_TEXT:
pos=0;
- bytes=module_get_message_part(*msg,xbuf,&pos,
1023,IvonaDelimiters);
+ bytes=module_get_message_part(*msg,xbuf,&pos, 1023,delimeters);
DBG("Got bytes %d, %s",bytes,xbuf);
if (bytes <= 0) {
*msg=NULL;
@@ -163,12 +173,12 @@ int ivona_get_msgpart(char **msg,char *icon,char
**buf,int *len)
xbuf[bytes]=0;
-
n=dumbtts_GetString(ivona_conf,xbuf,*buf,*len,ivona_punct_mode,IvonaPunctuationSome,",.;:!?");
+
n=dumbtts_GetString(conf,xbuf,*buf,*len,punct_mode,punct_some,",.;:!?");
if (n>0) {
*len=n+128;
*buf=xrealloc(*buf,*len);
-
n=dumbtts_GetString(ivona_conf,xbuf,*buf,*len,ivona_punct_mode,IvonaPunctuationSome,",.;:!?");
+
n=dumbtts_GetString(conf,xbuf,*buf,*len,punct_mode,punct_some,",.;:!?");
}
if (n) {
*msg=NULL;
@@ -337,10 +347,10 @@ ivona_play_file(char *filename)
}
-void play_icon(char *name)
+void play_icon(char* path, char *name)
{
char buf[256];
- sprintf(buf,"%s%s",IvonaSoundIconPath,name);
+ sprintf(buf,"%s%s",path,name);
ivona_play_file(buf);
}
@@ -358,7 +368,7 @@ static struct ivona_cache {
char *wave;
} ica_head,ica_tail,icas[IVONA_CACHE_SIZE];
-static void ivona_init_cache(void)
+void ivona_init_cache(void)
{
ica_head.pred=&ica_tail;
ica_tail.succ=&ica_head;
@@ -416,7 +426,7 @@ void ivona_store_wave_in_cache(char *str,char *wave,int
samples)
DBG("Stored cache %s",str);
}
-static char *ivona_get_wave_from_cache(char *to_say,int *samples)
+char *ivona_get_wave_from_cache(char *to_say,int *samples)
{
struct ivona_cache *ica;
if (strlen(to_say)>IVONA_CACHE_MAX_STRLEN) return NULL;
--
1.6.0.4
- [PATCH 1/9] moved module_main.c from the dummy.c to Makefile.am, Andrei Kholodnyi, 2010/09/04
- [PATCH 2/9] moved module_main.c from cicero.c to Makefile.am, Andrei Kholodnyi, 2010/09/04
- [PATCH 3/9] moved module_main.c from espeak.c to Makefile.am, Andrei Kholodnyi, 2010/09/04
- [PATCH 4/9] moved module_main.c from festival.c to Makefile.am, Andrei Kholodnyi, 2010/09/04
- [PATCH 5/9] moved module.main.c from flite.c to Makefile.am, Andrei Kholodnyi, 2010/09/04
- [PATCH 6/9] moved module_main.c from generic.c to Makefile.am, Andrei Kholodnyi, 2010/09/04
- [PATCH 7/9] moved module_main.c from ibmtts.c to Makefile.am, Andrei Kholodnyi, 2010/09/04
- [PATCH 8/9] moved module_main.c from ivona.c to Makefile.am,
Andrei Kholodnyi <=
- [PATCH 9/9] moved fdsetconv.c from module_utils.c to Makefile.am, Andrei Kholodnyi, 2010/09/04
- [PATCH 9/9] moved fdsetconv.c from module_utils.c to Makefile.am, Christopher Brannon, 2010/09/08
- [PATCH 9/9] moved fdsetconv.c from module_utils.c to Makefile.am, Andrei Kholodnyi, 2010/09/08
- [PATCH 8/9] moved module_main.c from ivona.c to Makefile.am, Christopher Brannon, 2010/09/06
- [PATCH 8/9] moved module_main.c from ivona.c to Makefile.am, Andrei Kholodnyi, 2010/09/06
- [PATCH 4/9] moved module_main.c from festival.c to Makefile.am, Christopher Brannon, 2010/09/06
- [PATCH 4/9] moved module_main.c from festival.c to Makefile.am, Andrei Kholodnyi, 2010/09/06
- [PATCH 4/9] moved module_main.c from festival.c to Makefile.am, Andrei Kholodnyi, 2010/09/06
[PATCH 1/9] moved module_main.c from the dummy.c to Makefile.am, William Hubbs, 2010/09/04