mirror of
https://github.com/linux-speakup/espeakup.git
synced 2026-08-09 09:19:09 +02:00
removed open_softsynth and close_softsynth
The thread can now handle the softsynth device, so main doesn't need to call these functions.
This commit is contained in:
parent
a58f93cd74
commit
c5fce64f25
3 changed files with 15 additions and 27 deletions
12
espeakup.c
12
espeakup.c
|
|
@ -97,12 +97,6 @@ int main(int argc, char **argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
/* open the softsynth. */
|
||||
if (!open_softsynth()) {
|
||||
perror("Unable to open the softsynth device");
|
||||
return 3;
|
||||
}
|
||||
|
||||
/*
|
||||
* If we are not in debug mode, become a daemon and store the pid.
|
||||
*/
|
||||
|
|
@ -135,5 +129,11 @@ int main(int argc, char **argv)
|
|||
return 4;
|
||||
}
|
||||
|
||||
/* Spawn our softsynth thread. */
|
||||
err = pthread_create(&softsynth_thread_id, NULL, &softsynth_thread, &s);
|
||||
if (err != 0) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,8 +74,6 @@ extern espeak_ERROR set_volume(struct synth_t *s, int vol,
|
|||
enum adjust_t adj);
|
||||
extern espeak_ERROR stop_speech(void);
|
||||
extern espeak_ERROR speak_text(struct synth_t *s);
|
||||
extern int open_softsynth(void);
|
||||
extern void close_softsynth(void);
|
||||
extern void *softsynth_thread(void *arg);
|
||||
extern void stop_runner(void);
|
||||
extern void *queue_runner(void *arg);
|
||||
|
|
|
|||
28
softsynth.c
28
softsynth.c
|
|
@ -33,25 +33,6 @@ const size_t maxBufferSize = 1025;
|
|||
/* synth flush character */
|
||||
const int synthFlushChar = 0x18;
|
||||
|
||||
static int softFD = 0;
|
||||
|
||||
int open_softsynth(void)
|
||||
{
|
||||
int rc;
|
||||
|
||||
softFD = open("/dev/softsynth", O_RDWR | O_NONBLOCK);
|
||||
if (softFD < 0)
|
||||
rc = 0;
|
||||
else
|
||||
rc = 1;
|
||||
return rc;
|
||||
}
|
||||
|
||||
void close_softsynth(void)
|
||||
{
|
||||
close(softFD);
|
||||
}
|
||||
|
||||
static int process_command(struct synth_t *s, char *buf, int start)
|
||||
{
|
||||
char *cp;
|
||||
|
|
@ -150,6 +131,13 @@ void *softsynth_thread(void *arg)
|
|||
char buf[maxBufferSize];
|
||||
char *cp;
|
||||
|
||||
/* open the softsynth. */
|
||||
softFD = open("/dev/softsynth", O_RDWR | O_NONBLOCK);
|
||||
if (softFD < 0) {
|
||||
perror("Unable to open the softsynth device");
|
||||
should_run = 0;
|
||||
}
|
||||
|
||||
while (should_run) {
|
||||
FD_ZERO(&set);
|
||||
FD_SET(softFD, &set);
|
||||
|
|
@ -180,5 +168,7 @@ void *softsynth_thread(void *arg)
|
|||
}
|
||||
process_buffer(s, buf, length);
|
||||
}
|
||||
if (softFD)
|
||||
close(softFD);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue