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.

374 lines
11KB

  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 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. * Maximum size of @a load_init string passed to an internal client
  37. * jack_initialize() function via jack_internal_client_load().
  38. */
  39. #define JACK_LOAD_INIT_LIMIT 1024
  40. /**
  41. * jack_intclient_t is an opaque type representing a loaded internal
  42. * client. You may only access it using the API provided in @ref
  43. * intclient.h "<jack/intclient.h>".
  44. */
  45. typedef uint64_t jack_intclient_t;
  46. /**
  47. * jack_port_t is an opaque type. You may only access it using the
  48. * API provided.
  49. */
  50. typedef struct _jack_port jack_port_t;
  51. /**
  52. * jack_client_t is an opaque type. You may only access it using the
  53. * API provided.
  54. */
  55. typedef struct _jack_client jack_client_t;
  56. /**
  57. * Ports have unique ids. A port registration callback is the only
  58. * place you ever need to know their value.
  59. */
  60. typedef uint32_t jack_port_id_t;
  61. /**
  62. * Prototype for the client supplied function that is called
  63. * by the engine anytime there is work to be done.
  64. *
  65. * @pre nframes == jack_get_buffer_size()
  66. * @pre nframes == pow(2,x)
  67. *
  68. * @param nframes number of frames to process
  69. * @param arg pointer to a client supplied structure
  70. *
  71. * @return zero on success, non-zero on error
  72. */
  73. typedef int (*JackProcessCallback)(jack_nframes_t nframes, void *arg);
  74. /**
  75. * Prototype for the client supplied function that is called
  76. * once after the creation of the thread in which other
  77. * callbacks will be made. Special thread characteristics
  78. * can be set from this callback, for example. This is a
  79. * highly specialized callback and most clients will not
  80. * and should not use it.
  81. *
  82. * @param arg pointer to a client supplied structure
  83. *
  84. * @return void
  85. */
  86. typedef void (*JackThreadInitCallback)(void *arg);
  87. /**
  88. * Prototype for the client supplied function that is called
  89. * whenever the processing graph is reordered.
  90. *
  91. * @param arg pointer to a client supplied structure
  92. *
  93. * @return zero on success, non-zero on error
  94. */
  95. typedef int (*JackGraphOrderCallback)(void *arg);
  96. /**
  97. * Prototype for the client-supplied function that is called whenever
  98. * an xrun has occured.
  99. *
  100. * @see jack_get_xrun_delayed_usecs()
  101. *
  102. * @param arg pointer to a client supplied structure
  103. *
  104. * @return zero on success, non-zero on error
  105. */
  106. typedef int (*JackXRunCallback)(void *arg);
  107. /**
  108. * Prototype for the @a bufsize_callback that is invoked whenever the
  109. * JACK engine buffer size changes. Although this function is called
  110. * in the JACK process thread, the normal process cycle is suspended
  111. * during its operation, causing a gap in the audio flow. So, the @a
  112. * bufsize_callback can allocate storage, touch memory not previously
  113. * referenced, and perform other operations that are not realtime
  114. * safe.
  115. *
  116. * @param nframes buffer size
  117. * @param arg pointer supplied by jack_set_buffer_size_callback().
  118. *
  119. * @return zero on success, non-zero on error
  120. */
  121. typedef int (*JackBufferSizeCallback)(jack_nframes_t nframes, void *arg);
  122. /**
  123. * Prototype for the client supplied function that is called
  124. * when the engine sample rate changes.
  125. *
  126. * @param nframes new engine sample rate
  127. * @param arg pointer to a client supplied structure
  128. *
  129. * @return zero on success, non-zero on error
  130. */
  131. typedef int (*JackSampleRateCallback)(jack_nframes_t nframes, void *arg);
  132. /**
  133. * Prototype for the client supplied function that is called
  134. * whenever a port is registered or unregistered.
  135. *
  136. * @param arg pointer to a client supplied structure
  137. */
  138. typedef void (*JackPortRegistrationCallback)(jack_port_id_t port, int, void *arg);
  139. /**
  140. * Prototype for the client supplied function that is called
  141. * whenever jackd starts or stops freewheeling.
  142. *
  143. * @param starting non-zero if we start starting to freewheel, zero otherwise
  144. * @param arg pointer to a client supplied structure
  145. */
  146. typedef void (*JackFreewheelCallback)(int starting, void *arg);
  147. /**
  148. * Used for the type argument of jack_port_register() for default
  149. * audio and midi ports.
  150. */
  151. #define JACK_DEFAULT_AUDIO_TYPE "32 bit float mono audio"
  152. #define JACK_DEFAULT_MIDI_TYPE "8 bit raw midi"
  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. */
  234. JackServerName = 0x04,
  235. /**
  236. * Load internal client from optional <em>(char *)
  237. * load_name</em>. Otherwise use the @a client_name.
  238. */
  239. JackLoadName = 0x08,
  240. /**
  241. * Pass optional <em>(char *) load_init</em> string to the
  242. * jack_initialize() entry point of an internal client.
  243. */
  244. JackLoadInit = 0x10
  245. };
  246. /** Valid options for opening an external client. */
  247. #define JackOpenOptions (JackServerName|JackNoStartServer|JackUseExactName)
  248. /** Valid options for loading an internal client. */
  249. #define JackLoadOptions (JackLoadInit|JackLoadName|JackUseExactName)
  250. /**
  251. * Options for several JACK operations, formed by OR-ing together the
  252. * relevant @ref JackOptions bits.
  253. */
  254. typedef enum JackOptions jack_options_t;
  255. /**
  256. * @ref jack_status_t bits
  257. */
  258. enum JackStatus {
  259. /**
  260. * Overall operation failed.
  261. */
  262. JackFailure = 0x01,
  263. /**
  264. * The operation contained an invalid or unsupported option.
  265. */
  266. JackInvalidOption = 0x02,
  267. /**
  268. * The desired client name was not unique. With the @ref
  269. * JackUseExactName option this situation is fatal. Otherwise,
  270. * the name was modified by appending a dash and a two-digit
  271. * number in the range "-01" to "-99". The
  272. * jack_get_client_name() function will return the exact string
  273. * that was used. If the specified @a client_name plus these
  274. * extra characters would be too long, the open fails instead.
  275. */
  276. JackNameNotUnique = 0x04,
  277. /**
  278. * The JACK server was started as a result of this operation.
  279. * Otherwise, it was running already. In either case the caller
  280. * is now connected to jackd, so there is no race condition.
  281. * When the server shuts down, the client will find out.
  282. */
  283. JackServerStarted = 0x08,
  284. /**
  285. * Unable to connect to the JACK server.
  286. */
  287. JackServerFailed = 0x10,
  288. /**
  289. * Communication error with the JACK server.
  290. */
  291. JackServerError = 0x20,
  292. /**
  293. * Requested client does not exist.
  294. */
  295. JackNoSuchClient = 0x40,
  296. /**
  297. * Unable to load internal client
  298. */
  299. JackLoadFailure = 0x80,
  300. /**
  301. * Unable to initialize client
  302. */
  303. JackInitFailure = 0x100,
  304. /**
  305. * Unable to access shared memory
  306. */
  307. JackShmFailure = 0x200,
  308. /**
  309. * Client's protocol version does not match
  310. */
  311. JackVersionError = 0x400
  312. };
  313. /**
  314. * Status word returned from several JACK operations, formed by
  315. * OR-ing together the relevant @ref JackStatus bits.
  316. */
  317. typedef enum JackStatus jack_status_t;
  318. #endif /* __jack_types_h__ */