speech-dispatcher: Multi-process output modules

 
 5.2.7.6 Multi-process output modules
 ....................................
 
  -- 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)
 
      It simply sends the data to the child in smaller pieces and waits
      for confirmation with a single 'C' character on the pipe from child
      to parent.
 
      'dpipe' is a parameter which contains the information necessary for
      communicating through pipes between the parent and the child and
      vice-versa.
 
           typedef struct{
               int pc[2];            /* Parent to child pipe */
               int cp[2];            /* Child to parent pipe */
           }TModuleDoublePipe;
 
      'message' is a pointer to a NULL-terminated string containing the
      message for synthesis.
 
      'msgtype' is the type of the message for synthesis.
 
      'maxlen' is the maximum number of bytes that should be transfered
      over the pipe.
 
      'dividers' is a NULL-terminated string containing the punctuation
      characters at which this function should divide the message into
      smaller pieces.
 
      '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:
        1. Reads a part of the message or an index mark using
           'module_get_message_part()'.
        2. Looks if there isn't a pending request for pause and handles
           it.
        3. Sends the current part of the message to the child using
           'module_parent_dp_write()'.
        4. Waits until a single character 'C' comes from the other pipe
           using 'module_parent_dp_read()'.
        5. Repeats the cycle or terminates, if there is no more data.
 
  -- Module Utils function: int
           module_parent_wait_continue(TModuleDoublePipe dpipe)
      Waits until the character 'C' (continue) is read from the pipe from
      child.  This function is intended to be run from the parent.
 
      'dpipe' is the double pipe used for communication between the child
      and parent.
 
      Returns 0 if the character was read or 1 if the pipe was broken
      before the character could be read.
 
  -- Module Utils function: void module_parent_dp_init (TModuleDoublePipe
           dpipe)
      Initializes pipes (dpipe) in the parent.  Currently it only closes
      the unnecessary ends.
 
  -- Module Utils function: void module_child_dp_close (TModuleDoublePipe
           dpipe)
      Initializes pipes (dpipe) in the child.  Currently it only closes
      the unnecessary ends.
 
  -- Module Utils function: void module_child_dp_write(TModuleDoublePipe
           dpipe, const char *msg, size_t bytes)
      Writes the specified number of 'bytes' from 'msg' to the pipe to
      the parent.  This function is intended, as the prefix says, to be
      run from the child.  Uses the pipes defined in 'dpipe'.
 
  -- Module Utils function: void module_parent_dp_write(TModuleDoublePipe
           dpipe, const char *msg, size_t bytes)
      Writes the specified number of 'bytes' from 'msg' into the pipe to
      the child.  This function is intended, as the prefix says, to be
      run from the parent.  Uses the pipes defined in 'dpipe'.
 
  -- Module Utils function: int module_child_dp_read(TModuleDoublePipe
           dpipe char *msg, size_t maxlen)
      Reads up to 'maxlen' bytes from the pipe from parent into the
      buffer 'msg'.  This function is intended, as the prefix says, to be
      run from the child.  Uses the pipes defined in 'dpipe'.
 
  -- Module Utils function: int module_parent_dp_read(TModuleDoublePipe
           dpipe, char *msg, size_t maxlen)
      Reads up to 'maxlen' bytes from the pipe from child into the buffer
      'msg'.  This function is intended, as the prefix says, to be run
      from the parent.  Uses the pipes defined in 'dpipe'.
 
  -- Module Utils function: void module_sigblockall(void)
      Blocks all signals.  This is intended to be run from the child
      processes and threads so that their signal handling won't interfere
      with the parent.
 
  -- Module Utils function: void module_sigunblockusr(sigset_t
           *some_signals)
      Use the set 'some_signals' to unblock SIGUSR1.
 
  -- Module Utils function: void module_sigblockusr(sigset_t
           *some_signals)
      Use the set 'some_signals' to block SIGUSR1.