edit by hand

more formatting improvements
This commit is contained in:
Alexander Epaneshnikov 2021-06-15 23:55:43 +03:00 committed by William
commit e13ceb3cce
11 changed files with 44 additions and 44 deletions

View file

@ -1,5 +1,5 @@
/*
* espeakup - interface which allows speakup to use espeak
* espeakup - interface which allows speakup to use espeak-ng
*
* Copyright (C) 2008 William Hubbs
*

View file

@ -1,5 +1,5 @@
/*
* espeakup - interface which allows speakup to use espeak
* espeakup - interface which allows speakup to use espeak-ng
*
* Copyright (C) 2008 William Hubbs
*

View file

@ -1,5 +1,5 @@
/*
* espeakup - interface which allows speakup to use espeak
* espeakup - interface which allows speakup to use espeak-ng
*
* Copyright (C) 2008 William Hubbs
*
@ -28,7 +28,7 @@
#include "espeakup.h"
/* path to our pid file */
// path to our pid file
char *pidPath = "/var/run/espeakup.pid";
int debug = 0;
@ -60,7 +60,7 @@ int espeakup_start_daemon(void)
exit(1);
}
if (pid) {
/* Parent, just wait for daemon */
// Parent, just wait for daemon
if (read(fds[0], &c, 1) < 0) {
printf("Espeakup is already running!\n");
exit(1);
@ -68,14 +68,14 @@ int espeakup_start_daemon(void)
exit(c);
}
/* Child, create new session */
// Child, create new session
setsid();
pid = fork();
if (pid)
/* Intermediate child, just exit */
// Intermediate child, just exit
exit(0);
/* Child */
// Child
if (chdir("/") < 0) {
c = 1;
(void) write(fds[1], &c, 1);
@ -110,7 +110,7 @@ int espeakup_is_running(void)
s[n] = 0;
n = sscanf(s, "%d", &pid);
if (n == 1 && (!kill(pid, 0) || errno != ESRCH)) {
/* Already running */
// Already running
close(pidFile);
return 1;
}
@ -153,13 +153,13 @@ int main(int argc, char **argv)
return 2;
}
/* set up the pipe used to wake the espeak thread */
// set up the pipe used to wake the espeak thread
if (pipe(self_pipe_fds) < 0) {
perror("Unable to create pipe");
return 5;
}
/* process command line options */
// process command line options
process_cli(argc, argv);
if (!debug && espeakup_mode == ESPEAKUP_MODE_SPEAKUP) {
@ -179,7 +179,7 @@ int main(int argc, char **argv)
close(devnull);
}
/* create the signal processing thread here. */
// create the signal processing thread here.
err = pthread_create(&signal_thread_id, NULL, signal_thread, NULL);
if (err != 0) {
ret = 4;
@ -195,26 +195,26 @@ int main(int argc, char **argv)
sigaddset(&sigset, SIGTERM);
sigprocmask(SIG_BLOCK, &sigset, NULL);
/* Initialize espeak */
// Initialize espeak
if (initialize_espeak(&s) < 0) {
ret = 2;
goto out;
}
/* open the softsynth */
// open the softsynth
if (open_softsynth() < 0) {
ret = 2;
goto out;
}
/* Spawn our softsynth thread. */
// Spawn our softsynth thread.
err = pthread_create(&softsynth_thread_id, NULL, softsynth_thread, &s);
if (err != 0) {
ret = 4;
goto out;
}
/* Spawn our espeak-interacting thread. */
// Spawn our espeak-interacting thread.
err = pthread_create(&espeak_thread_id, NULL, espeak_thread, &s);
if (err != 0) {
ret = 4;
@ -224,7 +224,7 @@ int main(int argc, char **argv)
if (!debug && espeakup_mode == ESPEAKUP_MODE_SPEAKUP)
(void) write(fd, &ret, 1);
/* wait for the threads to shut down. */
// wait for the threads to shut down.
pthread_join(signal_thread_id, NULL);
pthread_join(softsynth_thread_id, NULL);
pthread_join(espeak_thread_id, NULL);
@ -239,8 +239,7 @@ out:
unlink(pidPath);
if (ret != 0)
(void) write(fd, &ret, 1);
/* If ret was 0, the status byte was written before joining
* the threads. */
// If ret was 0, the status byte was written before joining the threads.
}
return ret;
}

View file

@ -1,5 +1,5 @@
/*
* espeakup - interface which allows speakup to use espeak
* espeakup - interface which allows speakup to use espeak-ng
*
* Copyright (C) 2008 William Hubbs
*
@ -20,7 +20,7 @@
#ifndef __ESPEAKUP_H
#define __ESPEAKUP_H
/* This was added for gcc 4.3 */
// This was added for gcc 4.3
#include <pthread.h>
#include <stddef.h>

View file

@ -1,5 +1,5 @@
/*
* espeakup - interface which allows speakup to use espeak
* espeakup - interface which allows speakup to use espeak-ng
*
* Note that these functions are meant to be used in either a single or
* multi-threaded environment, so they know nothing about mutexes, etc.

View file

@ -1,5 +1,5 @@
/*
* espeakup - interface which allows speakup to use espeak
* espeakup - interface which allows speakup to use espeak-ng
*
* Copyright (C) 2008 William Hubbs
*
@ -20,7 +20,7 @@
#ifndef __QUEUE_H
#define __QUEUE_H
struct queue_t; /* An opaque type. */
struct queue_t; // An opaque type.
extern struct queue_t *new_queue(void);
extern int queue_add(struct queue_t *q, void *entry);

View file

@ -1,5 +1,5 @@
/*
* espeakup - interface which allows speakup to use espeak
* espeakup - interface which allows speakup to use espeak-ng
*
* Copyright (C) 2008 William Hubbs
*
@ -21,10 +21,11 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#define STOP_MSG "s"
#include "espeakup.h"
#define STOP_MSG "s"
/*
* We install a dummy signal handler to let the o/s know that we
* do not want the default action to be performed since we are
@ -41,7 +42,7 @@ void *signal_thread(void *arg)
int sig;
memset(&temp, 0, sizeof(struct sigaction));
/* install dummy handlers for the signals we want to process */
// install dummy handlers for the signals we want to process
temp.sa_handler = dummy_handler;
sigemptyset(&temp.sa_mask);
sigaction(SIGINT, &temp, NULL);
@ -66,7 +67,7 @@ void *signal_thread(void *arg)
pthread_mutex_lock(&queue_guard);
}
pthread_mutex_unlock(&queue_guard);
/* Tell the reader to stop, if it is in a select() call. */
// Tell the reader to stop, if it is in a select() call.
write(PIPE_WRITE_FD, STOP_MSG, strlen(STOP_MSG));
return NULL;
}

