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.

1425 lines
53KB

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