speechd-discuss
[Top][All Lists]
Advanced

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

[PATCH 1/1] Remove unused function module_speak_thread_wfork()


From: Anatol
Subject: [PATCH 1/1] Remove unused function module_speak_thread_wfork()
Date: Thu, 12 Jan 2012 23:27:01 +0400

Remove function module_speak_thread_wfork() from module_utils.*.
Remove #include <semaphore.h> from module_utils.h.
Remove  definitions of TChildFunction and TParentFunction.
Update speech-dispatcher.texi.
---
 doc/speech-dispatcher.texi |   93 ++++++++++---------------------------------
 src/modules/module_utils.c |   72 ----------------------------------
 src/modules/module_utils.h |   17 --------
 3 files changed, 22 insertions(+), 160 deletions(-)
 mode change 100644 => 100755 doc/speech-dispatcher.texi

diff --git a/doc/speech-dispatcher.texi b/doc/speech-dispatcher.texi
old mode 100644
new mode 100755
index 45f9033..9073cfd
--- a/doc/speech-dispatcher.texi
+++ b/doc/speech-dispatcher.texi
@@ -3383,73 +3383,18 @@ in the middle of its run.
 @node Multi-process output modules, Memory Handling Functions, Functions for 
use when talking to synthesizer, Module Utils Functions and Macros
 @subsubsection Multi-process output modules
 
- at deffn {Module Utils function} void module_speak_thread_wfork (sem_t 
*semaphore,pid_t *process_pid, TChildFunction child_function, TParentFunction 
parent_function, int *speaking_flag, char **message, const size_t maxlen, const 
char *dividers, size_t *module_position, int *pause_requested)
- at findex module_speak_thread_wfork
-
-This function waits on the specified @code{semaphore} for activity.
-When the semaphore is on, it forks and creates pipes between the two
-processes in both directions.
-
-In the child, it starts the @code{child_function}. This function
-is supposed to never return. If it returns, exit(0) is called
-immediatelly.
-
-In the parent, it starts the @code{parent_function} and passes the
-parameters. It waits until the function returns and writes its return
-value to the @code{*module_position}. It then cleans the process, logs
-the return values of @code{waitpid()} using DBG, sets *speaking_flag
-to 0 and calls module_signal_end().
-
-It is intended to be run from a separate thread, because it doesn't
-return and it would block the communication on stdin/stdout.
-
- at code{semaphore} is the pthread-type semaphore on which requests
-for @code{child_function()} to run will be posted.
-
- at code{process_pid} is a pointer to an integer where the pid of the
-newly started child process should be stored.
-
- at code{child_function} is the function that should be called in the child.
-
- at code{parent_function} is the function that should be called in the parent.
-
- at code{speaking_flag} is a pointer to an integer where this function
-will write a 0 after the parent function terminates. This would mean
-that the synthesizer stopped speaking.
-
- at code{message} is a pointer to a NULL-terminated string containing the 
message
-that should be passed to the parent function for synthesis.
-
- at code{maxlen} is the maximum number of bytes that should be transfered from
-parent to child over the pipe.
-
- at code{dividers} is a NULL-terminated string containing the punctuation 
characters
-at which the parent function should divide the message into smaller pieces.
-
- at code{module_position} is a pointer to an integer for the actual position
-(according to index marks) where the speaking terminated, as returned by
-the parent function, will be stored.
-
- at code{pause_requested} is a pointer to an integer flag, which is either 0 if
-no pause request is pending, or 1 if the parent function should terminate
-at a convenient place in the message because a pause is requested.
-
-The two types of functions @code{child_function} and @code{parent_function}
-are:
+ at deffn {Module Utils function} size_t module_parent_wfork ( 
TModuleDoublePipe dpipe,
+const char* message, SPDMessageType msgtype, const size_t maxlen,
+const char* dividers, int *pause_requested)
+ at findex module_parent_wfork
 
- at example
-typedef void (*TChildFunction)(TModuleDoublePipe dpipe, const size_t maxlen);
-typedef size_t (*TParentFunction)(TModuleDoublePipe dpipe, const char* message,
-                             const size_t maxlen, const char* dividers,
-                             int *pause_requested);
- at end example
+It simply sends the data to the
+child in smaller pieces and waits for confirmation with a single
+ at code{C} character on the pipe from child to parent.
 
-The parameters have the same meaning as stated above. Additionally
-there is the @code{dpipe} parameter which contains the information
+ at code{dpipe} is a parameter which contains the information
 necessary for communicating through pipes between the parent and the
-child and vice-versa. Each of these functions should initialize
-the pipes at the beginning and then communicate through them. The
-preferred functions to do that are listed below.
+child and vice-versa.
 
 @example
 typedef address@hidden
@@ -3457,15 +3402,21 @@ typedef address@hidden
     int cp[2];            /* Child to parent pipe */
 @}TModuleDoublePipe;
 @end example
- at end deffn
 
- at deffn {Module Utils function} size_t module_parent_wfork ( 
TModuleDoublePipe dpipe, const char* message, const size_t maxlen, const char* 
dividers, int *pause_requested)
- at findex module_parent_wfork
+ at code{message} is a pointer to a NULL-terminated string containing the 
message
+for synthesis.
 
