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.

1339 lines
49KB

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