speech-dispatcher: Server Core

 
 5.1 Server Core
 ===============
 
 The main documentation for the server core is the code itself.  This
 section is only a general introduction intended to give you some basic
 information and hints where to look for things.  If you are going to
 make some modifications in the server core, we will be happy if you get
 in touch with us on <speechd-discuss@nongnu.org>.
 
    The server core is composed of two main parts, each of them
 implemented in a separate thread.  The _server part_ handles the
 communication with clients and, with the desired configuration options,
 stores the messages in the priority queue.  The _speaking part_ takes
 care of communicating with the output modules, pulls messages out of the
 priority queue at the correct time and sends them to the appropriate
 synthesizer.
 
    Synchronization between these two parts is done by thread mutexes.
 Additionally, synchronization of the speaking part from both sides
 (server part, output modules) is done via a SYSV/IPC semaphore.
 
 Server part
 -----------
 
 After switching to the daemon mode (if required), it reads configuration
 files and initializes the speaking part.  Then it opens the socket and
 waits for incoming data.  This is implemented mainly in
 'src/server/speechd.c' and 'src/server/server.c'.
 
    There are three types of events: new client connects to speechd, old
 client disconnects, or a client sends some data.  In the third case, the
 data is passed to the 'parse()' function defined in
 'src/server/parse.c'.
 
    If the incoming data is a new message, it's stored in a queue
 according to its priority.  If it is SSIP commands, it's handled by the
 appropriate handlers.  Handling of the 'SET' family of commands can be
 found in 'src/server/set.c' and 'HISTORY' commands are processed in
 'src/server/history.c'.
 
    All reply messages of SSIP are defined in 'src/server/msg.h'.
 
 Speaking part
 -------------
 
 This thread, the function 'speak()' defined in 'src/server/speaking.c',
 is created from the server part process shortly after initialization.
 Then it enters an infinite loop and waits on a SYSV/IPC semaphore until
 one of the following actions happen:
 
    * The server adds a new message to the queue of messages waiting to
      be said.
    * The currently active output module signals that the message that
      was being spoken is done.
    * Pause or resume is requested.
 
    After handling the rest of the priority interaction (like actions
 needed to repeat the last priority progress message) it decides which
 action should be performed.  Usually it's picking up a message from the
 queue and sending it to the desired output module (synthesizer), but
 sometimes it's handling the pause or resume requests, and sometimes it's
 doing nothing.
 
    As said before, this is the part of Speech Dispatcher that talks to
 the output modules.  It does so by using the output interface defined in
 'src/server/output.c'.