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.

441 lines
13KB

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