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.

1471 lines
54KB

  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. * 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 arbitary 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 seperated 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 seperated 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 seperated 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 seperated 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 seperated 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 seperated 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 seperated 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 seperated 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 seperated 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. /**
  513. * Tell the Jack server to call @a latency_callback whenever it
  514. * is necessary to recompute the latencies for some or all
  515. * Jack ports.
  516. *
  517. * @a latency_callback will be called twice each time it is
  518. * needed, once being passed JackCaptureLatency and once
  519. * JackPlaybackLatency. See @ref LatencyFunctions for
  520. * the definition of each type of latency and related functions.
  521. *
  522. * <b>IMPORTANT: Most JACK clients do NOT need to register a latency
  523. * callback.</b>
  524. *
  525. * Clients that meet any of the following conditions do NOT
  526. * need to register a latency callback:
  527. *
  528. * - have only input ports
  529. * - have only output ports
  530. * - their output is totally unrelated to their input
  531. * - their output is not delayed relative to their input
  532. * (i.e. data that arrives in a given process()
  533. * callback is processed and output again in the
  534. * same callback)
  535. *
  536. * Clients NOT registering a latency callback MUST also
  537. * satisfy this condition:
  538. *
  539. * - have no multiple distinct internal signal pathways
  540. *
  541. * This means that if your client has more than 1 input and
  542. * output port, and considers them always "correlated"
  543. * (e.g. as a stereo pair), then there is only 1 (e.g. stereo)
  544. * signal pathway through the client. This would be true,
  545. * for example, of a stereo FX rack client that has a
  546. * left/right input pair and a left/right output pair.
  547. *
  548. * However, this is somewhat a matter of perspective. The
  549. * same FX rack client could be connected so that its
  550. * two input ports were connected to entirely separate
  551. * sources. Under these conditions, the fact that the client
  552. * does not register a latency callback MAY result
  553. * in port latency values being incorrect.
  554. *
  555. * Clients that do not meet any of those conditions SHOULD
  556. * register a latency callback.
  557. *
  558. * See the documentation for @ref jack_port_set_latency_range()
  559. * on how the callback should operate. Remember that the @a mode
  560. * argument given to the latency callback will need to be
  561. * passed into @ref jack_port_set_latency_range()
  562. *
  563. * @return 0 on success, otherwise a non-zero error code
  564. */
  565. int jack_set_latency_callback (jack_client_t *client,
  566. JackLatencyCallback latency_callback,
  567. void *) JACK_WEAK_EXPORT;
  568. /*@}*/
  569. /**
  570. * @defgroup ServerClientControl Controlling & querying JACK server operation
  571. * @{
  572. */
  573. /**
  574. * Start/Stop JACK's "freewheel" mode.
  575. *
  576. * When in "freewheel" mode, JACK no longer waits for
  577. * any external event to begin the start of the next process
  578. * cycle.
  579. *
  580. * As a result, freewheel mode causes "faster than realtime"
  581. * execution of a JACK graph. If possessed, real-time
  582. * scheduling is dropped when entering freewheel mode, and
  583. * if appropriate it is reacquired when stopping.
  584. *
  585. * IMPORTANT: on systems using capabilities to provide real-time
  586. * scheduling (i.e. Linux kernel 2.4), if onoff is zero, this function
  587. * must be called from the thread that originally called jack_activate().
  588. * This restriction does not apply to other systems (e.g. Linux kernel 2.6
  589. * or OS X).
  590. *
  591. * @param client pointer to JACK client structure
  592. * @param onoff if non-zero, freewheel mode starts. Otherwise
  593. * freewheel mode ends.
  594. *
  595. * @return 0 on success, otherwise a non-zero error code.
  596. */
  597. int jack_set_freewheel(jack_client_t* client, int onoff) JACK_OPTIONAL_WEAK_EXPORT;
  598. /**
  599. * Change the buffer size passed to the @a process_callback.
  600. *
  601. * This operation stops the JACK engine process cycle, then calls all
  602. * registered @a bufsize_callback functions before restarting the
  603. * process cycle. This will cause a gap in the audio flow, so it
  604. * should only be done at appropriate stopping points.
  605. *
  606. * @see jack_set_buffer_size_callback()
  607. *
  608. * @param client pointer to JACK client structure.
  609. * @param nframes new buffer size. Must be a power of two.
  610. *
  611. * @return 0 on success, otherwise a non-zero error code
  612. */
  613. int jack_set_buffer_size (jack_client_t *client, jack_nframes_t nframes) JACK_OPTIONAL_WEAK_EXPORT;
  614. /**
  615. * @return the sample rate of the jack system, as set by the user when
  616. * jackd was started.
  617. */
  618. jack_nframes_t jack_get_sample_rate (jack_client_t *) JACK_OPTIONAL_WEAK_EXPORT;
  619. /**
  620. * @return the current maximum size that will ever be passed to the @a
  621. * process_callback. It should only be used *before* the client has
  622. * been activated. This size may change, clients that depend on it
  623. * must register a @a bufsize_callback so they will be notified if it
  624. * does.
  625. *
  626. * @see jack_set_buffer_size_callback()
  627. */
  628. jack_nframes_t jack_get_buffer_size (jack_client_t *) JACK_OPTIONAL_WEAK_EXPORT;
  629. /**
  630. * Old-style interface to become the timebase for the entire JACK
  631. * subsystem.
  632. *
  633. * @deprecated This function still exists for compatibility with the
  634. * earlier transport interface, but it does nothing. Instead, see
  635. * transport.h and use jack_set_timebase_callback().
  636. *
  637. * @return ENOSYS, function not implemented.
  638. */
  639. int jack_engine_takeover_timebase (jack_client_t *) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
  640. /**
  641. * @return the current CPU load estimated by JACK. This is a running
  642. * average of the time it takes to execute a full process cycle for
  643. * all clients as a percentage of the real time available per cycle
  644. * determined by the buffer size and sample rate.
  645. */
  646. float jack_cpu_load (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT;
  647. /*@}*/
  648. /**
  649. * @defgroup PortFunctions Creating & manipulating ports
  650. * @{
  651. */
  652. /**
  653. * Create a new port for the client. This is an object used for moving
  654. * data of any type in or out of the client. Ports may be connected
  655. * in various ways.
  656. *
  657. * Each port has a short name. The port's full name contains the name
  658. * of the client concatenated with a colon (:) followed by its short
  659. * name. The jack_port_name_size() is the maximum length of this full
  660. * name. Exceeding that will cause the port registration to fail and
  661. * return NULL.
  662. *
  663. * The @a port_name must be unique among all ports owned by this client.
  664. * If the name is not unique, the registration will fail.
  665. *
  666. * All ports have a type, which may be any non-NULL and non-zero
  667. * length string, passed as an argument. Some port types are built
  668. * into the JACK API, currently only JACK_DEFAULT_AUDIO_TYPE.
  669. *
  670. * @param client pointer to JACK client structure.
  671. * @param port_name non-empty short name for the new port (not
  672. * including the leading @a "client_name:"). Must be unique.
  673. * @param port_type port type name. If longer than
  674. * jack_port_type_size(), only that many characters are significant.
  675. * @param flags @ref JackPortFlags bit mask.
  676. * @param buffer_size must be non-zero if this is not a built-in @a
  677. * port_type. Otherwise, it is ignored.
  678. *
  679. * @return jack_port_t pointer on success, otherwise NULL.
  680. */
  681. jack_port_t * jack_port_register (jack_client_t *client,
  682. const char *port_name,
  683. const char *port_type,
  684. unsigned long flags,
  685. unsigned long buffer_size) JACK_OPTIONAL_WEAK_EXPORT;
  686. /**
  687. * Remove the port from the client, disconnecting any existing
  688. * connections.
  689. *
  690. * @return 0 on success, otherwise a non-zero error code
  691. */
  692. int jack_port_unregister (jack_client_t *client, jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
  693. /**
  694. * This returns a pointer to the memory area associated with the
  695. * specified port. For an output port, it will be a memory area
  696. * that can be written to; for an input port, it will be an area
  697. * containing the data from the port's connection(s), or
  698. * zero-filled. if there are multiple inbound connections, the data
  699. * will be mixed appropriately.
  700. *
  701. * FOR OUTPUT PORTS ONLY : DEPRECATED in Jack 2.0 !!
  702. * ---------------------------------------------------
  703. * You may cache the value returned, but only between calls to
  704. * your "blocksize" callback. For this reason alone, you should
  705. * either never cache the return value or ensure you have
  706. * a "blocksize" callback and be sure to invalidate the cached
  707. * address from there.
  708. *
  709. * Caching output ports is DEPRECATED in Jack 2.0, due to some new optimization (like "pipelining").
  710. * Port buffers have to be retrieved in each callback for proper functionning.
  711. */
  712. void * jack_port_get_buffer (jack_port_t *port, jack_nframes_t) JACK_OPTIONAL_WEAK_EXPORT;
  713. /**
  714. * @return the UUID of the jack_port_t
  715. *
  716. * @see jack_uuid_to_string() to convert into a string representation
  717. */
  718. jack_uuid_t jack_port_uuid (const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
  719. /**
  720. * @return the full name of the jack_port_t (including the @a
  721. * "client_name:" prefix).
  722. *
  723. * @see jack_port_name_size().
  724. */
  725. const char * jack_port_name (const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
  726. /**
  727. * @return the short name of the jack_port_t (not including the @a
  728. * "client_name:" prefix).
  729. *
  730. * @see jack_port_name_size().
  731. */
  732. const char * jack_port_short_name (const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
  733. /**
  734. * @return the @ref JackPortFlags of the jack_port_t.
  735. */
  736. int jack_port_flags (const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
  737. /**
  738. * @return the @a port type, at most jack_port_type_size() characters
  739. * including a final NULL.
  740. */
  741. const char * jack_port_type (const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
  742. /**
  743. * @return the @a port type id.
  744. */
  745. jack_port_type_id_t jack_port_type_id (const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
  746. /**
  747. * @return TRUE if the jack_port_t belongs to the jack_client_t.
  748. */
  749. int jack_port_is_mine (const jack_client_t *client, const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
  750. /**
  751. * @return number of connections to or from @a port.
  752. *
  753. * @pre The calling client must own @a port.
  754. */
  755. int jack_port_connected (const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
  756. /**
  757. * @return TRUE if the locally-owned @a port is @b directly connected
  758. * to the @a port_name.
  759. *
  760. * @see jack_port_name_size()
  761. */
  762. int jack_port_connected_to (const jack_port_t *port,
  763. const char *port_name) JACK_OPTIONAL_WEAK_EXPORT;
  764. /**
  765. * @return a null-terminated array of full port names to which the @a
  766. * port is connected. If none, returns NULL.
  767. *
  768. * The caller is responsible for calling jack_free() on any non-NULL
  769. * returned value.
  770. *
  771. * @param port locally owned jack_port_t pointer.
  772. *
  773. * @see jack_port_name_size(), jack_port_get_all_connections()
  774. */
  775. const char ** jack_port_get_connections (const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
  776. /**
  777. * @return a null-terminated array of full port names to which the @a
  778. * port is connected. If none, returns NULL.
  779. *
  780. * The caller is responsible for calling jack_free() on any non-NULL
  781. * returned value.
  782. *
  783. * This differs from jack_port_get_connections() in two important
  784. * respects:
  785. *
  786. * 1) You may not call this function from code that is
  787. * executed in response to a JACK event. For example,
  788. * you cannot use it in a GraphReordered handler.
  789. *
  790. * 2) You need not be the owner of the port to get information
  791. * about its connections.
  792. *
  793. * @see jack_port_name_size()
  794. */
  795. const char ** jack_port_get_all_connections (const jack_client_t *client,
  796. const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
  797. /**
  798. *
  799. * @deprecated This function will be removed from a future version
  800. * of JACK. Do not use it. There is no replacement. It has
  801. * turned out to serve essentially no purpose in real-life
  802. * JACK clients.
  803. */
  804. int jack_port_tie (jack_port_t *src, jack_port_t *dst) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
  805. /**
  806. *
  807. * @deprecated This function will be removed from a future version
  808. * of JACK. Do not use it. There is no replacement. It has
  809. * turned out to serve essentially no purpose in real-life
  810. * JACK clients.
  811. */
  812. int jack_port_untie (jack_port_t *port) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
  813. /**
  814. * \bold THIS FUNCTION IS DEPRECATED AND SHOULD NOT BE USED IN
  815. * NEW JACK CLIENTS
  816. *
  817. * Modify a port's short name. May be called at any time. If the
  818. * resulting full name (including the @a "client_name:" prefix) is
  819. * longer than jack_port_name_size(), it will be truncated.
  820. *
  821. * @return 0 on success, otherwise a non-zero error code.
  822. */
  823. int jack_port_set_name (jack_port_t *port, const char *port_name) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
  824. /**
  825. * Modify a port's short name. May NOT be called from a callback handling a server event.
  826. * If the resulting full name (including the @a "client_name:" prefix) is
  827. * longer than jack_port_name_size(), it will be truncated.
  828. *
  829. * @return 0 on success, otherwise a non-zero error code.
  830. *
  831. * This differs from jack_port_set_name() by triggering PortRename notifications to
  832. * clients that have registered a port rename handler.
  833. */
  834. int jack_port_rename (jack_client_t* client, jack_port_t *port, const char *port_name) JACK_OPTIONAL_WEAK_EXPORT;
  835. /**
  836. * Set @a alias as an alias for @a port. May be called at any time.
  837. * If the alias is longer than jack_port_name_size(), it will be truncated.
  838. *
  839. * After a successful call, and until JACK exits or
  840. * @function jack_port_unset_alias() is called, @alias may be
  841. * used as a alternate name for the port.
  842. *
  843. * Ports can have up to two aliases - if both are already
  844. * set, this function will return an error.
  845. *
  846. * @return 0 on success, otherwise a non-zero error code.
  847. */
  848. int jack_port_set_alias (jack_port_t *port, const char *alias) JACK_OPTIONAL_WEAK_EXPORT;
  849. /**
  850. * Remove @a alias as an alias for @a port. May be called at any time.
  851. *
  852. * After a successful call, @a alias can no longer be
  853. * used as a alternate name for the port.
  854. *
  855. * @return 0 on success, otherwise a non-zero error code.
  856. */
  857. int jack_port_unset_alias (jack_port_t *port, const char *alias) JACK_OPTIONAL_WEAK_EXPORT;
  858. /**
  859. * Get any aliases known for @port.
  860. *
  861. * @return the number of aliases discovered for the port
  862. */
  863. int jack_port_get_aliases (const jack_port_t *port, char* const aliases[2]) JACK_OPTIONAL_WEAK_EXPORT;
  864. /**
  865. * If @ref JackPortCanMonitor is set for this @a port, turn input
  866. * monitoring on or off. Otherwise, do nothing.
  867. */
  868. int jack_port_request_monitor (jack_port_t *port, int onoff) JACK_OPTIONAL_WEAK_EXPORT;
  869. /**
  870. * If @ref JackPortCanMonitor is set for this @a port_name, turn input
  871. * monitoring on or off. Otherwise, do nothing.
  872. *
  873. * @return 0 on success, otherwise a non-zero error code.
  874. *
  875. * @see jack_port_name_size()
  876. */
  877. int jack_port_request_monitor_by_name (jack_client_t *client,
  878. const char *port_name, int onoff) JACK_OPTIONAL_WEAK_EXPORT;
  879. /**
  880. * If @ref JackPortCanMonitor is set for a port, this function turns
  881. * on input monitoring if it was off, and turns it off if only one
  882. * request has been made to turn it on. Otherwise it does nothing.
  883. *
  884. * @return 0 on success, otherwise a non-zero error code
  885. */
  886. int jack_port_ensure_monitor (jack_port_t *port, int onoff) JACK_OPTIONAL_WEAK_EXPORT;
  887. /**
  888. * @return TRUE if input monitoring has been requested for @a port.
  889. */
  890. int jack_port_monitoring_input (jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
  891. /**
  892. * Establish a connection between two ports.
  893. *
  894. * When a connection exists, data written to the source port will
  895. * be available to be read at the destination port.
  896. *
  897. * @pre The port types must be identical.
  898. *
  899. * @pre The @ref JackPortFlags of the @a source_port must include @ref
  900. * JackPortIsOutput.
  901. *
  902. * @pre The @ref JackPortFlags of the @a destination_port must include
  903. * @ref JackPortIsInput.
  904. *
  905. * @return 0 on success, EEXIST if the connection is already made,
  906. * otherwise a non-zero error code
  907. */
  908. int jack_connect (jack_client_t *client,
  909. const char *source_port,
  910. const char *destination_port) JACK_OPTIONAL_WEAK_EXPORT;
  911. /**
  912. * Remove a connection between two ports.
  913. *
  914. * @pre The port types must be identical.
  915. *
  916. * @pre The @ref JackPortFlags of the @a source_port must include @ref
  917. * JackPortIsOutput.
  918. *
  919. * @pre The @ref JackPortFlags of the @a destination_port must include
  920. * @ref JackPortIsInput.
  921. *
  922. * @return 0 on success, otherwise a non-zero error code
  923. */
  924. int jack_disconnect (jack_client_t *client,
  925. const char *source_port,
  926. const char *destination_port) JACK_OPTIONAL_WEAK_EXPORT;
  927. /**
  928. * Perform the same function as jack_disconnect() using port handles
  929. * rather than names. This avoids the name lookup inherent in the
  930. * name-based version.
  931. *
  932. * Clients connecting their own ports are likely to use this function,
  933. * while generic connection clients (e.g. patchbays) would use
  934. * jack_disconnect().
  935. */
  936. int jack_port_disconnect (jack_client_t *client, jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
  937. /**
  938. * @return the maximum number of characters in a full JACK port name
  939. * including the final NULL character. This value is a constant.
  940. *
  941. * A port's full name contains the owning client name concatenated
  942. * with a colon (:) followed by its short name and a NULL
  943. * character.
  944. */
  945. int jack_port_name_size(void) JACK_OPTIONAL_WEAK_EXPORT;
  946. /**
  947. * @return the maximum number of characters in a JACK port type name
  948. * including the final NULL character. This value is a constant.
  949. */
  950. int jack_port_type_size(void) JACK_OPTIONAL_WEAK_EXPORT;
  951. /**
  952. * @return the buffersize of a port of type @arg port_type.
  953. *
  954. * this function may only be called in a buffer_size callback.
  955. */
  956. size_t jack_port_type_get_buffer_size (jack_client_t *client, const char *port_type) JACK_WEAK_EXPORT;
  957. /*@}*/
  958. /**
  959. * @defgroup LatencyFunctions Managing and determining latency
  960. *
  961. * The purpose of JACK's latency API is to allow clients to
  962. * easily answer two questions:
  963. *
  964. * - How long has it been since the data read from a port arrived
  965. * at the edge of the JACK graph (either via a physical port
  966. * or being synthesized from scratch)?
  967. *
  968. * - How long will it be before the data written to a port arrives
  969. * at the edge of a JACK graph?
  970. * To help answering these two questions, all JACK ports have two
  971. * latency values associated with them, both measured in frames:
  972. *
  973. * <b>capture latency</b>: how long since the data read from
  974. * the buffer of a port arrived at
  975. * a port marked with JackPortIsTerminal.
  976. * The data will have come from the "outside
  977. * world" if the terminal port is also
  978. * marked with JackPortIsPhysical, or
  979. * will have been synthesized by the client
  980. * that owns the terminal port.
  981. *
  982. * <b>playback latency</b>: how long until the data
  983. * written to the buffer of port will reach a port
  984. * marked with JackPortIsTerminal.
  985. *
  986. * Both latencies might potentially have more than one value
  987. * because there may be multiple pathways to/from a given port
  988. * and a terminal port. Latency is therefore generally
  989. * expressed a min/max pair.
  990. *
  991. * In most common setups, the minimum and maximum latency
  992. * are the same, but this design accomodates more complex
  993. * routing, and allows applications (and thus users) to
  994. * detect cases where routing is creating an anomalous
  995. * situation that may either need fixing or more
  996. * sophisticated handling by clients that care about
  997. * latency.
  998. *
  999. * See also @ref jack_set_latency_callback for details on how
  1000. * clients that add latency to the signal path should interact
  1001. * with JACK to ensure that the correct latency figures are
  1002. * used.
  1003. * @{
  1004. */
  1005. /**
  1006. * The port latency is zero by default. Clients that control
  1007. * physical hardware with non-zero latency should call this
  1008. * to set the latency to its correct value. Note that the value
  1009. * should include any systemic latency present "outside" the
  1010. * physical hardware controlled by the client. For example,
  1011. * for a client controlling a digital audio interface connected
  1012. * to an external digital converter, the latency setting should
  1013. * include both buffering by the audio interface *and* the converter.
  1014. *
  1015. * @deprecated This method will be removed in the next major
  1016. * release of JACK. It should not be used in new code, and should
  1017. * be replaced by a latency callback that calls @ref
  1018. * jack_port_set_latency_range().
  1019. */
  1020. void jack_port_set_latency (jack_port_t *port, jack_nframes_t) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
  1021. /**
  1022. * return the latency range defined by @a mode for
  1023. * @a port, in frames.
  1024. *
  1025. * See @ref LatencyFunctions for the definition of each latency value.
  1026. *
  1027. * This is normally used in the LatencyCallback.
  1028. * and therefor safe to execute from callbacks.
  1029. */
  1030. void jack_port_get_latency_range (jack_port_t *port, jack_latency_callback_mode_t mode, jack_latency_range_t *range) JACK_WEAK_EXPORT;
  1031. /**
  1032. * set the minimum and maximum latencies defined by
  1033. * @a mode for @a port, in frames.
  1034. *
  1035. * See @ref LatencyFunctions for the definition of each latency value.
  1036. *
  1037. * This function should ONLY be used inside a latency
  1038. * callback. The client should determine the current
  1039. * value of the latency using @ref jack_port_get_latency_range()
  1040. * (called using the same mode as @a mode)
  1041. * and then add some number of frames to that reflects
  1042. * latency added by the client.
  1043. *
  1044. * How much latency a client adds will vary
  1045. * dramatically. For most clients, the answer is zero
  1046. * and there is no reason for them to register a latency
  1047. * callback and thus they should never call this
  1048. * function.
  1049. *
  1050. * More complex clients that take an input signal,
  1051. * transform it in some way and output the result but
  1052. * not during the same process() callback will
  1053. * generally know a single constant value to add
  1054. * to the value returned by @ref jack_port_get_latency_range().
  1055. *
  1056. * Such clients would register a latency callback (see
  1057. * @ref jack_set_latency_callback) and must know what input
  1058. * ports feed which output ports as part of their
  1059. * internal state. Their latency callback will update
  1060. * the ports' latency values appropriately.
  1061. *
  1062. * A pseudo-code example will help. The @a mode argument to the latency
  1063. * callback will determine whether playback or capture
  1064. * latency is being set. The callback will use
  1065. * @ref jack_port_set_latency_range() as follows:
  1066. *
  1067. * \code
  1068. * jack_latency_range_t range;
  1069. * if (mode == JackPlaybackLatency) {
  1070. * foreach input_port in (all self-registered port) {
  1071. * jack_port_get_latency_range (port_feeding_input_port, JackPlaybackLatency, &range);
  1072. * range.min += min_delay_added_as_signal_flows_from port_feeding to input_port;
  1073. * range.max += max_delay_added_as_signal_flows_from port_feeding to input_port;
  1074. * jack_port_set_latency_range (input_port, JackPlaybackLatency, &range);
  1075. * }
  1076. * } else if (mode == JackCaptureLatency) {
  1077. * foreach output_port in (all self-registered port) {
  1078. * jack_port_get_latency_range (port_fed_by_output_port, JackCaptureLatency, &range);
  1079. * range.min += min_delay_added_as_signal_flows_from_output_port_to_fed_by_port;
  1080. * range.max += max_delay_added_as_signal_flows_from_output_port_to_fed_by_port;
  1081. * jack_port_set_latency_range (output_port, JackCaptureLatency, &range);
  1082. * }
  1083. * }
  1084. * \endcode
  1085. *
  1086. * In this relatively simple pseudo-code example, it is assumed that
  1087. * each input port or output is connected to only 1 output or input
  1088. * port respectively.
  1089. *
  1090. * If a port is connected to more than 1 other port, then the
  1091. * range.min and range.max values passed to @ref
  1092. * jack_port_set_latency_range() should reflect the minimum and
  1093. * maximum values across all connected ports.
  1094. *
  1095. * See the description of @ref jack_set_latency_callback for more
  1096. * information.
  1097. */
  1098. void jack_port_set_latency_range (jack_port_t *port, jack_latency_callback_mode_t mode, jack_latency_range_t *range) JACK_WEAK_EXPORT;
  1099. /**
  1100. * Request a complete recomputation of all port latencies. This
  1101. * can be called by a client that has just changed the internal
  1102. * latency of its port using jack_port_set_latency
  1103. * and wants to ensure that all signal pathways in the graph
  1104. * are updated with respect to the values that will be returned
  1105. * by jack_port_get_total_latency. It allows a client
  1106. * to change multiple port latencies without triggering a
  1107. * recompute for each change.
  1108. *
  1109. * @return zero for successful execution of the request. non-zero
  1110. * otherwise.
  1111. */
  1112. int jack_recompute_total_latencies (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT;
  1113. /**
  1114. * @return the time (in frames) between data being available or
  1115. * delivered at/to a port, and the time at which it arrived at or is
  1116. * delivered to the "other side" of the port. E.g. for a physical
  1117. * audio output port, this is the time between writing to the port and
  1118. * when the signal will leave the connector. For a physical audio
  1119. * input port, this is the time between the sound arriving at the
  1120. * connector and the corresponding frames being readable from the
  1121. * port.
  1122. *
  1123. * @deprecated This method will be removed in the next major
  1124. * release of JACK. It should not be used in new code, and should
  1125. * be replaced by jack_port_get_latency_range() in any existing
  1126. * use cases.
  1127. */
  1128. jack_nframes_t jack_port_get_latency (jack_port_t *port) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
  1129. /**
  1130. * The maximum of the sum of the latencies in every
  1131. * connection path that can be drawn between the port and other
  1132. * ports with the @ref JackPortIsTerminal flag set.
  1133. *
  1134. * @deprecated This method will be removed in the next major
  1135. * release of JACK. It should not be used in new code, and should
  1136. * be replaced by jack_port_get_latency_range() in any existing
  1137. * use cases.
  1138. */
  1139. jack_nframes_t jack_port_get_total_latency (jack_client_t *client,
  1140. jack_port_t *port) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
  1141. /**
  1142. * Request a complete recomputation of a port's total latency. This
  1143. * can be called by a client that has just changed the internal
  1144. * latency of its port using jack_port_set_latency
  1145. * and wants to ensure that all signal pathways in the graph
  1146. * are updated with respect to the values that will be returned
  1147. * by jack_port_get_total_latency.
  1148. *
  1149. * @return zero for successful execution of the request. non-zero
  1150. * otherwise.
  1151. *
  1152. * @deprecated This method will be removed in the next major
  1153. * release of JACK. It should not be used in new code, and should
  1154. * be replaced by jack_recompute_total_latencies() in any existing
  1155. * use cases.
  1156. */
  1157. int jack_recompute_total_latency (jack_client_t*, jack_port_t* port) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
  1158. /*@}*/
  1159. /**
  1160. * @defgroup PortSearching Looking up ports
  1161. * @{
  1162. */
  1163. /**
  1164. * @param port_name_pattern A regular expression used to select
  1165. * ports by name. If NULL or of zero length, no selection based
  1166. * on name will be carried out.
  1167. * @param type_name_pattern A regular expression used to select
  1168. * ports by type. If NULL or of zero length, no selection based
  1169. * on type will be carried out.
  1170. * @param flags A value used to select ports by their flags.
  1171. * If zero, no selection based on flags will be carried out.
  1172. *
  1173. * @return a NULL-terminated array of ports that match the specified
  1174. * arguments. The caller is responsible for calling jack_free() any
  1175. * non-NULL returned value.
  1176. *
  1177. * @see jack_port_name_size(), jack_port_type_size()
  1178. */
  1179. const char ** jack_get_ports (jack_client_t *client,
  1180. const char *port_name_pattern,
  1181. const char *type_name_pattern,
  1182. unsigned long flags) JACK_OPTIONAL_WEAK_EXPORT;
  1183. /**
  1184. * @return address of the jack_port_t named @a port_name.
  1185. *
  1186. * @see jack_port_name_size()
  1187. */
  1188. jack_port_t * jack_port_by_name (jack_client_t *client, const char *port_name) JACK_OPTIONAL_WEAK_EXPORT;
  1189. /**
  1190. * @return address of the jack_port_t of a @a port_id.
  1191. */
  1192. jack_port_t * jack_port_by_id (jack_client_t *client,
  1193. jack_port_id_t port_id) JACK_OPTIONAL_WEAK_EXPORT;
  1194. /*@}*/
  1195. /**
  1196. * @defgroup TimeFunctions Handling time
  1197. * @{
  1198. *
  1199. * JACK time is in units of 'frames', according to the current sample rate.
  1200. * The absolute value of frame times is meaningless, frame times have meaning
  1201. * only relative to each other.
  1202. */
  1203. /**
  1204. * @return the estimated time in frames that has passed since the JACK
  1205. * server began the current process cycle.
  1206. */
  1207. jack_nframes_t jack_frames_since_cycle_start (const jack_client_t *) JACK_OPTIONAL_WEAK_EXPORT;
  1208. /**
  1209. * @return the estimated current time in frames.
  1210. * This function is intended for use in other threads (not the process
  1211. * callback). The return value can be compared with the value of
  1212. * jack_last_frame_time to relate time in other threads to JACK time.
  1213. */
  1214. jack_nframes_t jack_frame_time (const jack_client_t *) JACK_OPTIONAL_WEAK_EXPORT;
  1215. /**
  1216. * @return the precise time at the start of the current process cycle.
  1217. * This function may only be used from the process callback, and can
  1218. * be used to interpret timestamps generated by jack_frame_time() in
  1219. * other threads with respect to the current process cycle.
  1220. *
  1221. * This is the only jack time function that returns exact time:
  1222. * when used during the process callback it always returns the same
  1223. * value (until the next process callback, where it will return
  1224. * that value + nframes, etc). The return value is guaranteed to be
  1225. * monotonic and linear in this fashion unless an xrun occurs.
  1226. * If an xrun occurs, clients must check this value again, as time
  1227. * may have advanced in a non-linear way (e.g. cycles may have been skipped).
  1228. */
  1229. jack_nframes_t jack_last_frame_time (const jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT;
  1230. /**
  1231. * This function may only be used from the process callback.
  1232. * It provides the internal cycle timing information as used by
  1233. * most of the other time related functions. This allows the
  1234. * caller to map between frame counts and microseconds with full
  1235. * precision (i.e. without rounding frame times to integers),
  1236. * and also provides e.g. the microseconds time of the start of
  1237. * the current cycle directly (it has to be computed otherwise).
  1238. *
  1239. * If the return value is zero, the following information is
  1240. * provided in the variables pointed to by the arguments:
  1241. *
  1242. * current_frames: the frame time counter at the start of the
  1243. * current cycle, same as jack_last_frame_time().
  1244. * current_usecs: the microseconds time at the start of the
  1245. * current cycle.
  1246. * next_usecs: the microseconds time of the start of the next
  1247. * next cycle as computed by the DLL.
  1248. * period_usecs: the current best estimate of the period time in
  1249. * microseconds.
  1250. *
  1251. * NOTES:
  1252. *
  1253. * Because of the types used, all the returned values except period_usecs
  1254. * are unsigned. In computations mapping between frames and microseconds
  1255. * *signed* differences are required. The easiest way is to compute those
  1256. * separately and assign them to the appropriate signed variables,
  1257. * int32_t for frames and int64_t for usecs. See the implementation of
  1258. * jack_frames_to_time() and Jack_time_to_frames() for an example.
  1259. *
  1260. * Unless there was an xrun, skipped cycles, or the current cycle is the
  1261. * first after freewheeling or starting Jack, the value of current_usecs
  1262. * will always be the value of next_usecs of the previous cycle.
  1263. *
  1264. * The value of period_usecs will in general NOT be exactly equal to
  1265. * the difference of next_usecs and current_usecs. This is because to
  1266. * ensure stability of the DLL and continuity of the mapping, a fraction
  1267. * of the loop error must be included in next_usecs. For an accurate
  1268. * mapping between frames and microseconds, the difference of next_usecs
  1269. * and current_usecs should be used, and not period_usecs.
  1270. *
  1271. * @return zero if OK, non-zero otherwise.
  1272. */
  1273. int jack_get_cycle_times(const jack_client_t *client,
  1274. jack_nframes_t *current_frames,
  1275. jack_time_t *current_usecs,
  1276. jack_time_t *next_usecs,
  1277. float *period_usecs) JACK_OPTIONAL_WEAK_EXPORT;
  1278. /**
  1279. * @return the estimated time in microseconds of the specified frame time
  1280. */
  1281. jack_time_t jack_frames_to_time(const jack_client_t *client, jack_nframes_t) JACK_OPTIONAL_WEAK_EXPORT;
  1282. /**
  1283. * @return the estimated time in frames for the specified system time.
  1284. */
  1285. jack_nframes_t jack_time_to_frames(const jack_client_t *client, jack_time_t) JACK_OPTIONAL_WEAK_EXPORT;
  1286. /**
  1287. * @return return JACK's current system time in microseconds,
  1288. * using the JACK clock source.
  1289. *
  1290. * The value returned is guaranteed to be monotonic, but not linear.
  1291. */
  1292. jack_time_t jack_get_time() JACK_OPTIONAL_WEAK_EXPORT;
  1293. /*@}*/
  1294. /**
  1295. * @defgroup ErrorOutput Controlling error/information output
  1296. */
  1297. /*@{*/
  1298. /**
  1299. * Display JACK error message.
  1300. *
  1301. * Set via jack_set_error_function(), otherwise a JACK-provided
  1302. * default will print @a msg (plus a newline) to stderr.
  1303. *
  1304. * @param msg error message text (no newline at end).
  1305. */
  1306. extern void (*jack_error_callback)(const char *msg) JACK_OPTIONAL_WEAK_EXPORT;
  1307. /**
  1308. * Set the @ref jack_error_callback for error message display.
  1309. * Set it to NULL to restore default_jack_error_callback function.
  1310. *
  1311. * The JACK library provides two built-in callbacks for this purpose:
  1312. * default_jack_error_callback() and silent_jack_error_callback().
  1313. */
  1314. void jack_set_error_function (void (*func)(const char *)) JACK_OPTIONAL_WEAK_EXPORT;
  1315. /**
  1316. * Display JACK info message.
  1317. *
  1318. * Set via jack_set_info_function(), otherwise a JACK-provided
  1319. * default will print @a msg (plus a newline) to stdout.
  1320. *
  1321. * @param msg info message text (no newline at end).
  1322. */
  1323. extern void (*jack_info_callback)(const char *msg) JACK_OPTIONAL_WEAK_EXPORT;
  1324. /**
  1325. * Set the @ref jack_info_callback for info message display.
  1326. * Set it to NULL to restore default_jack_info_callback function.
  1327. *
  1328. * The JACK library provides two built-in callbacks for this purpose:
  1329. * default_jack_info_callback() and silent_jack_info_callback().
  1330. */
  1331. void jack_set_info_function (void (*func)(const char *)) JACK_OPTIONAL_WEAK_EXPORT;
  1332. /*@}*/
  1333. /**
  1334. * The free function to be used on memory returned by jack_port_get_connections,
  1335. * jack_port_get_all_connections, jack_get_ports and jack_get_internal_client_name functions.
  1336. * This is MANDATORY on Windows when otherwise all nasty runtime version related crashes can occur.
  1337. * Developers are strongly encouraged to use this function instead of the standard "free" function in new code.
  1338. *
  1339. * @param ptr the memory pointer to be deallocated.
  1340. */
  1341. void jack_free(void* ptr) JACK_OPTIONAL_WEAK_EXPORT;
  1342. #ifdef __cplusplus
  1343. }
  1344. #endif
  1345. #endif /* __jack_h__ */