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.

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