jack1 codebase
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.

313 lines
9.2KB

  1. /*
  2. Copyright (C) 2001 Paul Davis
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU Lesser General Public License as published by
  5. the Free Software Foundation; either version 2.1 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. $Id$
  15. */
  16. #ifndef __jack_types_h__
  17. #define __jack_types_h__
  18. #include <inttypes.h>
  19. typedef char shm_name_t[32];
  20. typedef int32_t jack_shmsize_t;
  21. /**
  22. * Type used to represent sample frame counts.
  23. */
  24. typedef uint32_t jack_nframes_t;
  25. /**
  26. * Maximum value that can be stored in jack_nframes_t
  27. */
  28. #define JACK_MAX_FRAMES (4294967295U) /* This should be UINT32_MAX, but
  29. C++ has a problem with that. */
  30. /**
  31. * Type used to represent the value of free running
  32. * monotonic clock with units of microseconds.
  33. */
  34. typedef uint64_t jack_time_t;
  35. /**
  36. * jack_port_t is an opaque type. You may only access it using the
  37. * API provided.
  38. */
  39. typedef struct _jack_port jack_port_t;
  40. /**
  41. * jack_client_t is an opaque type. You may only access it using the
  42. * API provided.
  43. */
  44. typedef struct _jack_client jack_client_t;
  45. /**
  46. * Ports have unique ids. A port registration callback is the only
  47. * place you ever need to know their value.
  48. */
  49. typedef uint32_t jack_port_id_t;
  50. /**
  51. * Prototype for the client supplied function that is called
  52. * by the engine anytime there is work to be done.
  53. *
  54. * @pre nframes == jack_get_buffer_size()
  55. * @pre nframes == pow(2,x)
  56. *
  57. * @param nframes number of frames to process
  58. * @param arg pointer to a client supplied structure
  59. *
  60. * @return zero on success, non-zero on error
  61. */
  62. typedef int (*JackProcessCallback)(jack_nframes_t nframes, void *arg);
  63. /**
  64. * Prototype for the client supplied function that is called
  65. * once after the creation of the thread in which other
  66. * callbacks will be made. Special thread characteristics
  67. * can be set from this callback, for example. This is a
  68. * highly specialized callback and most clients will not
  69. * and should not use it.
  70. *
  71. * @param arg pointer to a client supplied structure
  72. *
  73. * @return void
  74. */
  75. typedef void (*JackThreadInitCallback)(void *arg);
  76. /**
  77. * Prototype for the client supplied function that is called
  78. * whenever the processing graph is reordered.
  79. *
  80. * @param arg pointer to a client supplied structure
  81. *
  82. * @return zero on success, non-zero on error
  83. */
  84. typedef int (*JackGraphOrderCallback)(void *arg);
  85. /**
  86. * Prototype for the client-supplied function that is called whenever
  87. * an xrun has occured.
  88. *
  89. * @see jack_get_xrun_delayed_usecs()
  90. *
  91. * @param arg pointer to a client supplied structure
  92. *
  93. * @return zero on success, non-zero on error
  94. */
  95. typedef int (*JackXRunCallback)(void *arg);
  96. /**
  97. * Prototype for the @a bufsize_callback that is invoked whenever the
  98. * JACK engine buffer size changes. Although this function is called
  99. * in the JACK process thread, the normal process cycle is suspended
  100. * during its operation, causing a gap in the audio flow. So, the @a
  101. * bufsize_callback can allocate storage, touch memory not previously
  102. * referenced, and perform other operations that are not realtime
  103. * safe.
  104. *
  105. * @param nframes buffer size
  106. * @param arg pointer supplied by jack_set_buffer_size_callback().
  107. *
  108. * @return zero on success, non-zero on error
  109. */
  110. typedef int (*JackBufferSizeCallback)(jack_nframes_t nframes, void *arg);
  111. /**
  112. * Prototype for the client supplied function that is called
  113. * when the engine sample rate changes.
  114. *
  115. * @param nframes new engine sample rate
  116. * @param arg pointer to a client supplied structure
  117. *
  118. * @return zero on success, non-zero on error
  119. */
  120. typedef int (*JackSampleRateCallback)(jack_nframes_t nframes, void *arg);
  121. /**
  122. * Prototype for the client supplied function that is called
  123. * whenever a port is registered or unregistered.
  124. *
  125. * @param arg pointer to a client supplied structure
  126. */
  127. typedef void (*JackPortRegistrationCallback)(jack_port_id_t port, int, void *arg);
  128. /**
  129. * Prototype for the client supplied function that is called
  130. * whenever jackd starts or stops freewheeling.
  131. *
  132. * @param starting non-zero if we start starting to freewheel, zero otherwise
  133. * @param arg pointer to a client supplied structure
  134. */
  135. typedef void (*JackFreewheelCallback)(int starting, void *arg);
  136. /**
  137. * Used for the type argument of jack_port_register() for default
  138. * audio ports.
  139. */
  140. #define JACK_DEFAULT_AUDIO_TYPE "32 bit float mono audio"
  141. /**
  142. * For convenience, use this typedef if you want to be able to change
  143. * between float and double. You may want to typedef sample_t to
  144. * jack_default_audio_sample_t in your application.
  145. */
  146. typedef float jack_default_audio_sample_t;
  147. /**
  148. * A port has a set of flags that are formed by AND-ing together the
  149. * desired values from the list below. The flags "JackPortIsInput" and
  150. * "JackPortIsOutput" are mutually exclusive and it is an error to use
  151. * them both.
  152. */
  153. enum JackPortFlags {
  154. /**
  155. * if JackPortIsInput is set, then the port can receive
  156. * data.
  157. */
  158. JackPortIsInput = 0x1,
  159. /**
  160. * if JackPortIsOutput is set, then data can be read from
  161. * the port.
  162. */
  163. JackPortIsOutput = 0x2,
  164. /**
  165. * if JackPortIsPhysical is set, then the port corresponds
  166. * to some kind of physical I/O connector.
  167. */
  168. JackPortIsPhysical = 0x4,
  169. /**
  170. * if JackPortCanMonitor is set, then a call to
  171. * jack_port_request_monitor() makes sense.
  172. *
  173. * Precisely what this means is dependent on the client. A typical
  174. * result of it being called with TRUE as the second argument is
  175. * that data that would be available from an output port (with
  176. * JackPortIsPhysical set) is sent to a physical output connector
  177. * as well, so that it can be heard/seen/whatever.
  178. *
  179. * Clients that do not control physical interfaces
  180. * should never create ports with this bit set.
  181. */
  182. JackPortCanMonitor = 0x8,
  183. /**
  184. * JackPortIsTerminal means:
  185. *
  186. * for an input port: the data received by the port
  187. * will not be passed on or made
  188. * available at any other port
  189. *
  190. * for an output port: the data available at the port
  191. * does not originate from any other port
  192. *
  193. * Audio synthesizers, I/O hardware interface clients, HDR
  194. * systems are examples of clients that would set this flag for
  195. * their ports.
  196. */
  197. JackPortIsTerminal = 0x10
  198. };
  199. /**
  200. * jack_client_open() option bits
  201. */
  202. enum JackOpenOptions {
  203. /**
  204. * Null value to use when no option bits are needed.
  205. */
  206. JackNullOption = 0x00,
  207. /**
  208. * Do not automatically start the JACK server when it is not
  209. * already running. This option is always selected if
  210. * \$JACK_NO_START_SERVER is defined in the calling process
  211. * environment.
  212. */
  213. JackNoStartServer = 0x01,
  214. /**
  215. * Use the exact client name requested. Otherwise, JACK
  216. * automatically generates a unique one, if needed.
  217. */
  218. JackUseExactName = 0x02,
  219. /**
  220. * Open with optional @a char @a *server_name parameter.
  221. *
  222. * @warning This option has not yet been implemented.
  223. */
  224. JackServerName = 0x04
  225. };
  226. /* options mask does not include unimplemented features */
  227. #define JackValidOptions (JackNoStartServer|JackUseExactName)
  228. /**
  229. * jack_client_open() request options are formed by AND-ing together
  230. * @ref JackOpenOptions bits.
  231. */
  232. typedef enum JackOpenOptions jack_options_t;
  233. /**
  234. * jack_client_open() status bits
  235. */
  236. enum JackOpenStatus {
  237. /**
  238. * The open request failed because it contained an invalid or
  239. * unsupported option.
  240. */
  241. JackInvalidOption = 0x01,
  242. /**
  243. * The desired client name was not unique. With the @ref
  244. * JackUseExactName option this situation is fatal. Otherwise,
  245. * the name was modified by appending a dash and a two-digit
  246. * number in the range "-01" to "-99". The
  247. * jack_get_client_name() function will return the exact string
  248. * that was used. If the specified @a client_name plus these
  249. * extra characters would be too long, the open fails instead.
  250. */
  251. JackNameNotUnique = 0x02,
  252. /**
  253. * The JACK server was started as a result of this open.
  254. * Otherwise, it was running already. In either case the caller
  255. * is now connected to jackd, so there is no race condition.
  256. * When the server shuts down, the client will find out.
  257. */
  258. JackServerStarted = 0x04,
  259. /**
  260. * Unable to connect to the JACK server, open failed.
  261. */
  262. JackServerFailed = 0x08
  263. };
  264. /**
  265. * The status word returned from jack_client_open() is formed by
  266. * AND-ing together the relevant @ref JackOpenStatus bits.
  267. */
  268. typedef enum JackOpenStatus jack_status_t;
  269. #endif /* __jack_types_h__ */