jack2 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1362 lines
50KB

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