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.

500 lines
14KB

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