View file

@ -1,5 +1,5 @@
/*
* espeakup - interface which allows speakup to use espeak
* espeakup - interface which allows speakup to use espeak-ng
*
* Copyright (C) 2008 William Hubbs
*
@ -29,15 +29,15 @@
#include "espeakup.h"
#include "stringhandling.h"
/* max buffer size */
// max buffer size
static const size_t maxBufferSize = 16 * 1024 + 1;
/* synth flush character */
// synth flush character
static const int synthFlushChar = 0x18;
static int softFD = 0;
/* Text accumulator: */
// Text accumulator:
char *textAccumulator;
int textAccumulator_l;
@ -227,26 +227,26 @@ static void request_espeak_stop(void)
{
pthread_mutex_lock(&queue_guard);
stop_requested = 1;
pthread_cond_signal(&runner_awake); /* Wake runner, if necessary. */
pthread_cond_signal(&runner_awake); // Wake runner, if necessary.
while (should_run && stop_requested)
pthread_cond_wait(&stop_acknowledged,
&queue_guard); /* wait for acknowledgement. */
// wait for acknowledgement.
pthread_cond_wait(&stop_acknowledged, &queue_guard);
pthread_mutex_unlock(&queue_guard);
}
int open_softsynth(void)
{
int rc = 0;
/* If we're in acsint mode, we read from stdin. No need to open. */
// If we're in acsint mode, we read from stdin. No need to open.
if (espeakup_mode == ESPEAKUP_MODE_ACSINT) {
softFD = STDIN_FILENO;
return 0;
}
/* open the softsynth. */
// open the softsynth.
softFD = open("/dev/softsynthu", O_RDWR | O_NONBLOCK);
if (softFD < 0 && errno == ENOENT)
/* Kernel without unicode support? Try without unicode. */
// Kernel without unicode support? Try without unicode.
softFD = open("/dev/softsynth", O_RDWR | O_NONBLOCK);
if (softFD < 0) {
perror("Unable to open the softsynth device");

View file

@ -1,5 +1,5 @@
/*
* espeakup - interface which allows speakup to use espeak
* espeakup - interface which allows speakup to use espeak-ng
*
* Copyright (C) 2011 William Hubbs
*
@ -75,9 +75,9 @@ void stringAndString(char **s, int *l, const char *t)
oldlen = *l;
newlen = oldlen + strlen(t);
*l = newlen;
++newlen; /* room for the 0 */
++newlen; // room for the 0
x = oldlen ^ newlen;
if (x > oldlen) { /* must realloc */
if (x > oldlen) { // must realloc
newlen |= (newlen >> 1);
newlen |= (newlen >> 2);
newlen |= (newlen >> 4);
@ -98,7 +98,7 @@ void stringAndBytes(char **s, int *l, const char *t, int cnt)
*l = newlen;
++newlen;
x = oldlen ^ newlen;
if (x > oldlen) { /* must realloc */
if (x > oldlen) { // must realloc
newlen |= (newlen >> 1);
newlen |= (newlen >> 2);
newlen |= (newlen >> 4);

View file

@ -1,5 +1,5 @@
/*
* espeakup - interface which allows speakup to use espeak
* espeakup - interface which allows speakup to use espeak-ng
*
* Copyright (C) 2011 William Hubbs
*

View file

@ -1,5 +1,5 @@
/*
* espeakup - interface which allows speakup to use espeak
* espeakup - interface which allows speakup to use espeak-ng
*
* Copyright (C) 2008 William Hubbs
*