Anatomy of a module

While the internal implementation of the modules is quite different, they all share common features. Each type of module has an interface that defines how it interacts with io-asr:
Each interface includes some or all of the following members:

All modules provide an initialization function that io-asr invokes when the module is loaded. In addition to setting up module-specific data, the initialization function also loads the configuration tree and extracts the confidence threshold that's used to select speech-to-text results from the recognizer. The confidence threshold value is set globally per instance of the io-asr subsystem. This threshold is used frequently; saving it to memory speeds up access since the module won't have to walk the configuration tree each time the threshold is required.

Many of the callback functions in the module interfaces take private module-specific data as an argument (init(), destroy(), start(), stop()). This argument is a void pointer that's usually named module_data. ASR doesn't access this data, so its structure can be whatever is required by the individual module; two modules of the same type might use different module-specific data. This module-specific data structure can be passed to io-asr via the module's connect() function. ASR can then pass it as an argument to the module's callback functions.