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.

1476 lines
55KB

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