-This is a generic function that can be used as the @code{parent_function()}
-for @code{module_speak_thread_wfork}. It simply sends the data to the
-child in smaller pieces and waits for confirmation with a single
- at code{C} character on the pipe from child to parent.
+ at code{msgtype} is  the type of the message for synthesis.
+
+ at code{maxlen} is the maximum number of bytes that should be transfered
+over the pipe.
+
+ at code{dividers} is a NULL-terminated string containing the punctuation 
characters
+at which this function should divide the message into smaller pieces.
+
+ at code{pause_requested} is a pointer to an integer flag, which is either 0 if
+no pause request is pending, or 1 if the function should terminate
+at a convenient place in the message because a pause is requested.
 
 In the beginning, it initializes the pipes and then it enters a simple cycle:
 @enumerate
diff --git a/src/modules/module_utils.c b/src/modules/module_utils.c
index de81c79..f8c3c7b 100644
--- a/src/modules/module_utils.c
+++ b/src/modules/module_utils.c
@@ -604,78 +604,6 @@ module_strip_punctuation_default(char *buf)
     module_strip_punctuation_some(buf, "~#$%^&*+=|<>[]_");
 }
 
-void
-module_speak_thread_wfork(sem_t *semaphore, pid_t *process_pid, 
-                          TChildFunction child_function,
-                          TParentFunction parent_function,
-                          int *speaking_flag, char **message, const 
SPDMessageType *msgtype,
-                          const size_t maxlen, const char *dividers, size_t 
*module_position,
-                          int *pause_requested)
-{
-    TModuleDoublePipe module_pipe;
-    int ret;
-    int status;
-
-    set_speaking_thread_parameters();
-
-    while(1){        
-        sem_wait(semaphore);
-        DBG("Semaphore on\n");
-
-        ret = pipe(module_pipe.pc);
-        if (ret != 0){
-            DBG("Can't create pipe pc\n");
-            *speaking_flag = 0;
-            continue;
-        }
-
-        ret = pipe(module_pipe.cp);
-        if (ret != 0){
-            DBG("Can't create pipe cp\n");
-            close(module_pipe.pc[0]);     close(module_pipe.pc[1]);
-            *speaking_flag = 0;
-            continue;
-        }
-
-       DBG("Pipes initialized");
-
-        /* Create a new process so that we could send it signals */
-        *process_pid = fork();
-
-        switch(*process_pid){
-        case -1:       
-            DBG("Can't say the message. fork() failed!\n");
-            close(module_pipe.pc[0]);     close(module_pipe.pc[1]);
-            close(module_pipe.cp[0]);     close(module_pipe.cp[1]);
-            *speaking_flag = 0;
-            continue;
-
-        case 0:
-            /* This is the child. Make it speak, but exit on SIGINT. */
-
-            DBG("Starting child...\n");
-            (* child_function)(module_pipe, maxlen);           
-            exit(0);
-
-        default:
-            /* This is the parent. Send data to the child. */
-
-            *module_position = (* parent_function)(module_pipe, *message, 
*msgtype,
-                                                   maxlen, dividers, 
pause_requested);
-
-            DBG("Waiting for child...");
-            waitpid(*process_pid, &status, 0);            
-            
-            *speaking_flag = 0;
-
-           module_report_event_end();
-
-            DBG("child terminated -: status:%d signal?:%d signal number:%d.\n",
-                WIFEXITED(status), WIFSIGNALED(status), WTERMSIG(status));
-        }        
-    }
-}
-
 size_t
 module_parent_wfork(TModuleDoublePipe dpipe, const char* message, 
SPDMessageType msgtype,
                     const size_t maxlen, const char* dividers, int 
*pause_requested)
diff --git a/src/modules/module_utils.h b/src/modules/module_utils.h
index 031692f..eacda04 100644
--- a/src/modules/module_utils.h
+++ b/src/modules/module_utils.h
@@ -24,7 +24,6 @@
 #ifndef __MODULE_UTILS_H
 #define __MODULE_UTILS_H
 
-#include <semaphore.h>
 #include <dotconf.h>
 #include <unistd.h>
 #include <stdio.h>
@@ -34,13 +33,11 @@
 #include <glib.h>
 #include <pthread.h>
 #include <signal.h>
-#include <semaphore.h>
 #include <sys/wait.h>
 #include <sys/time.h>
 #include <errno.h>
 #include <dotconf.h>
 
-#include <semaphore.h>
 #include <sys/ipc.h>
 
 #include <speechd_types.h>
@@ -203,20 +200,6 @@ char *do_loglevel(void);
 char *do_debug(char *cmd_buf);
 void do_quit(void);
 
-typedef void (*TChildFunction) (TModuleDoublePipe dpipe, const size_t maxlen);
-typedef size_t(*TParentFunction) (TModuleDoublePipe dpipe, const char *message,
-                                 const SPDMessageType msgtype,
-                                 const size_t maxlen, const char *dividers,
-                                 int *pause_requested);
-
-void module_speak_thread_wfork(sem_t * semaphore, pid_t * process_pid,
-                              TChildFunction child_function,
-                              TParentFunction parent_function,
-                              int *speaking_flag, char **message,
-                              const SPDMessageType * msgtype,
-                              const size_t maxlen, const char *dividers,
-                              size_t * module_position, int *pause_requested);
-
 size_t module_parent_wfork(TModuleDoublePipe dpipe, const char *message,
                           SPDMessageType msgtype, const size_t maxlen,
                           const char *dividers, int *pause_requested);
-- 
1.7.4.1




reply via email to

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