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.

401 lines
12KB

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