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.

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