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.

451 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. enum JackSessionEvent {
  176. JackSessionSave = 1,
  177. JackSessionQuit = 2
  178. };
  179. typedef enum JackSessionEvent jack_session_event_t;
  180. /**
  181. * Prototype for the client supplied function that is called
  182. * by the engine anytime there is work to be done.
  183. *
  184. * @pre nframes == jack_get_buffer_size()
  185. * @pre nframes == pow(2,x)
  186. *
  187. * @param nframes number of frames to process
  188. * @param arg pointer to a client supplied data
  189. *
  190. * @return zero on success, non-zero on error
  191. */
  192. typedef int (*JackProcessCallback)(jack_nframes_t nframes, void *arg);
  193. /**
  194. * Prototype for the client supplied function that is called
  195. * once after the creation of the thread in which other
  196. * callbacks will be made. Special thread characteristics
  197. * can be set from this callback, for example. This is a
  198. * highly specialized callback and most clients will not
  199. * and should not use it.
  200. *
  201. * @param arg pointer to a client supplied structure
  202. *
  203. * @return void
  204. */
  205. typedef void (*JackThreadInitCallback)(void *arg);
  206. /**
  207. * Prototype for the client supplied function that is called
  208. * whenever the processing graph is reordered.
  209. *
  210. * @param arg pointer to a client supplied data
  211. *
  212. * @return zero on success, non-zero on error
  213. */
  214. typedef int (*JackGraphOrderCallback)(void *arg);
  215. /**
  216. * Prototype for the client-supplied function that is called whenever
  217. * an xrun has occured.
  218. *
  219. * @see jack_get_xrun_delayed_usecs()
  220. *
  221. * @param arg pointer to a client supplied data
  222. *
  223. * @return zero on success, non-zero on error
  224. */
  225. typedef int (*JackXRunCallback)(void *arg);
  226. /**
  227. * Prototype for the @a bufsize_callback that is invoked whenever the
  228. * JACK engine buffer size changes. Although this function is called
  229. * in the JACK process thread, the normal process cycle is suspended
  230. * during its operation, causing a gap in the audio flow. So, the @a
  231. * bufsize_callback can allocate storage, touch memory not previously
  232. * referenced, and perform other operations that are not realtime
  233. * safe.
  234. *
  235. * @param nframes buffer size
  236. * @param arg pointer supplied by jack_set_buffer_size_callback().
  237. *
  238. * @return zero on success, non-zero on error
  239. */
  240. typedef int (*JackBufferSizeCallback)(jack_nframes_t nframes, void *arg);
  241. /**
  242. * Prototype for the client supplied function that is called
  243. * when the engine sample rate changes.
  244. *
  245. * @param nframes new engine sample rate
  246. * @param arg pointer to a client supplied data
  247. *
  248. * @return zero on success, non-zero on error
  249. */
  250. typedef int (*JackSampleRateCallback)(jack_nframes_t nframes, void *arg);
  251. /**
  252. * Prototype for the client supplied function that is called
  253. * whenever a port is registered or unregistered.
  254. *
  255. * @param port the ID of the port
  256. * @param arg pointer to a client supplied data
  257. * @param register non-zero if the port is being registered,
  258. * zero if the port is being unregistered
  259. */
  260. typedef void (*JackPortRegistrationCallback)(jack_port_id_t port, int register, void *arg);
  261. /**
  262. * Prototype for the client supplied function that is called
  263. * whenever a client is registered or unregistered.
  264. *
  265. * @param name a null-terminated string containing the client name
  266. * @param register non-zero if the client is being registered,
  267. * zero if the client is being unregistered
  268. * @param arg pointer to a client supplied data
  269. */
  270. typedef void (*JackClientRegistrationCallback)(const char* name, int register, void *arg);
  271. /**
  272. * Prototype for the client supplied function that is called
  273. * whenever a client is registered or unregistered.
  274. *
  275. * @param a one of two ports connected or disconnected
  276. * @param b one of two ports connected or disconnected
  277. * @param connect non-zero if ports were connected
  278. * zero if ports were disconnected
  279. * @param arg pointer to a client supplied data
  280. */
  281. typedef void (*JackPortConnectCallback)(jack_port_id_t a, jack_port_id_t b, int connect, void* arg);
  282. /**
  283. * Prototype for the client supplied function that is called
  284. * whenever jackd starts or stops freewheeling.
  285. *
  286. * @param starting non-zero if we start starting to freewheel, zero otherwise
  287. * @param arg pointer to a client supplied structure
  288. */
  289. typedef void (*JackFreewheelCallback)(int starting, void *arg);
  290. typedef void *(*JackThreadCallback)(void* arg);
  291. /**
  292. * Prototype for the client supplied function that is called
  293. * whenever jackd is shutdown. Note that after server shutdown,
  294. * the client pointer is *not* deallocated by libjack,
  295. * the application is responsible to properly use jack_client_close()
  296. * to release client ressources. Warning: jack_client_close() cannot be
  297. * safely used inside the shutdown callback and has to be called outside of
  298. * the callback context.
  299. *
  300. * @param arg pointer to a client supplied structure
  301. */
  302. typedef void (*JackShutdownCallback)(void *arg);
  303. /**
  304. * Prototype for the client supplied function that is called
  305. * whenever jackd is shutdown. Note that after server shutdown,
  306. * the client pointer is *not* deallocated by libjack,
  307. * the application is responsible to properly use jack_client_close()
  308. * to release client ressources. Warning: jack_client_close() cannot be
  309. * safely used inside the shutdown callback and has to be called outside of
  310. * the callback context.
  311. * @param code a shuntdown code
  312. * @param reason a string discribing the shuntdown 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. typedef char *(*JackSessionCallback)(jack_session_event_t code, const char* session_dir, const char* prefix, void *arg);
  317. /**
  318. * Used for the type argument of jack_port_register() for default
  319. * audio and midi ports.
  320. */
  321. #define JACK_DEFAULT_AUDIO_TYPE "32 bit float mono audio"
  322. #define JACK_DEFAULT_MIDI_TYPE "8 bit raw midi"
  323. /**
  324. * For convenience, use this typedef if you want to be able to change
  325. * between float and double. You may want to typedef sample_t to
  326. * jack_default_audio_sample_t in your application.
  327. */
  328. typedef float jack_default_audio_sample_t;
  329. /**
  330. * A port has a set of flags that are formed by AND-ing together the
  331. * desired values from the list below. The flags "JackPortIsInput" and
  332. * "JackPortIsOutput" are mutually exclusive and it is an error to use
  333. * them both.
  334. */
  335. enum JackPortFlags {
  336. /**
  337. * if JackPortIsInput is set, then the port can receive
  338. * data.
  339. */
  340. JackPortIsInput = 0x1,
  341. /**
  342. * if JackPortIsOutput is set, then data can be read from
  343. * the port.
  344. */
  345. JackPortIsOutput = 0x2,
  346. /**
  347. * if JackPortIsPhysical is set, then the port corresponds
  348. * to some kind of physical I/O connector.
  349. */
  350. JackPortIsPhysical = 0x4,
  351. /**
  352. * if JackPortCanMonitor is set, then a call to
  353. * jack_port_request_monitor() makes sense.
  354. *
  355. * Precisely what this means is dependent on the client. A typical
  356. * result of it being called with TRUE as the second argument is
  357. * that data that would be available from an output port (with
  358. * JackPortIsPhysical set) is sent to a physical output connector
  359. * as well, so that it can be heard/seen/whatever.
  360. *
  361. * Clients that do not control physical interfaces
  362. * should never create ports with this bit set.
  363. */
  364. JackPortCanMonitor = 0x8,
  365. /**
  366. * JackPortIsTerminal means:
  367. *
  368. * for an input port: the data received by the port
  369. * will not be passed on or made
  370. * available at any other port
  371. *
  372. * for an output port: the data available at the port
  373. * does not originate from any other port
  374. *
  375. * Audio synthesizers, I/O hardware interface clients, HDR
  376. * systems are examples of clients that would set this flag for
  377. * their ports.
  378. */
  379. JackPortIsTerminal = 0x10
  380. };
  381. #endif /* __jack_types_h__ */