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.

1416 lines
52KB

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