Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

module.c File Reference

Main loop for module mode (server mode). More...

#include <julius.h>
#include <stdarg.h>

Include dependency graph for module.c:

Go to the source code of this file.

Defines

#define MAXBUFLEN   4096
 Maximum line length of a message sent from a client.

Enumerations

enum  { SM_TERMINATE, SM_PAUSE, SM_WAIT }
 Switch to specify the grammar changing timing policy.

Functions

void main_module_loop ()
 Application main loop for module mode.
boolean module_disconnect ()
boolean module_is_connected ()
static boolean msock_read_grammar (DFA_INFO **ret_dfa, WORD_INFO **ret_winfo)
 Read a recognition grammar from current module client.
static void set_grammar_switch_timing_flag ()
 Set flags to update global grammar.
void msock_exec_command (char *command)
 Process a module command.
boolean module_is_active ()
 Return the process activity status.
boolean module_wants_terminate ()
 Return whether we currently has a request of immediate termination.
void module_reset_reload ()
void msock_process_command ()
void msock_check_and_process_command ()
int msock_check_in_adin ()
 callback function to process module command while input detection.

Variables

static int listen_sd = -1
 Socket to listen to a client.
static char mbuf [MAXBUFLEN]
 Work buffer for message output.
static boolean process_active = TRUE
static boolean process_want_terminate = FALSE
static boolean process_want_reload = FALSE
static short gram_switch_input_method = SM_PAUSE
 Specify when to refresh the global lexicon while recognition.


Detailed Description

Main loop for module mode (server mode).

Author:
Akinobu Lee
Date:
Mon May 30 15:59:54 2005
Revision
1.3

Definition in file module.c.


Function Documentation

void main_module_loop  ) 
 

Application main loop for module mode.

This function wait for a connection request from a client process, and when connected, it calls the recognition main loop for that. The established socket descriptor will be stored in the global variable "module_sd". In Win32, this process will not fork by the connection acceptance.

Definition at line 89 of file module.c.

Referenced by main().

boolean module_disconnect  ) 
 

Disconnect the current client.

Returns:
TRUE on success, or FALSE on failure.

Definition at line 152 of file module.c.

Referenced by m_errexit(), and m_exit().

boolean module_is_connected  ) 
 

Return whether a client process has been connected.

Returns:
TRUE if currently connected, or FALSE if not.

Definition at line 172 of file module.c.

Referenced by m_errexit(), and m_exit().

static boolean msock_read_grammar DFA_INFO **  ret_dfa,
WORD_INFO **  ret_winfo
[static]
 

Read a recognition grammar from current module client.

The syntax file (.dfa) and vicabulary file (.dict) from the module client will be received in this function. The end markers that specify the end of the files are lines with only "DFAEND" and "DICEND". The received data are stored to the memory area newly allocated within this function.

The received grammar will be incorporated into the global grammar when the next updating chance has come.

Parameters:
ret_dfa [out] pointer to the newly received DFA data.
ret_winfo [out] pointer to the newly received dict data.
Returns:
TRUE if successfully read with no error, or FALSE if error exists.

Definition at line 219 of file module.c.

static void set_grammar_switch_timing_flag  )  [static]
 

Set flags to update global grammar.

This function sets flags to make engine update the global grammar at the next updating chance, according to the configuration variable in gram_switch_input_method.

Definition at line 269 of file module.c.

void msock_exec_command char *  command  ) 
 

Process a module command.

This function processes command string received from module client. This will be called whenever a command arrives from a client, interrupting the main recognition process. The status responses will be performed at this function immediately. On the whole, grammar modification (add/delete/(de)activation) will not be performed here. The received data are just stored in this function, and they will be processed later by calling multigram_exec() between the recognition process.

Parameters:
command [in] command string

Definition at line 326 of file module.c.

Referenced by main_recognition_loop().

boolean module_is_active  ) 
 

Return the process activity status.

If TRUE, the process is currently activated, either monitoring an audio input or recognizing the current input. If FALSE, recognition is currently disabled, ignoring all the speech inputs.

Returns:
TRUE if process is currently activated, or FALSE if not.

Definition at line 563 of file module.c.

Referenced by adin_cut_callback_store_buffer(), and main_recognition_loop().

boolean module_wants_terminate  ) 
 

Return whether we currently has a request of immediate termination.

This function returns whether we now has an order for immediate termination. This status will be set by receiving "TERMINATE" command from module client, or when a grammar has been received with immediate update option. This function is typically called from several recognition functions and ad-in processing function to check if we should stop the current recognition process immediately.

Returns:
TRUE if we have a request of immediate termination, or FALSE if not.

Definition at line 592 of file module.c.

Referenced by adin_cut_callback_store_buffer(), get_back_trellis(), main_recognition_loop(), and wchmm_fbs().

void module_reset_reload  ) 
 

Clear the process_want_reload flag.

Definition at line 608 of file module.c.

Referenced by main_recognition_loop().

void msock_process_command  ) 
 

Process one commands from client module. If no command is in the buffer, it will block until next command comes.

Definition at line 626 of file module.c.

Referenced by main_recognition_loop().

void msock_check_and_process_command  ) 
 

Process one commands from client module. If no command is in the buffer, it will return without blocking.

Definition at line 652 of file module.c.

Referenced by adin_cut_callback_store_buffer(), and main_recognition_loop().

int msock_check_in_adin  ) 
 

callback function to process module command while input detection.

This function will be called periodically from A/D-in function to check and process commands from module client. If some commands are found, it will be processed here. Also, if some termination or stop of recognition process is requested, this function returns to the caller as so.

Returns:
0 normally, -2 when there is immediate termination request, and -1 if there is recognition stop command.

Definition at line 707 of file module.c.

Referenced by main_recognition_loop().


Variable Documentation

boolean process_active = TRUE [static]
 

Status flag indicating whether the recognition is alive or not. If TRUE, the process is currently activated, either monitoring an audio input or recognizing the current input. If FALSE, the recognition is now disabled until some activation command has been arrived from client. While disabled, all the inputs are ignored.

If set to FALSE in the program, Julius/Julian will stop after the current recognition ends, and enter the disabled status.

Definition at line 43 of file module.c.

boolean process_want_terminate = FALSE [static]
 

If set to TRUE, Julius/Julian stops recognition immediately, terminating the currenct recognition process, and enter into disabled status.

Definition at line 50 of file module.c.

boolean process_want_reload = FALSE [static]
 

If set to TRUE, Julius/Julian stops recognition softly. If it is performing recognition of the 1st pass, it immediately segments the current input, process the 2nd pass, and output the result. Then it enters the disabled status.

Definition at line 59 of file module.c.


Generated on Tue Mar 28 16:18:01 2006 for Julius by  doxygen 1.4.2