JACK API headers
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.

1331 lines
48KB

  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_h__
  17. #define __jack_h__
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. #include <jack/types.h>
  22. #include <jack/transport.h>
  23. /**
  24. * Note: More documentation can be found in jack/types.h.
  25. */
  26. /*************************************************************
  27. * NOTE: JACK_WEAK_EXPORT ***MUST*** be used on every function
  28. * added to the JACK API after the 0.116.2 release.
  29. *
  30. * Functions that predate this release are marked with
  31. * JACK_WEAK_OPTIONAL_EXPORT which can be defined at compile
  32. * time in a variety of ways. The default definition is empty,
  33. * so that these symbols get normal linkage. If you wish to
  34. * use all JACK symbols with weak linkage, include
  35. * <jack/weakjack.h> before jack.h.
  36. *************************************************************/
  37. #include <jack/weakmacros.h>
  38. /**
  39. * @defgroup ClientFunctions Creating & manipulating clients
  40. * @{
  41. */
  42. /**
  43. * Open an external client session with a JACK server. This interface
  44. * is more complex but more powerful than jack_client_new(). With it,
  45. * clients may choose which of several servers to connect, and control
  46. * whether and how to start the server automatically, if it was not
  47. * already running. There is also an option for JACK to generate a
  48. * unique client name, when necessary.
  49. *
  50. * @param client_name of at most jack_client_name_size() characters.
  51. * The name scope is local to each server. Unless forbidden by the
  52. * @ref JackUseExactName option, the server will modify this name to
  53. * create a unique variant, if needed.
  54. *
  55. * @param options formed by OR-ing together @ref JackOptions bits.
  56. * Only the @ref JackOpenOptions bits are allowed.
  57. *
  58. * @param status (if non-NULL) an address for JACK to return
  59. * information from the open operation. This status word is formed by
  60. * OR-ing together the relevant @ref JackStatus bits.
  61. *
  62. *
  63. * <b>Optional parameters:</b> depending on corresponding [@a options
  64. * bits] additional parameters may follow @a status (in this order).
  65. *
  66. * @arg [@ref JackServerName] <em>(char *) server_name</em> selects
  67. * from among several possible concurrent server instances. Server
  68. * names are unique to each user. If unspecified, use "default"
  69. * unless \$JACK_DEFAULT_SERVER is defined in the process environment.
  70. *
  71. * @return Opaque client handle if successful. If this is NULL, the
  72. * open operation failed, @a *status includes @ref JackFailure and the
  73. * caller is not a JACK client.
  74. */
  75. jack_client_t *jack_client_open (const char *client_name,
  76. jack_options_t options,
  77. jack_status_t *status, ...) JACK_OPTIONAL_WEAK_EXPORT;
  78. /**
  79. * <b>THIS FUNCTION IS DEPRECATED AND SHOULD NOT BE USED IN
  80. * NEW JACK CLIENTS</b>
  81. *
  82. */
  83. jack_client_t *jack_client_new (const char *client_name) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
  84. /**
  85. * Disconnects an external client from a JACK server.
  86. *
  87. * @return 0 on success, otherwise a non-zero error code
  88. */
  89. int jack_client_close (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT;
  90. /**
  91. * @return the maximum number of characters in a JACK client name
  92. * including the final NULL character. This value is a constant.
  93. */
  94. int jack_client_name_size (void) JACK_OPTIONAL_WEAK_EXPORT;
  95. /**
  96. * @return pointer to actual client name. This is useful when @ref
  97. * JackUseExactName is not specified on open and @ref
  98. * JackNameNotUnique status was returned. In that case, the actual
  99. * name will differ from the @a client_name requested.
  100. */
  101. char *jack_get_client_name (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT;
  102. /**
  103. * @return pointer to a string representation of the UUID for
  104. * a client named @param name . If no such client exists, return NULL
  105. *
  106. * @param client the client making the request
  107. * @param name the name of the client whose UUID is desired
  108. *
  109. * Return NULL if no such client with the given name exists
  110. *
  111. */
  112. char *jack_get_uuid_for_client_name (jack_client_t *client,
  113. const char *name) JACK_WEAK_EXPORT;
  114. /**
  115. * @return a pointer to the name of the client with the UUID
  116. * specified by uuid.
  117. *
  118. * @param client making the request
  119. * @param uuid the uuid of the client whose name is desired
  120. *
  121. * Return NULL if no such client with the given UUID exists
  122. */
  123. char *jack_get_client_name_by_uuid (jack_client_t *client,
  124. const char *uuid ) JACK_WEAK_EXPORT;
  125. /**
  126. * Load an internal client into the Jack server.
  127. *
  128. * Internal clients run inside the JACK server process. They can use
  129. * most of the same functions as external clients. Each internal
  130. * client must declare jack_initialize() and jack_finish() entry
  131. * points, called at load and unload times. See inprocess.c for an
  132. * example of how to write an internal client.
  133. *
  134. * @deprecated Please use jack_internal_client_load().
  135. *
  136. * @param client_name of at most jack_client_name_size() characters.
  137. *
  138. * @param load_name of a shared object file containing the code for
  139. * the new client.
  140. *
  141. * @param load_init an arbitary string passed to the jack_initialize()
  142. * routine of the new client (may be NULL).
  143. *
  144. * @return 0 if successful.
  145. */
  146. int jack_internal_client_new (const char *client_name,
  147. const char *load_name,
  148. const char *load_init) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
  149. /**
  150. * Remove an internal client from a JACK server.
  151. *
  152. * @deprecated Please use jack_internal_client_load().
  153. */
  154. void jack_internal_client_close (const char *client_name) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
  155. /**
  156. * Tell the Jack server that the program is ready to start processing
  157. * audio.
  158. *
  159. * @return 0 on success, otherwise a non-zero error code
  160. */
  161. int jack_activate (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT;
  162. /**
  163. * Tell the Jack server to remove this @a client from the process
  164. * graph. Also, disconnect all ports belonging to it, since inactive
  165. * clients have no port connections.
  166. *
  167. * @return 0 on success, otherwise a non-zero error code
  168. */
  169. int jack_deactivate (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT;
  170. /**
  171. * @return the pthread ID of the thread running the JACK client side
  172. * code.
  173. */
  174. jack_native_thread_t jack_client_thread_id (jack_client_t *) JACK_OPTIONAL_WEAK_EXPORT;
  175. /*@}*/
  176. /**
  177. * @param client pointer to JACK client structure.
  178. *
  179. * Check if the JACK subsystem is running with -R (--realtime).
  180. *
  181. * @return 1 if JACK is running realtime, 0 otherwise
  182. */
  183. int jack_is_realtime (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT;
  184. /**
  185. * @defgroup NonCallbackAPI The non-callback API
  186. * @{
  187. */
  188. /**
  189. * <b>THIS FUNCTION IS DEPRECATED AND SHOULD NOT BE USED IN
  190. * NEW JACK CLIENTS</b>
  191. *
  192. * It should be replace by use of @ jack_cycle_wait and @ jack_cycle_signal functions.
  193. *
  194. */
  195. jack_nframes_t jack_thread_wait (jack_client_t*, int status) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
  196. /**
  197. * Wait until this JACK client should process data.
  198. *
  199. * @param client - pointer to a JACK client structure
  200. *
  201. * @return the number of frames of data to process
  202. */
  203. jack_nframes_t jack_cycle_wait (jack_client_t* client) JACK_OPTIONAL_WEAK_EXPORT;
  204. /**
  205. * Signal next clients in the graph.
  206. *
  207. * @param client - pointer to a JACK client structure
  208. * @param status - if non-zero, calling thread should exit
  209. */
  210. void jack_cycle_signal (jack_client_t* client, int status) JACK_OPTIONAL_WEAK_EXPORT;
  211. /**
  212. * Tell the Jack server to call @a thread_callback in the RT thread.
  213. * Typical use are in conjunction with @a jack_cycle_wait and @ jack_cycle_signal functions.
  214. * The code in the supplied function must be suitable for real-time
  215. * execution. That means that it cannot call functions that might
  216. * block for a long time. This includes all I/O functions (disk, TTY, network),
  217. * malloc, free, printf, pthread_mutex_lock, sleep, wait, poll, select, pthread_join,
  218. * pthread_cond_wait, etc, etc.
  219. *
  220. * @return 0 on success, otherwise a non-zero error code.
  221. */
  222. int jack_set_process_thread(jack_client_t* client, JackThreadCallback fun, void *arg) JACK_OPTIONAL_WEAK_EXPORT;
  223. /*@}*/
  224. /**
  225. * @defgroup ClientCallbacks Setting Client Callbacks
  226. * @{
  227. */
  228. /**
  229. * Tell JACK to call @a thread_init_callback once just after
  230. * the creation of the thread in which all other callbacks
  231. * will be handled.
  232. *
  233. * The code in the supplied function does not need to be
  234. * suitable for real-time execution.
  235. *
  236. * @return 0 on success, otherwise a non-zero error code, causing JACK
  237. * to remove that client from the process() graph.
  238. */
  239. int jack_set_thread_init_callback (jack_client_t *client,
  240. JackThreadInitCallback thread_init_callback,
  241. void *arg) JACK_OPTIONAL_WEAK_EXPORT;
  242. /**
  243. * @param client pointer to JACK client structure.
  244. * @param function The jack_shutdown function pointer.
  245. * @param arg The arguments for the jack_shutdown function.
  246. *
  247. * Register a function (and argument) to be called if and when the
  248. * JACK server shuts down the client thread. The function must
  249. * be written as if it were an asynchonrous POSIX signal
  250. * handler --- use only async-safe functions, and remember that it
  251. * is executed from another thread. A typical function might
  252. * set a flag or write to a pipe so that the rest of the
  253. * application knows that the JACK client thread has shut
  254. * down.
  255. *
  256. * NOTE: clients do not need to call this. It exists only
  257. * to help more complex clients understand what is going
  258. * on. It should be called before jack_client_activate().
  259. *
  260. * NOTE: if a client calls this AND jack_on_info_shutdown(), then
  261. * the event of a client thread shutdown, the callback
  262. * passed to this function will not be called, and the one passed to
  263. * jack_on_info_shutdown() will.
  264. */
  265. void jack_on_shutdown (jack_client_t *client,
  266. JackShutdownCallback function, void *arg) JACK_OPTIONAL_WEAK_EXPORT;
  267. /**
  268. * @param client pointer to JACK client structure.
  269. * @param function The jack_shutdown function pointer.
  270. * @param arg The arguments for the jack_shutdown function.
  271. *
  272. * Register a function (and argument) to be called if and when the
  273. * JACK server shuts down the client thread. The function must
  274. * be written as if it were an asynchonrous POSIX signal
  275. * handler --- use only async-safe functions, and remember that it
  276. * is executed from another thread. A typical function might
  277. * set a flag or write to a pipe so that the rest of the
  278. * application knows that the JACK client thread has shut
  279. * down.
  280. *
  281. * NOTE: clients do not need to call this. It exists only
  282. * to help more complex clients understand what is going
  283. * on. It should be called before jack_client_activate().
  284. *
  285. * NOTE: if a client calls this AND jack_on_shutdown(), then in the
  286. * event of a client thread shutdown, the callback passed to
  287. * this function will be called, and the one passed to
  288. * jack_on_shutdown() will not.
  289. */
  290. void jack_on_info_shutdown (jack_client_t *client,
  291. JackInfoShutdownCallback function, void *arg) JACK_WEAK_EXPORT;
  292. /**
  293. * Tell the Jack server to call @a process_callback whenever there is
  294. * work be done, passing @a arg as the second argument.
  295. *
  296. * The code in the supplied function must be suitable for real-time
  297. * execution. That means that it cannot call functions that might
  298. * block for a long time. This includes all I/O functions (disk, TTY, network),
  299. * malloc, free, printf, pthread_mutex_lock, sleep, wait, poll, select, pthread_join,
  300. * pthread_cond_wait, etc, etc.
  301. *
  302. * @return 0 on success, otherwise a non-zero error code, causing JACK
  303. * to remove that client from the process() graph.
  304. */
  305. int jack_set_process_callback (jack_client_t *client,
  306. JackProcessCallback process_callback,
  307. void *arg) JACK_OPTIONAL_WEAK_EXPORT;
  308. /**
  309. * Tell the Jack server to call @a freewheel_callback
  310. * whenever we enter or leave "freewheel" mode, passing @a
  311. * arg as the second argument. The first argument to the
  312. * callback will be non-zero if JACK is entering freewheel
  313. * mode, and zero otherwise.
  314. *
  315. * @return 0 on success, otherwise a non-zero error code.
  316. */
  317. int jack_set_freewheel_callback (jack_client_t *client,
  318. JackFreewheelCallback freewheel_callback,
  319. void *arg) JACK_OPTIONAL_WEAK_EXPORT;
  320. /**
  321. * Tell JACK to call @a bufsize_callback whenever the size of the the
  322. * buffer that will be passed to the @a process_callback is about to
  323. * change. Clients that depend on knowing the buffer size must supply
  324. * a @a bufsize_callback before activating themselves.
  325. *
  326. * @param client pointer to JACK client structure.
  327. * @param bufsize_callback function to call when the buffer size changes.
  328. * @param arg argument for @a bufsize_callback.
  329. *
  330. * @return 0 on success, otherwise a non-zero error code
  331. */
  332. int jack_set_buffer_size_callback (jack_client_t *client,
  333. JackBufferSizeCallback bufsize_callback,
  334. void *arg) JACK_OPTIONAL_WEAK_EXPORT;
  335. /**
  336. * Tell the Jack server to call @a srate_callback whenever the system
  337. * sample rate changes.
  338. *
  339. * @return 0 on success, otherwise a non-zero error code
  340. */
  341. int jack_set_sample_rate_callback (jack_client_t *client,
  342. JackSampleRateCallback srate_callback,
  343. void *arg) JACK_OPTIONAL_WEAK_EXPORT;
  344. /**
  345. * Tell the JACK server to call @a registration_callback whenever a
  346. * port is registered or unregistered, passing @a arg as a parameter.
  347. *
  348. * @return 0 on success, otherwise a non-zero error code
  349. */
  350. int jack_set_client_registration_callback (jack_client_t *,
  351. JackClientRegistrationCallback
  352. registration_callback, void *arg) JACK_OPTIONAL_WEAK_EXPORT;
  353. /**
  354. * Tell the JACK server to call @a registration_callback whenever a
  355. * port is registered or unregistered, passing @a arg as a parameter.
  356. *
  357. * @return 0 on success, otherwise a non-zero error code
  358. */
  359. int jack_set_port_registration_callback (jack_client_t *,
  360. JackPortRegistrationCallback
  361. registration_callback, void *arg) JACK_OPTIONAL_WEAK_EXPORT;
  362. /**
  363. * Tell the JACK server to call @a rename_callback whenever a
  364. * port is renamed, passing @a arg as a parameter.
  365. *
  366. * @return 0 on success, otherwise a non-zero error code
  367. */
  368. int jack_set_port_rename_callback (jack_client_t *,
  369. JackPortRenameCallback
  370. rename_callback, void *arg) JACK_OPTIONAL_WEAK_EXPORT;
  371. /**
  372. * Tell the JACK server to call @a connect_callback whenever a
  373. * port is connected or disconnected, passing @a arg as a parameter.
  374. *
  375. * @return 0 on success, otherwise a non-zero error code
  376. */
  377. int jack_set_port_connect_callback (jack_client_t *,
  378. JackPortConnectCallback
  379. connect_callback, void *arg) JACK_OPTIONAL_WEAK_EXPORT;
  380. /**
  381. * Tell the JACK server to call @a graph_callback whenever the
  382. * processing graph is reordered, passing @a arg as a parameter.
  383. *
  384. * @return 0 on success, otherwise a non-zero error code
  385. */
  386. int jack_set_graph_order_callback (jack_client_t *,
  387. JackGraphOrderCallback graph_callback,
  388. void *) JACK_OPTIONAL_WEAK_EXPORT;
  389. /**
  390. * Tell the JACK server to call @a xrun_callback whenever there is a
  391. * xrun, passing @a arg as a parameter.
  392. *
  393. * @return 0 on success, otherwise a non-zero error code
  394. */
  395. int jack_set_xrun_callback (jack_client_t *,
  396. JackXRunCallback xrun_callback, void *arg) JACK_OPTIONAL_WEAK_EXPORT;
  397. /**
  398. * Tell the Jack server to call @a latency_callback whenever it
  399. * is necessary to recompute the latencies for some or all
  400. * Jack ports.
  401. *
  402. * @a latency_callback will be called twice each time it is
  403. * needed, once being passed JackCaptureLatency and once
  404. * JackPlaybackLatency. See @ref LatencyFunctions for
  405. * the definition of each type of latency and related functions.
  406. *
  407. * <b>IMPORTANT: Most JACK clients do NOT need to register a latency
  408. * callback.</b>
  409. *
  410. * Clients that meet any of the following conditions do NOT
  411. * need to register a latency callback:
  412. *
  413. * - have only input ports
  414. * - have only output ports
  415. * - their output is totally unrelated to their input
  416. * - their output is not delayed relative to their input
  417. * (i.e. data that arrives in a given process()
  418. * callback is processed and output again in the
  419. * same callback)
  420. *
  421. * Clients NOT registering a latency callback MUST also
  422. * satisfy this condition:
  423. *
  424. * - have no multiple distinct internal signal pathways
  425. *
  426. * This means that if your client has more than 1 input and
  427. * output port, and considers them always "correlated"
  428. * (e.g. as a stereo pair), then there is only 1 (e.g. stereo)
  429. * signal pathway through the client. This would be true,
  430. * for example, of a stereo FX rack client that has a
  431. * left/right input pair and a left/right output pair.
  432. *
  433. * However, this is somewhat a matter of perspective. The
  434. * same FX rack client could be connected so that its
  435. * two input ports were connected to entirely separate
  436. * sources. Under these conditions, the fact that the client
  437. * does not register a latency callback MAY result
  438. * in port latency values being incorrect.
  439. *
  440. * Clients that do not meet any of those conditions SHOULD
  441. * register a latency callback.
  442. *
  443. * See the documentation for @ref jack_port_set_latency_range()
  444. * on how the callback should operate. Remember that the @a mode
  445. * argument given to the latency callback will need to be
  446. * passed into @ref jack_port_set_latency_range()
  447. *
  448. * @return 0 on success, otherwise a non-zero error code
  449. */
  450. int jack_set_latency_callback (jack_client_t *,
  451. JackLatencyCallback latency_callback,
  452. void *) JACK_WEAK_EXPORT;
  453. /*@}*/
  454. /**
  455. * @defgroup ServerControl Controlling & querying JACK server operation
  456. * @{
  457. */
  458. /**
  459. * Start/Stop JACK's "freewheel" mode.
  460. *
  461. * When in "freewheel" mode, JACK no longer waits for
  462. * any external event to begin the start of the next process
  463. * cycle.
  464. *
  465. * As a result, freewheel mode causes "faster than realtime"
  466. * execution of a JACK graph. If possessed, real-time
  467. * scheduling is dropped when entering freewheel mode, and
  468. * if appropriate it is reacquired when stopping.
  469. *
  470. * IMPORTANT: on systems using capabilities to provide real-time
  471. * scheduling (i.e. Linux kernel 2.4), if onoff is zero, this function
  472. * must be called from the thread that originally called jack_activate().
  473. * This restriction does not apply to other systems (e.g. Linux kernel 2.6
  474. * or OS X).
  475. *
  476. * @param client pointer to JACK client structure
  477. * @param onoff if non-zero, freewheel mode starts. Otherwise
  478. * freewheel mode ends.
  479. *
  480. * @return 0 on success, otherwise a non-zero error code.
  481. */
  482. int jack_set_freewheel(jack_client_t* client, int onoff) JACK_OPTIONAL_WEAK_EXPORT;
  483. /**
  484. * Change the buffer size passed to the @a process_callback.
  485. *
  486. * This operation stops the JACK engine process cycle, then calls all
  487. * registered @a bufsize_callback functions before restarting the
  488. * process cycle. This will cause a gap in the audio flow, so it
  489. * should only be done at appropriate stopping points.
  490. *
  491. * @see jack_set_buffer_size_callback()
  492. *
  493. * @param client pointer to JACK client structure.
  494. * @param nframes new buffer size. Must be a power of two.
  495. *
  496. * @return 0 on success, otherwise a non-zero error code
  497. */
  498. int jack_set_buffer_size (jack_client_t *client, jack_nframes_t nframes) JACK_OPTIONAL_WEAK_EXPORT;
  499. /**
  500. * @return the sample rate of the jack system, as set by the user when
  501. * jackd was started.
  502. */
  503. jack_nframes_t jack_get_sample_rate (jack_client_t *) JACK_OPTIONAL_WEAK_EXPORT;
  504. /**
  505. * @return the current maximum size that will ever be passed to the @a
  506. * process_callback. It should only be used *before* the client has
  507. * been activated. This size may change, clients that depend on it
  508. * must register a @a bufsize_callback so they will be notified if it
  509. * does.
  510. *
  511. * @see jack_set_buffer_size_callback()
  512. */
  513. jack_nframes_t jack_get_buffer_size (jack_client_t *) JACK_OPTIONAL_WEAK_EXPORT;
  514. /**
  515. * Old-style interface to become the timebase for the entire JACK
  516. * subsystem.
  517. *
  518. * @deprecated This function still exists for compatibility with the
  519. * earlier transport interface, but it does nothing. Instead, see
  520. * transport.h and use jack_set_timebase_callback().
  521. *
  522. * @return ENOSYS, function not implemented.
  523. */
  524. int jack_engine_takeover_timebase (jack_client_t *) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
  525. /**
  526. * @return the current CPU load estimated by JACK. This is a running
  527. * average of the time it takes to execute a full process cycle for
  528. * all clients as a percentage of the real time available per cycle
  529. * determined by the buffer size and sample rate.
  530. */
  531. float jack_cpu_load (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT;
  532. /*@}*/
  533. /**
  534. * @defgroup PortFunctions Creating & manipulating ports
  535. * @{
  536. */
  537. /**
  538. * Create a new port for the client. This is an object used for moving
  539. * data of any type in or out of the client. Ports may be connected
  540. * in various ways.
  541. *
  542. * Each port has a short name. The port's full name contains the name
  543. * of the client concatenated with a colon (:) followed by its short
  544. * name. The jack_port_name_size() is the maximum length of this full
  545. * name. Exceeding that will cause the port registration to fail and
  546. * return NULL.
  547. *
  548. * The @a port_name must be unique among all ports owned by this client.
  549. * If the name is not unique, the registration will fail.
  550. *
  551. * All ports have a type, which may be any non-NULL and non-zero
  552. * length string, passed as an argument. Some port types are built
  553. * into the JACK API, like JACK_DEFAULT_AUDIO_TYPE or JACK_DEFAULT_MIDI_TYPE
  554. *
  555. * @param client pointer to JACK client structure.
  556. * @param port_name non-empty short name for the new port (not
  557. * including the leading @a "client_name:"). Must be unique.
  558. * @param port_type port type name. If longer than
  559. * jack_port_type_size(), only that many characters are significant.
  560. * @param flags @ref JackPortFlags bit mask.
  561. * @param buffer_size must be non-zero if this is not a built-in @a
  562. * port_type. Otherwise, it is ignored.
  563. *
  564. * @return jack_port_t pointer on success, otherwise NULL.
  565. */
  566. jack_port_t *jack_port_register (jack_client_t *client,
  567. const char *port_name,
  568. const char *port_type,
  569. unsigned long flags,
  570. unsigned long buffer_size) JACK_OPTIONAL_WEAK_EXPORT;
  571. /**
  572. * Remove the port from the client, disconnecting any existing
  573. * connections.
  574. *
  575. * @return 0 on success, otherwise a non-zero error code
  576. */
  577. int jack_port_unregister (jack_client_t *, jack_port_t *) JACK_OPTIONAL_WEAK_EXPORT;
  578. /**
  579. * This returns a pointer to the memory area associated with the
  580. * specified port. For an output port, it will be a memory area
  581. * that can be written to; for an input port, it will be an area
  582. * containing the data from the port's connection(s), or
  583. * zero-filled. if there are multiple inbound connections, the data
  584. * will be mixed appropriately.
  585. *
  586. * Do not cache the returned address across process() callbacks.
  587. * Port buffers have to be retrieved in each callback for proper functionning.
  588. */
  589. void *jack_port_get_buffer (jack_port_t *, jack_nframes_t) JACK_OPTIONAL_WEAK_EXPORT;
  590. /**
  591. * @return the full name of the jack_port_t (including the @a
  592. * "client_name:" prefix).
  593. *
  594. * @see jack_port_name_size().
  595. */
  596. const char *jack_port_name (const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
  597. /**
  598. * @return the UUID of the jack_port_t
  599. *
  600. * @see jack_uuid_to_string() to convert into a string representation
  601. */
  602. jack_uuid_t jack_port_uuid (const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
  603. /**
  604. * @return the short name of the jack_port_t (not including the @a
  605. * "client_name:" prefix).
  606. *
  607. * @see jack_port_name_size().
  608. */
  609. const char *jack_port_short_name (const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
  610. /**
  611. * @return the @ref JackPortFlags of the jack_port_t.
  612. */
  613. int jack_port_flags (const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
  614. /**
  615. * @return the @a port type, at most jack_port_type_size() characters
  616. * including a final NULL.
  617. */
  618. const char *jack_port_type (const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
  619. /**
  620. * @return TRUE if the jack_port_t belongs to the jack_client_t.
  621. */
  622. int jack_port_is_mine (const jack_client_t *, const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
  623. /**
  624. * @return number of connections to or from @a port.
  625. *
  626. * @pre The calling client must own @a port.
  627. */
  628. int jack_port_connected (const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
  629. /**
  630. * @return TRUE if the locally-owned @a port is @b directly connected
  631. * to the @a port_name.
  632. *
  633. * @see jack_port_name_size()
  634. */
  635. int jack_port_connected_to (const jack_port_t *port,
  636. const char *port_name) JACK_OPTIONAL_WEAK_EXPORT;
  637. /**
  638. * @return a null-terminated array of full port names to which the @a
  639. * port is connected. If none, returns NULL.
  640. *
  641. * The caller is responsible for calling jack_free(3) on any non-NULL
  642. * returned value.
  643. *
  644. * @param port locally owned jack_port_t pointer.
  645. *
  646. * @see jack_port_name_size(), jack_port_get_all_connections()
  647. */
  648. const char **jack_port_get_connections (const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
  649. /**
  650. * @return a null-terminated array of full port names to which the @a
  651. * port is connected. If none, returns NULL.
  652. *
  653. * The caller is responsible for calling jack_free(3) on any non-NULL
  654. * returned value.
  655. *
  656. * This differs from jack_port_get_connections() in two important
  657. * respects:
  658. *
  659. * 1) You may not call this function from code that is
  660. * executed in response to a JACK event. For example,
  661. * you cannot use it in a GraphReordered handler.
  662. *
  663. * 2) You need not be the owner of the port to get information
  664. * about its connections.
  665. *
  666. * @see jack_port_name_size()
  667. */
  668. const char **jack_port_get_all_connections (const jack_client_t *client,
  669. const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
  670. /**
  671. *
  672. * @deprecated This function will be removed from a future version
  673. * of JACK. Do not use it. There is no replacement. It has
  674. * turned out to serve essentially no purpose in real-life
  675. * JACK clients.
  676. */
  677. int jack_port_tie (jack_port_t *src, jack_port_t *dst) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
  678. /**
  679. *
  680. * @deprecated This function will be removed from a future version
  681. * of JACK. Do not use it. There is no replacement. It has
  682. * turned out to serve essentially no purpose in real-life
  683. * JACK clients.
  684. */
  685. int jack_port_untie (jack_port_t *port) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
  686. /**
  687. * Modify a port's short name. May be called at any time. If the
  688. * resulting full name (including the @a "client_name:" prefix) is
  689. * longer than jack_port_name_size(), it will be truncated.
  690. *
  691. * @return 0 on success, otherwise a non-zero error code.
  692. */
  693. int jack_port_set_name (jack_port_t *port, const char *port_name) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
  694. /**
  695. * Modify a port's short name. May NOT be called from a callback handling a server event.
  696. * If the resulting full name (including the @a "client_name:" prefix) is
  697. * longer than jack_port_name_size(), it will be truncated.
  698. *
  699. * @return 0 on success, otherwise a non-zero error code.
  700. *
  701. * This differs from jack_port_set_name() by triggering PortRename notifications to
  702. * clients that have registered a port rename handler.
  703. */
  704. int jack_port_rename (jack_client_t* client, jack_port_t *port, const char *port_name) JACK_OPTIONAL_WEAK_EXPORT;
  705. /**
  706. * Set @a alias as an alias for @a port. May be called at any time.
  707. * If the alias is longer than jack_port_name_size(), it will be truncated.
  708. *
  709. * After a successful call, and until JACK exits or
  710. * jack_port_unset_alias() is called, may be
  711. * used as a alternate name for the port.
  712. *
  713. * Ports can have up to two aliases - if both are already
  714. * set, this function will return an error.
  715. *
  716. * @return 0 on success, otherwise a non-zero error code.
  717. */
  718. int jack_port_set_alias (jack_port_t *port, const char *alias) JACK_OPTIONAL_WEAK_EXPORT;
  719. /**
  720. * Remove @a alias as an alias for @a port. May be called at any time.
  721. *
  722. * After a successful call, @a alias can no longer be
  723. * used as a alternate name for the port.
  724. *
  725. * @return 0 on success, otherwise a non-zero error code.
  726. */
  727. int jack_port_unset_alias (jack_port_t *port, const char *alias) JACK_OPTIONAL_WEAK_EXPORT;
  728. /*
  729. * Get any aliases known for @port.
  730. *
  731. * @return the number of aliases discovered for the port
  732. */
  733. int jack_port_get_aliases (const jack_port_t *port, char* const aliases[2]) JACK_OPTIONAL_WEAK_EXPORT;
  734. /**
  735. * If @ref JackPortCanMonitor is set for this @a port, turn input
  736. * monitoring on or off. Otherwise, do nothing.
  737. */
  738. int jack_port_request_monitor (jack_port_t *port, int onoff) JACK_OPTIONAL_WEAK_EXPORT;
  739. /**
  740. * If @ref JackPortCanMonitor is set for this @a port_name, turn input
  741. * monitoring on or off. Otherwise, do nothing.
  742. *
  743. * @return 0 on success, otherwise a non-zero error code.
  744. *
  745. * @see jack_port_name_size()
  746. */
  747. int jack_port_request_monitor_by_name (jack_client_t *client,
  748. const char *port_name, int onoff) JACK_OPTIONAL_WEAK_EXPORT;
  749. /**
  750. * If @ref JackPortCanMonitor is set for a port, this function turns
  751. * on input monitoring if it was off, and turns it off if only one
  752. * request has been made to turn it on. Otherwise it does nothing.
  753. *
  754. * @return 0 on success, otherwise a non-zero error code
  755. */
  756. int jack_port_ensure_monitor (jack_port_t *port, int onoff) JACK_OPTIONAL_WEAK_EXPORT;
  757. /**
  758. * @return TRUE if input monitoring has been requested for @a port.
  759. */
  760. int jack_port_monitoring_input (jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
  761. /**
  762. * Establish a connection between two ports.
  763. *
  764. * When a connection exists, data written to the source port will
  765. * be available to be read at the destination port.
  766. *
  767. * @pre The port types must be identical.
  768. *
  769. * @pre The @ref JackPortFlags of the @a source_port must include @ref
  770. * JackPortIsOutput.
  771. *
  772. * @pre The @ref JackPortFlags of the @a destination_port must include
  773. * @ref JackPortIsInput.
  774. *
  775. * @return 0 on success, EEXIST if the connection is already made,
  776. * otherwise a non-zero error code
  777. */
  778. int jack_connect (jack_client_t *,
  779. const char *source_port,
  780. const char *destination_port) JACK_OPTIONAL_WEAK_EXPORT;
  781. /**
  782. * Remove a connection between two ports.
  783. *
  784. * @pre The port types must be identical.
  785. *
  786. * @pre The @ref JackPortFlags of the @a source_port must include @ref
  787. * JackPortIsOutput.
  788. *
  789. * @pre The @ref JackPortFlags of the @a destination_port must include
  790. * @ref JackPortIsInput.
  791. *
  792. * @return 0 on success, otherwise a non-zero error code
  793. */
  794. int jack_disconnect (jack_client_t *,
  795. const char *source_port,
  796. const char *destination_port) JACK_OPTIONAL_WEAK_EXPORT;
  797. /**
  798. * Perform the same function as jack_disconnect() using port handles
  799. * rather than names. This avoids the name lookup inherent in the
  800. * name-based version.
  801. *
  802. * Clients connecting their own ports are likely to use this function,
  803. * while generic connection clients (e.g. patchbays) would use
  804. * jack_disconnect().
  805. */
  806. int jack_port_disconnect (jack_client_t *, jack_port_t *) JACK_OPTIONAL_WEAK_EXPORT;
  807. /**
  808. * @return the maximum number of characters in a full JACK port name
  809. * including the final NULL character. This value is a constant.
  810. *
  811. * A port's full name contains the owning client name concatenated
  812. * with a colon (:) followed by its short name and a NULL
  813. * character.
  814. */
  815. int jack_port_name_size(void) JACK_OPTIONAL_WEAK_EXPORT;
  816. /**
  817. * @return the maximum number of characters in a JACK port type name
  818. * including the final NULL character. This value is a constant.
  819. */
  820. int jack_port_type_size(void) JACK_OPTIONAL_WEAK_EXPORT;
  821. /**
  822. * @return the buffersize of a port of type @arg port_type.
  823. *
  824. * this function may only be called in a buffer_size callback.
  825. */
  826. size_t jack_port_type_get_buffer_size (jack_client_t *client, const char *port_type) JACK_WEAK_EXPORT;
  827. /*@}*/
  828. /**
  829. * @defgroup LatencyFunctions Managing and determining latency
  830. *
  831. * The purpose of JACK's latency API is to allow clients to
  832. * easily answer two questions:
  833. *
  834. * - How long has it been since the data read from a port arrived
  835. * at the edge of the JACK graph (either via a physical port
  836. * or being synthesized from scratch)?
  837. *
  838. * - How long will it be before the data written to a port arrives
  839. * at the edge of a JACK graph?
  840. * To help answering these two questions, all JACK ports have two
  841. * latency values associated with them, both measured in frames:
  842. *
  843. * <b>capture latency</b>: how long since the data read from
  844. * the buffer of a port arrived at at
  845. * a port marked with JackPortIsTerminal.
  846. * The data will have come from the "outside
  847. * world" if the terminal port is also
  848. * marked with JackPortIsPhysical, or
  849. * will have been synthesized by the client
  850. * that owns the terminal port.
  851. *
  852. * <b>playback latency</b>: how long until the data
  853. * written to the buffer of port will reach a port
  854. * marked with JackPortIsTerminal.
  855. *
  856. * Both latencies might potentially have more than one value
  857. * because there may be multiple pathways to/from a given port
  858. * and a terminal port. Latency is therefore generally
  859. * expressed a min/max pair.
  860. *
  861. * In most common setups, the minimum and maximum latency
  862. * are the same, but this design accomodates more complex
  863. * routing, and allows applications (and thus users) to
  864. * detect cases where routing is creating an anomalous
  865. * situation that may either need fixing or more
  866. * sophisticated handling by clients that care about
  867. * latency.
  868. *
  869. * See also @ref jack_set_latency_callback for details on how
  870. * clients that add latency to the signal path should interact
  871. * with JACK to ensure that the correct latency figures are
  872. * used.
  873. * @{
  874. */
  875. /**
  876. * The port latency is zero by default. Clients that control
  877. * physical hardware with non-zero latency should call this
  878. * to set the latency to its correct value. Note that the value
  879. * should include any systemic latency present "outside" the
  880. * physical hardware controlled by the client. For example,
  881. * for a client controlling a digital audio interface connected
  882. * to an external digital converter, the latency setting should
  883. * include both buffering by the audio interface *and* the converter.
  884. *
  885. * @deprecated This method will be removed in the next major
  886. * release of JACK. It should not be used in new code, and should
  887. * be replaced by a latency callback that calls @ref
  888. * jack_port_set_latency_range().
  889. */
  890. void jack_port_set_latency (jack_port_t *, jack_nframes_t) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
  891. /**
  892. * return the latency range defined by @a mode for
  893. * @a port, in frames.
  894. *
  895. * See @ref LatencyFunctions for the definition of each latency value.
  896. *
  897. * This is normally used in the LatencyCallback.
  898. * and therefor safe to execute from callbacks.
  899. */
  900. void jack_port_get_latency_range (jack_port_t *port, jack_latency_callback_mode_t mode, jack_latency_range_t *range) JACK_WEAK_EXPORT;
  901. /**
  902. * set the minimum and maximum latencies defined by
  903. * @a mode for @a port, in frames.
  904. *
  905. * See @ref LatencyFunctions for the definition of each latency value.
  906. *
  907. * This function should ONLY be used inside a latency
  908. * callback. The client should determine the current
  909. * value of the latency using @ref jack_port_get_latency_range()
  910. * (called using the same mode as @a mode)
  911. * and then add some number of frames to that reflects
  912. * latency added by the client.
  913. *
  914. * How much latency a client adds will vary
  915. * dramatically. For most clients, the answer is zero
  916. * and there is no reason for them to register a latency
  917. * callback and thus they should never call this
  918. * function.
  919. *
  920. * More complex clients that take an input signal,
  921. * transform it in some way and output the result but
  922. * not during the same process() callback will
  923. * generally know a single constant value to add
  924. * to the value returned by @ref jack_port_get_latency_range().
  925. *
  926. * Such clients would register a latency callback (see
  927. * @ref jack_set_latency_callback) and must know what input
  928. * ports feed which output ports as part of their
  929. * internal state. Their latency callback will update
  930. * the ports' latency values appropriately.
  931. *
  932. * A pseudo-code example will help. The @a mode argument to the latency
  933. * callback will determine whether playback or capture
  934. * latency is being set. The callback will use
  935. * @ref jack_port_set_latency_range() as follows:
  936. *
  937. * \code
  938. * jack_latency_range_t range;
  939. * if (mode == JackPlaybackLatency) {
  940. * foreach input_port in (all self-registered port) {
  941. * jack_port_get_latency_range (port_feeding_input_port, JackPlaybackLatency, &range);
  942. * range.min += min_delay_added_as_signal_flows_from port_feeding to input_port;
  943. * range.max += max_delay_added_as_signal_flows_from port_feeding to input_port;
  944. * jack_port_set_latency_range (input_port, JackPlaybackLatency, &range);
  945. * }
  946. * } else if (mode == JackCaptureLatency) {
  947. * foreach output_port in (all self-registered port) {
  948. * jack_port_get_latency_range (port_fed_by_output_port, JackCaptureLatency, &range);
  949. * range.min += min_delay_added_as_signal_flows_from_output_port_to_fed_by_port;
  950. * range.max += max_delay_added_as_signal_flows_from_output_port_to_fed_by_port;
  951. * jack_port_set_latency_range (output_port, JackCaptureLatency, &range);
  952. * }
  953. * }
  954. * \endcode
  955. *
  956. * In this relatively simple pseudo-code example, it is assumed that
  957. * each input port or output is connected to only 1 output or input
  958. * port respectively.
  959. *
  960. * If a port is connected to more than 1 other port, then the
  961. * range.min and range.max values passed to @ref
  962. * jack_port_set_latency_range() should reflect the minimum and
  963. * maximum values across all connected ports.
  964. *
  965. * See the description of @ref jack_set_latency_callback for more
  966. * information.
  967. */
  968. void jack_port_set_latency_range (jack_port_t *port, jack_latency_callback_mode_t mode, jack_latency_range_t *range) JACK_WEAK_EXPORT;
  969. /**
  970. * Request a complete recomputation of all port latencies. This
  971. * can be called by a client that has just changed the internal
  972. * latency of its port using jack_port_set_latency
  973. * and wants to ensure that all signal pathways in the graph
  974. * are updated with respect to the values that will be returned
  975. * by jack_port_get_total_latency. It allows a client
  976. * to change multiple port latencies without triggering a
  977. * recompute for each change.
  978. *
  979. * @return zero for successful execution of the request. non-zero
  980. * otherwise.
  981. */
  982. int jack_recompute_total_latencies (jack_client_t*) JACK_OPTIONAL_WEAK_EXPORT;
  983. /**
  984. * @return the time (in frames) between data being available or
  985. * delivered at/to a port, and the time at which it arrived at or is
  986. * delivered to the "other side" of the port. E.g. for a physical
  987. * audio output port, this is the time between writing to the port and
  988. * when the signal will leave the connector. For a physical audio
  989. * input port, this is the time between the sound arriving at the
  990. * connector and the corresponding frames being readable from the
  991. * port.
  992. *
  993. * @deprecated This method will be removed in the next major
  994. * release of JACK. It should not be used in new code, and should
  995. * be replaced by jack_port_get_latency_range() in any existing
  996. * use cases.
  997. */
  998. jack_nframes_t jack_port_get_latency (jack_port_t *port) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
  999. /**
  1000. * The maximum of the sum of the latencies in every
  1001. * connection path that can be drawn between the port and other
  1002. * ports with the @ref JackPortIsTerminal flag set.
  1003. *
  1004. * @deprecated This method will be removed in the next major
  1005. * release of JACK. It should not be used in new code, and should
  1006. * be replaced by jack_port_get_latency_range() in any existing
  1007. * use cases.
  1008. */
  1009. jack_nframes_t jack_port_get_total_latency (jack_client_t *,
  1010. jack_port_t *port) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
  1011. /**
  1012. * Request a complete recomputation of a port's total latency. This
  1013. * can be called by a client that has just changed the internal
  1014. * latency of its port using jack_port_set_latency
  1015. * and wants to ensure that all signal pathways in the graph
  1016. * are updated with respect to the values that will be returned
  1017. * by jack_port_get_total_latency.
  1018. *
  1019. * @return zero for successful execution of the request. non-zero
  1020. * otherwise.
  1021. *
  1022. * @deprecated This method will be removed in the next major
  1023. * release of JACK. It should not be used in new code, and should
  1024. * be replaced by jack_recompute_total_latencies() in any existing
  1025. * use cases.
  1026. */
  1027. int jack_recompute_total_latency (jack_client_t*, jack_port_t* port) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
  1028. /*@}*/
  1029. /**
  1030. * @defgroup PortSearching Looking up ports
  1031. * @{
  1032. */
  1033. /**
  1034. * @param port_name_pattern A regular expression used to select
  1035. * ports by name. If NULL or of zero length, no selection based
  1036. * on name will be carried out.
  1037. * @param type_name_pattern A regular expression used to select
  1038. * ports by type. If NULL or of zero length, no selection based
  1039. * on type will be carried out.
  1040. * @param flags A value used to select ports by their flags.
  1041. * If zero, no selection based on flags will be carried out.
  1042. *
  1043. * @return a NULL-terminated array of ports that match the specified
  1044. * arguments. The caller is responsible for calling jack_free(3) any
  1045. * non-NULL returned value.
  1046. *
  1047. * @see jack_port_name_size(), jack_port_type_size()
  1048. */
  1049. const char **jack_get_ports (jack_client_t *,
  1050. const char *port_name_pattern,
  1051. const char *type_name_pattern,
  1052. unsigned long flags) JACK_OPTIONAL_WEAK_EXPORT;
  1053. /**
  1054. * @return address of the jack_port_t named @a port_name.
  1055. *
  1056. * @see jack_port_name_size()
  1057. */
  1058. jack_port_t *jack_port_by_name (jack_client_t *, const char *port_name) JACK_OPTIONAL_WEAK_EXPORT;
  1059. /**
  1060. * @return address of the jack_port_t of a @a port_id.
  1061. */
  1062. jack_port_t *jack_port_by_id (jack_client_t *client,
  1063. jack_port_id_t port_id) JACK_OPTIONAL_WEAK_EXPORT;
  1064. /*@}*/
  1065. /**
  1066. * @defgroup TimeFunctions Handling time
  1067. * @{
  1068. *
  1069. * JACK time is in units of 'frames', according to the current sample rate.
  1070. * The absolute value of frame times is meaningless, frame times have meaning
  1071. * only relative to each other.
  1072. */
  1073. /**
  1074. * @return the estimated time in frames that has passed since the JACK
  1075. * server began the current process cycle.
  1076. */
  1077. jack_nframes_t jack_frames_since_cycle_start (const jack_client_t *) JACK_OPTIONAL_WEAK_EXPORT;
  1078. /**
  1079. * @return the estimated current time in frames.
  1080. * This function is intended for use in other threads (not the process
  1081. * callback). The return value can be compared with the value of
  1082. * jack_last_frame_time to relate time in other threads to JACK time.
  1083. */
  1084. jack_nframes_t jack_frame_time (const jack_client_t *) JACK_OPTIONAL_WEAK_EXPORT;
  1085. /**
  1086. * @return the precise time at the start of the current process cycle.
  1087. * This function may only be used from the process callback, and can
  1088. * be used to interpret timestamps generated by jack_frame_time() in
  1089. * other threads with respect to the current process cycle.
  1090. *
  1091. * This is the only jack time function that returns exact time:
  1092. * when used during the process callback it always returns the same
  1093. * value (until the next process callback, where it will return
  1094. * that value + nframes, etc). The return value is guaranteed to be
  1095. * monotonic and linear in this fashion unless an xrun occurs.
  1096. * If an xrun occurs, clients must check this value again, as time
  1097. * may have advanced in a non-linear way (e.g. cycles may have been skipped).
  1098. */
  1099. jack_nframes_t jack_last_frame_time (const jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT;
  1100. /**
  1101. * This function may only be used from the process callback.
  1102. * It provides the internal cycle timing information as used by
  1103. * most of the other time related functions. This allows the
  1104. * caller to map between frame counts and microseconds with full
  1105. * precision (i.e. without rounding frame times to integers),
  1106. * and also provides e.g. the microseconds time of the start of
  1107. * the current cycle directly (it has to be computed otherwise).
  1108. *
  1109. * If the return value is zero, the following information is
  1110. * provided in the variables pointed to by the arguments:
  1111. *
  1112. * current_frames: the frame time counter at the start of the
  1113. * current cycle, same as jack_last_frame_time().
  1114. * current_usecs: the microseconds time at the start of the
  1115. * current cycle.
  1116. * next_usecs: the microseconds time of the start of the next
  1117. * next cycle as computed by the DLL.
  1118. * period_usecs: the current best estimate of the period time in
  1119. * microseconds.
  1120. *
  1121. * NOTES:
  1122. *
  1123. * Because of the types used, all the returned values except period_usecs
  1124. * are unsigned. In computations mapping between frames and microseconds
  1125. * *signed* differences are required. The easiest way is to compute those
  1126. * separately and assign them to the appropriate signed variables,
  1127. * int32_t for frames and int64_t for usecs. See the implementation of
  1128. * jack_frames_to_time() and Jack_time_to_frames() for an example.
  1129. *
  1130. * Unless there was an xrun, skipped cycles, or the current cycle is the
  1131. * first after freewheeling or starting Jack, the value of current_usecs
  1132. * will always be the value of next_usecs of the previous cycle.
  1133. *
  1134. * The value of period_usecs will in general NOT be exactly equal to
  1135. * the difference of next_usecs and current_usecs. This is because to
  1136. * ensure stability of the DLL and continuity of the mapping, a fraction
  1137. * of the loop error must be included in next_usecs. For an accurate
  1138. * mapping between frames and microseconds, the difference of next_usecs
  1139. * and current_usecs should be used, and not period_usecs.
  1140. *
  1141. * @return zero if OK, non-zero otherwise.
  1142. */
  1143. int jack_get_cycle_times (const jack_client_t *client,
  1144. jack_nframes_t *current_frames,
  1145. jack_time_t *current_usecs,
  1146. jack_time_t *next_usecs,
  1147. float *period_usecs) JACK_OPTIONAL_WEAK_EXPORT;
  1148. /**
  1149. * @return the estimated time in microseconds of the specified frame time
  1150. */
  1151. jack_time_t jack_frames_to_time(const jack_client_t *client, jack_nframes_t) JACK_OPTIONAL_WEAK_EXPORT;
  1152. /**
  1153. * @return the estimated time in frames for the specified system time.
  1154. */
  1155. jack_nframes_t jack_time_to_frames(const jack_client_t *client, jack_time_t) JACK_OPTIONAL_WEAK_EXPORT;
  1156. /**
  1157. * @return return JACK's current system time in microseconds,
  1158. * using the JACK clock source.
  1159. *
  1160. * The value returned is guaranteed to be monotonic, but not linear.
  1161. */
  1162. jack_time_t jack_get_time(void) JACK_OPTIONAL_WEAK_EXPORT;
  1163. /*@}*/
  1164. /**
  1165. * @defgroup ErrorOutput Controlling error/information output
  1166. */
  1167. /*@{*/
  1168. /**
  1169. * Display JACK error message.
  1170. *
  1171. * Set via jack_set_error_function(), otherwise a JACK-provided
  1172. * default will print @a msg (plus a newline) to stderr.
  1173. *
  1174. * @param msg error message text (no newline at end).
  1175. */
  1176. extern void (*jack_error_callback)(const char *msg) JACK_OPTIONAL_WEAK_EXPORT;
  1177. /**
  1178. * Set the @ref jack_error_callback for error message display.
  1179. *
  1180. * The JACK library provides two built-in callbacks for this purpose:
  1181. * default_jack_error_callback() and silent_jack_error_callback().
  1182. */
  1183. void jack_set_error_function (void (*func)(const char *)) JACK_OPTIONAL_WEAK_EXPORT;
  1184. /**
  1185. * Display JACK info message.
  1186. *
  1187. * Set via jack_set_info_function(), otherwise a JACK-provided
  1188. * default will print @a msg (plus a newline) to stdout.
  1189. *
  1190. * @param msg info message text (no newline at end).
  1191. */
  1192. extern void (*jack_info_callback)(const char *msg) JACK_OPTIONAL_WEAK_EXPORT;
  1193. /**
  1194. * Set the @ref jack_info_callback for info message display.
  1195. */
  1196. void jack_set_info_function (void (*func)(const char *)) JACK_OPTIONAL_WEAK_EXPORT;
  1197. /*@}*/
  1198. /**
  1199. * The free function to be used on memory returned by jack_port_get_connections,
  1200. * jack_port_get_all_connections and jack_get_ports functions.
  1201. * This is MANDATORY on Windows when otherwise all nasty runtime version related crashes can occur.
  1202. * Developers are strongly encouraged to use this function instead of the standard "free" function in new code.
  1203. *
  1204. */
  1205. void jack_free(void* ptr) JACK_OPTIONAL_WEAK_EXPORT;
  1206. #ifdef __cplusplus
  1207. }
  1208. #endif
  1209. #endif /* __jack_h__ */