From 86e93edeb09774d3689cca7f9fe96aa484f3bd6d Mon Sep 17 00:00:00 2001 From: William Hubbs Date: Fri, 15 Aug 2008 22:34:49 -0500 Subject: [PATCH] removed softsynth code from main module --- espeakup.c | 10 ++-------- espeakup.h | 3 ++- softsynth.c | 17 +++++++++++++++++ 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/espeakup.c b/espeakup.c index 584df2c..a37e214 100644 --- a/espeakup.c +++ b/espeakup.c @@ -18,7 +18,6 @@ */ #include -#include #include #include #include @@ -37,7 +36,6 @@ const char *shortOptions = "dhv"; const char *pidPath = "/var/run/espeakup.pid"; int debug = 0; -int softFD; int espeakup_is_running(void) { @@ -76,7 +74,7 @@ void espeakup_sighandler(int sig) /* shutdown espeak and close the softsynth */ espeak_Terminate(); - close(softFD); + close_softsynth(); if (! debug) unlink(pidPath); @@ -153,11 +151,7 @@ int main(int argc, char **argv) } /* open the softsynth. */ - softFD = open ("/dev/softsynth", O_RDWR | O_NONBLOCK); - if (softFD < 0) { - perror("Unable to open the softsynth device"); - return 3; - } + open_softsynth(); /* initialize espeak */ espeak_Initialize(AUDIO_OUTPUT_PLAYBACK, 0, NULL, 0); diff --git a/espeakup.h b/espeakup.h index 82f1750..f0a0de1 100644 --- a/espeakup.h +++ b/espeakup.h @@ -33,7 +33,6 @@ struct synth_t { }; extern int debug; -extern int softFD; extern int SynthCallback(short *wav, int numsamples, espeak_EVENT *events); extern espeak_ERROR set_frequency (struct synth_t *s); @@ -43,6 +42,8 @@ extern espeak_ERROR set_voice(struct synth_t *s); extern espeak_ERROR set_volume (struct synth_t *s); extern espeak_ERROR stop_speech(void); extern espeak_ERROR speak_text(struct synth_t *s); +extern void open_softsynth(void); +extern void close_softsynth(void); extern void main_loop (struct synth_t *s); #endif diff --git a/softsynth.c b/softsynth.c index 5f6c0f2..55ae171 100644 --- a/softsynth.c +++ b/softsynth.c @@ -18,6 +18,7 @@ */ #include +#include #include #include #include @@ -27,6 +28,8 @@ /* max buffer size */ const int maxBufferSize = 1025; +static int softFD = 0; + static int process_command(struct synth_t *s, char *buf, int start) { int rc; @@ -118,6 +121,20 @@ static void process_buffer (struct synth_t *s, char *buf, size_t length) } } +void open_softsynth(void) +{ + softFD = open ("/dev/softsynth", O_RDWR | O_NONBLOCK); + if (softFD < 0) { + perror("Unable to open the softsynth device"); + exit(3); + } +} + +void close_softsynth(void) +{ + close(softFD); +} + void main_loop (struct synth_t *s) { fd_set set;