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.

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