You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

276 lines
10 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: pantheios/backends/bec.speech.h
  3. *
  4. * Purpose: Declaration of the Pantheios speech Stock Back-end API.
  5. *
  6. * Created: 10th July 2006
  7. * Updated: 30th April 2010
  8. *
  9. * Home: http://www.pantheios.org/
  10. *
  11. * Copyright (c) 2006-2010, Matthew Wilson and Synesis Software
  12. * All rights reserved.
  13. *
  14. * Redistribution and use in source and binary forms, with or without
  15. * modification, are permitted provided that the following conditions are
  16. * met:
  17. *
  18. * - Redistributions of source code must retain the above copyright notice,
  19. * this list of conditions and the following disclaimer.
  20. * - Redistributions in binary form must reproduce the above copyright
  21. * notice, this list of conditions and the following disclaimer in the
  22. * documentation and/or other materials provided with the distribution.
  23. * - Neither the name(s) of Matthew Wilson and Synesis Software nor the
  24. * names of any contributors may be used to endorse or promote products
  25. * derived from this software without specific prior written permission.
  26. *
  27. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
  28. * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  29. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  30. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  31. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  32. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  33. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  34. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  35. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  36. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  37. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  38. *
  39. * ////////////////////////////////////////////////////////////////////// */
  40. /** \file pantheios/backends/bec.speech.h
  41. *
  42. * [C, C++] Pantheios speech Back-end Common API
  43. */
  44. #ifndef PANTHEIOS_INCL_PANTHEIOS_BACKENDS_H_BEC_SPEECH
  45. #define PANTHEIOS_INCL_PANTHEIOS_BACKENDS_H_BEC_SPEECH
  46. /* /////////////////////////////////////////////////////////////////////////
  47. * Version information
  48. */
  49. #ifndef PANTHEIOS_DOCUMENTATION_SKIP_SECTION
  50. # define PANTHEIOS_VER_PANTHEIOS_BACKENDS_H_BEC_SPEECH_MAJOR 3
  51. # define PANTHEIOS_VER_PANTHEIOS_BACKENDS_H_BEC_SPEECH_MINOR 1
  52. # define PANTHEIOS_VER_PANTHEIOS_BACKENDS_H_BEC_SPEECH_REVISION 1
  53. # define PANTHEIOS_VER_PANTHEIOS_BACKENDS_H_BEC_SPEECH_EDIT 19
  54. #endif /* !PANTHEIOS_DOCUMENTATION_SKIP_SECTION */
  55. /* /////////////////////////////////////////////////////////////////////////
  56. * Includes
  57. */
  58. #ifndef PANTHEIOS_INCL_PANTHEIOS_H_PANTHEIOS
  59. # include <pantheios/pantheios.h>
  60. #endif /* !PANTHEIOS_INCL_PANTHEIOS_H_PANTHEIOS */
  61. #ifndef PANTHEIOS_INCL_PANTHEIOS_H_BACKEND
  62. # include <pantheios/backend.h>
  63. #endif /* !PANTHEIOS_INCL_PANTHEIOS_H_BACKEND */
  64. /* /////////////////////////////////////////////////////////////////////////
  65. * Documentation
  66. */
  67. /** \defgroup group__backend__stock_backends__speech Pantheios speech Stock Back-end
  68. * \ingroup group__backend__stock_backends
  69. * Back-end library that outputs as speech.
  70. */
  71. /* /////////////////////////////////////////////////////////////////////////
  72. * Constants
  73. */
  74. /** \defgroup group__backend__stock_backends__speech__flags Pantheios speech Stock Back-end Flags
  75. * \ingroup group__backend__stock_backends__speech
  76. * Flags for the \ref group__backend__stock_backends__speech
  77. */
  78. /** \def PANTHEIOS_BE_SPEECH_F_SYNCHRONOUS
  79. * Causes the \ref group__backend__stock_backends__speech to
  80. * log speech synchronously. By default, speech output is
  81. * asynchronous.
  82. * \ingroup group__backend__stock_backends__speech__flags
  83. */
  84. /** \def PANTHEIOS_BE_SPEECH_F_PURGE_BEFORE_SPEAK
  85. * Causes any log statements cached in the
  86. * \ref group__backend__stock_backends__speech prior to purge any
  87. * outstanding speach requests before attempting to emit the current
  88. * statement.
  89. * \ingroup group__backend__stock_backends__speech__flags
  90. */
  91. /** \def PANTHEIOS_BE_SPEECH_F_SPEAK_PUNCTUATION
  92. * Causes the \ref group__backend__stock_backends__speech to
  93. * speak punctuation.
  94. * \ingroup group__backend__stock_backends__speech__flags
  95. */
  96. /** \def PANTHEIOS_BE_SPEECH_F_SYNCHRONOUS_ON_CRITICAL
  97. * Causes the \ref group__backend__stock_backends__speech to
  98. * output speech synchronously and to purge any previous outstanding
  99. * speach requests if the severity level is pantheios::SEV_CRITICAL,
  100. * pantheios::SEV_ALERT, or pantheios::SEV_EMERGENCY.
  101. * \ingroup group__backend__stock_backends__speech__flags
  102. */
  103. /** \def PANTHEIOS_BE_SPEECH_F_UNINIT_DISCARD_WORKAROUND
  104. * Causes the \ref group__backend__stock_backends__speech to
  105. * discard the speech object reference, without waiting until done,
  106. * at uninitialisation time. This is to workaround what appears to
  107. * be a defect with SAPI, whereby the SAPI DLL is unloaded during
  108. * application shutdown before all speech object references are
  109. * released.
  110. * \ingroup group__backend__stock_backends__speech__flags
  111. */
  112. #define PANTHEIOS_BE_SPEECH_F_SYNCHRONOUS (0x00100000)
  113. #define PANTHEIOS_BE_SPEECH_F_PURGE_BEFORE_SPEAK (0x00200000)
  114. #define PANTHEIOS_BE_SPEECH_F_SPEAK_PUNCTUATION (0x00400000)
  115. #define PANTHEIOS_BE_SPEECH_F_SYNCHRONOUS_ON_CRITICAL (0x00800000)
  116. #define PANTHEIOS_BE_SPEECH_F_UNINIT_DISCARD_WORKAROUND (0x01000000)
  117. /* /////////////////////////////////////////////////////////////////////////
  118. * Typedefs
  119. */
  120. /** Structure used for specifying initialisation information to the
  121. * be.speech library.
  122. * \ingroup group__backend__stock_backends__speech
  123. */
  124. struct pan_be_speech_init_t
  125. {
  126. #if !defined(PANTHEIOS_DOCUMENTATION_SKIP_SECTION) && \
  127. !defined(PANTHEIOS_NO_NAMESPACE)
  128. typedef pantheios::pan_uint16_t pan_uint16_t;
  129. typedef pantheios::pan_uint32_t pan_uint32_t;
  130. #endif /* !PANTHEIOS_DOCUMENTATION_SKIP_SECTION && !PANTHEIOS_NO_NAMESPACE */
  131. pan_uint32_t version; /*!< Must be initialised to the value of PANTHEIOS_VER */
  132. pan_uint32_t flags; /*!< \ref group__backend__stock_backends__speech__flags "Flags" that control the information displayed. */
  133. #ifdef __cplusplus
  134. public: /* Construction */
  135. # ifndef PANTHEIOS_BE_INIT_NO_CPP_STRUCT_INIT
  136. pan_be_speech_init_t();
  137. # endif /* !PANTHEIOS_BE_INIT_NO_CPP_STRUCT_INIT */
  138. #endif /* __cplusplus */
  139. };
  140. #ifndef __cplusplus
  141. typedef struct pan_be_speech_init_t pan_be_speech_init_t;
  142. #endif /* !__cplusplus */
  143. /* /////////////////////////////////////////////////////////////////////////
  144. * Application-defined functions
  145. */
  146. /** Fills out a copy of the initialisation structure with default
  147. * values (representative of the default behaviour of the library),
  148. * ready to be customised and passed to the API initialiser function
  149. * pantheios_be_speech_init().
  150. */
  151. PANTHEIOS_CALL(void) pantheios_be_speech_getDefaultAppInit(
  152. pan_be_speech_init_t* init
  153. ) /* throw() */;
  154. /** \ref page__backend__callbacks "Callback" function defined by
  155. * the application, invoked when the
  156. * API is initialised with a NULL <code>init</code> parameter.
  157. * \ingroup group__backend__stock_backends__speech
  158. *
  159. * \param backEndId The back-end identifier passed to the back-end
  160. * during its initialisation.
  161. * \param init A pointer to an already-initialised instance of
  162. * pan_be_speech_init_t.
  163. *
  164. * If any application-specific changes are required they can be made to
  165. * the structure to which <code>init</code> points, which will already
  166. * have been initialised. These changes will then be incorporated into
  167. * the back-end state, and reflected in its behaviour.
  168. *
  169. * If no changes are required, then the function can be a simple stub,
  170. * containing no instructions.
  171. *
  172. * \note This function is only required when the
  173. * \ref page__backend__callbacks "callback" version of the library is
  174. * used.
  175. *
  176. * \exception "throw()" This function must <b>not</b> throw any exceptions!
  177. *
  178. * \warning This function will be called during the initialisation of
  179. * Pantheios, and so <b>must not</b> make any calls into Pantheios, either
  180. * directly or indirectly!
  181. */
  182. PANTHEIOS_CALL(void) pantheios_be_speech_getAppInit(
  183. int backEndId
  184. , pan_be_speech_init_t* init
  185. ) /* throw() */;
  186. /* /////////////////////////////////////////////////////////////////////////
  187. * API
  188. */
  189. /** Implements the functionality for pantheios_be_init() over the speech API.
  190. * \ingroup group__backend__stock_backends__speech
  191. */
  192. PANTHEIOS_CALL(int) pantheios_be_speech_init(
  193. PAN_CHAR_T const* processIdentity
  194. , int id
  195. , pan_be_speech_init_t const* init
  196. , void* reserved
  197. , void** ptoken
  198. );
  199. /** Implements the functionality for pantheios_be_uninit() over the speech API.
  200. * \ingroup group__backend__stock_backends__speech
  201. */
  202. PANTHEIOS_CALL(void) pantheios_be_speech_uninit(
  203. void* token
  204. );
  205. /** Implements the functionality for pantheios_be_logEntry() over the speech API.
  206. * \ingroup group__backend__stock_backends__speech
  207. */
  208. PANTHEIOS_CALL(int) pantheios_be_speech_logEntry(
  209. void* feToken
  210. , void* beToken
  211. , int severity
  212. , PAN_CHAR_T const* entry
  213. , size_t cchEntry
  214. );
  215. /** Parses the be.speech back-end flags
  216. *
  217. * \ingroup group__backend
  218. *
  219. *
  220. */
  221. PANTHEIOS_CALL(int) pantheios_be_speech_parseArgs(
  222. size_t numArgs
  223. #ifdef PANTHEIOS_NO_NAMESPACE
  224. , struct pan_slice_t* const args
  225. #else /* ? PANTHEIOS_NO_NAMESPACE */
  226. , pantheios::pan_slice_t* const args
  227. #endif /* PANTHEIOS_NO_NAMESPACE */
  228. , pan_be_speech_init_t* init
  229. );
  230. /* ////////////////////////////////////////////////////////////////////// */
  231. #ifdef __cplusplus
  232. # ifndef PANTHEIOS_BE_INIT_NO_CPP_STRUCT_INIT
  233. inline pan_be_speech_init_t::pan_be_speech_init_t()
  234. {
  235. pantheios_be_speech_getDefaultAppInit(this);
  236. }
  237. # endif /* !PANTHEIOS_BE_INIT_NO_CPP_STRUCT_INIT */
  238. #endif /* __cplusplus */
  239. /* ////////////////////////////////////////////////////////////////////// */
  240. #endif /* PANTHEIOS_INCL_PANTHEIOS_BACKENDS_H_BEC_SPEECH */
  241. /* ///////////////////////////// end of file //////////////////////////// */