jack2 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.

403 lines
11KB

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