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.

435 lines
12KB

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