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.

365 lines
10KB

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