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.

987 lines
36KB

  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. #ifdef WIN32
  23. #include <windows.h>
  24. typedef HANDLE pthread_t;
  25. #else
  26. #include <pthread.h>
  27. #endif
  28. #include <jack/types.h>
  29. #include <jack/transport.h>
  30. /**
  31. * Note: More documentation can be found in jack/types.h.
  32. */
  33. /**
  34. * Call this function to get version of the JACK, in form of several numbers
  35. *
  36. * @param major_ptr pointer to variable receiving major version of JACK.
  37. *
  38. * @param minor_ptr pointer to variable receiving minor version of JACK.
  39. *
  40. * @param major_ptr pointer to variable receiving micro version of JACK.
  41. *
  42. * @param major_ptr pointer to variable receiving protocol version of JACK.
  43. *
  44. */
  45. void
  46. jack_get_version(
  47. int *major_ptr,
  48. int *minor_ptr,
  49. int *micro_ptr,
  50. int *proto_ptr);
  51. /**
  52. * Call this function to get version of the JACK, in form of a string
  53. *
  54. * @return Human readable string describing JACK version being used.
  55. *
  56. */
  57. const char *
  58. jack_get_version_string();
  59. /**
  60. * Open an external client session with a JACK server. This interface
  61. * is more complex but more powerful than jack_client_new(). With it,
  62. * clients may choose which of several servers to connect, and control
  63. * whether and how to start the server automatically, if it was not
  64. * already running. There is also an option for JACK to generate a
  65. * unique client name, when necessary.
  66. *
  67. * @param client_name of at most jack_client_name_size() characters.
  68. * The name scope is local to each server. Unless forbidden by the
  69. * @ref JackUseExactName option, the server will modify this name to
  70. * create a unique variant, if needed.
  71. *
  72. * @param options formed by OR-ing together @ref JackOptions bits.
  73. * Only the @ref JackOpenOptions bits are allowed.
  74. *
  75. * @param status (if non-NULL) an address for JACK to return
  76. * information from the open operation. This status word is formed by
  77. * OR-ing together the relevant @ref JackStatus bits.
  78. *
  79. *
  80. * <b>Optional parameters:</b> depending on corresponding [@a options
  81. * bits] additional parameters may follow @a status (in this order).
  82. *
  83. * @arg [@ref JackServerName] <em>(char *) server_name</em> selects
  84. * from among several possible concurrent server instances. Server
  85. * names are unique to each user. If unspecified, use "default"
  86. * unless \$JACK_DEFAULT_SERVER is defined in the process environment.
  87. *
  88. * @return Opaque client handle if successful. If this is NULL, the
  89. * open operation failed, @a *status includes @ref JackFailure and the
  90. * caller is not a JACK client.
  91. */
  92. jack_client_t * jack_client_open (const char *client_name,
  93. jack_options_t options,
  94. jack_status_t *status, ...);
  95. /**
  96. * \bold THIS FUNCTION IS DEPRECATED AND SHOULD NOT BE USED IN
  97. * NEW JACK CLIENTS
  98. *
  99. */
  100. jack_client_t * jack_client_new (const char *client_name);
  101. /**
  102. * Disconnects an external client from a JACK server.
  103. *
  104. * @return 0 on success, otherwise a non-zero error code
  105. */
  106. int jack_client_close (jack_client_t *client);
  107. /**
  108. * @return the maximum number of characters in a JACK client name
  109. * including the final NULL character. This value is a constant.
  110. */
  111. int jack_client_name_size (void);
  112. /**
  113. * @return pointer to actual client name. This is useful when @ref
  114. * JackUseExactName is not specified on open and @ref
  115. * JackNameNotUnique status was returned. In that case, the actual
  116. * name will differ from the @a client_name requested.
  117. */
  118. char * jack_get_client_name (jack_client_t *client);
  119. /**
  120. * @return pid of client. If not available, 0 will be returned.
  121. */
  122. int jack_get_client_pid (const char *name);
  123. /**
  124. * Load an internal client into the Jack server.
  125. *
  126. * Internal clients run inside the JACK server process. They can use
  127. * most of the same functions as external clients. Each internal
  128. * client must declare jack_initialize() and jack_finish() entry
  129. * points, called at load and unload times. See inprocess.c for an
  130. * example of how to write an internal client.
  131. *
  132. * @deprecated Please use jack_internal_client_load().
  133. *
  134. * @param client_name of at most jack_client_name_size() characters.
  135. *
  136. * @param load_name of a shared object file containing the code for
  137. * the new client.
  138. *
  139. * @param load_init an arbitary string passed to the jack_initialize()
  140. * routine of the new client (may be NULL).
  141. *
  142. * @return 0 if successful.
  143. */
  144. int jack_internal_client_new (const char *client_name,
  145. const char *load_name,
  146. const char *load_init);
  147. /**
  148. * Remove an internal client from a JACK server.
  149. *
  150. * @deprecated Please use jack_internal_client_load().
  151. */
  152. void jack_internal_client_close (const char *client_name);
  153. /**
  154. * @param client pointer to JACK client structure.
  155. *
  156. * Check if the JACK subsystem is running with -R (--realtime).
  157. *
  158. * @return 1 if JACK is running realtime, 0 otherwise
  159. */
  160. int jack_is_realtime (jack_client_t *client);
  161. /**
  162. * @param client pointer to JACK client structure.
  163. * @param function The jack_shutdown function pointer.
  164. * @param arg The arguments for the jack_shutdown function.
  165. *
  166. * Register a function (and argument) to be called if and when the
  167. * JACK server shuts down the client thread. The function must
  168. * be written as if it were an asynchonrous POSIX signal
  169. * handler --- use only async-safe functions, and remember that it
  170. * is executed from another thread. A typical function might
  171. * set a flag or write to a pipe so that the rest of the
  172. * application knows that the JACK client thread has shut
  173. * down.
  174. *
  175. * NOTE: clients do not need to call this. It exists only
  176. * to help more complex clients understand what is going
  177. * on. It should be called before jack_client_activate().
  178. */
  179. void jack_on_shutdown (jack_client_t *client,
  180. void (*function)(void *arg), void *arg);
  181. /**
  182. * Tell the Jack server to call @a process_callback whenever there is
  183. * work be done, passing @a arg as the second argument.
  184. *
  185. * The code in the supplied function must be suitable for real-time
  186. * execution. That means that it cannot call functions that might
  187. * block for a long time. This includes malloc, free, printf,
  188. * pthread_mutex_lock, sleep, wait, poll, select, pthread_join,
  189. * pthread_cond_wait, etc, etc. See
  190. * http://jackit.sourceforge.net/docs/design/design.html#SECTION00411000000000000000
  191. * for more information.
  192. *
  193. * @return 0 on success, otherwise a non-zero error code.
  194. */
  195. int jack_set_process_callback (jack_client_t *client,
  196. JackProcessCallback process_callback,
  197. void *arg);
  198. /**
  199. * \bold THIS FUNCTION IS DEPRECATED AND SHOULD NOT BE USED IN
  200. * NEW JACK CLIENTS.
  201. *
  202. * It should be replace by use of @ jack_cycle_wait and @ jack_cycle_signal functions.
  203. *
  204. */
  205. jack_nframes_t jack_thread_wait (jack_client_t*, int status);
  206. /**
  207. * Wait until this JACK client should process data.
  208. *
  209. * @param client - pointer to a JACK client structure
  210. *
  211. * @return the number of frames of data to process
  212. */
  213. jack_nframes_t jack_cycle_wait (jack_client_t* client);
  214. /**
  215. * Signal next clients in the graph.
  216. *
  217. * @param client - pointer to a JACK client structure
  218. * @param status - if non-zero, calling thread should exit
  219. */
  220. void jack_cycle_signal (jack_client_t* client, int status);
  221. /**
  222. * Tell the Jack server to call @a thread_callback in the RT thread.
  223. * Typical use are in conjunction with @a jack_cycle_wait and @ jack_cycle_signal functions.
  224. * The code in the supplied function must be suitable for real-time
  225. * execution. That means that it cannot call functions that might
  226. * block for a long time. This includes malloc, free, printf,
  227. * pthread_mutex_lock, sleep, wait, poll, select, pthread_join,
  228. * pthread_cond_wait, etc, etc. See
  229. * http://jackit.sourceforge.net/docs/design/design.html#SECTION00411000000000000000
  230. * for more information.
  231. *
  232. * @return 0 on success, otherwise a non-zero error code.
  233. */
  234. int jack_set_process_thread(jack_client_t* client, JackThreadCallback thread_callback, void *arg);
  235. /**
  236. * Tell JACK to call @a thread_init_callback once just after
  237. * the creation of the thread in which all other callbacks
  238. * will be handled.
  239. *
  240. * The code in the supplied function does not need to be
  241. * suitable for real-time execution.
  242. *
  243. * @return 0 on success, otherwise a non-zero error code, causing JACK
  244. * to remove that client from the process() graph.
  245. */
  246. int jack_set_thread_init_callback (jack_client_t *client,
  247. JackThreadInitCallback thread_init_callback,
  248. void *arg);
  249. /**
  250. * Tell the Jack server to call @a freewheel_callback
  251. * whenever we enter or leave "freewheel" mode, passing @a
  252. * arg as the second argument. The first argument to the
  253. * callback will be non-zero if JACK is entering freewheel
  254. * mode, and zero otherwise.
  255. *
  256. * All "notification events" are received in a seperated non RT thread,
  257. * the code in the supplied function does not need to be
  258. * suitable for real-time execution.
  259. *
  260. * @return 0 on success, otherwise a non-zero error code.
  261. */
  262. int jack_set_freewheel_callback (jack_client_t *client,
  263. JackFreewheelCallback freewheel_callback,
  264. void *arg);
  265. /**
  266. * Start/Stop JACK's "freewheel" mode.
  267. *
  268. * When in "freewheel" mode, JACK no longer waits for
  269. * any external event to begin the start of the next process
  270. * cycle.
  271. *
  272. * As a result, freewheel mode causes "faster than realtime"
  273. * execution of a JACK graph. If possessed, real-time
  274. * scheduling is dropped when entering freewheel mode, and
  275. * if appropriate it is reacquired when stopping.
  276. *
  277. * IMPORTANT: on systems using capabilities to provide real-time
  278. * scheduling (i.e. Linux kernel 2.4), if onoff is zero, this function
  279. * must be called from the thread that originally called jack_activate().
  280. * This restriction does not apply to other systems (e.g. Linux kernel 2.6
  281. * or OS X).
  282. *
  283. * @param client pointer to JACK client structure
  284. * @param onoff if non-zero, freewheel mode starts. Otherwise
  285. * freewheel mode ends.
  286. *
  287. * @return 0 on success, otherwise a non-zero error code.
  288. */
  289. int jack_set_freewheel(jack_client_t* client, int onoff);
  290. /**
  291. * Change the buffer size passed to the @a process_callback.
  292. *
  293. * This operation stops the JACK engine process cycle, then calls all
  294. * registered @a bufsize_callback functions before restarting the
  295. * process cycle. This will cause a gap in the audio flow, so it
  296. * should only be done at appropriate stopping points.
  297. *
  298. * @see jack_set_buffer_size_callback()
  299. *
  300. * @param client pointer to JACK client structure.
  301. * @param nframes new buffer size. Must be a power of two.
  302. *
  303. * @return 0 on success, otherwise a non-zero error code
  304. */
  305. int jack_set_buffer_size (jack_client_t *client, jack_nframes_t nframes);
  306. /**
  307. * Tell JACK to call @a bufsize_callback whenever the size of the the
  308. * buffer that will be passed to the @a process_callback is about to
  309. * change. Clients that depend on knowing the buffer size must supply
  310. * a @a bufsize_callback before activating themselves.
  311. *
  312. * All "notification events" are received in a seperated non RT thread,
  313. * the code in the supplied function does not need to be
  314. * suitable for real-time execution.
  315. *
  316. * @param client pointer to JACK client structure.
  317. * @param bufsize_callback function to call when the buffer size changes.
  318. * @param arg argument for @a bufsize_callback.
  319. *
  320. * @return 0 on success, otherwise a non-zero error code
  321. */
  322. int jack_set_buffer_size_callback (jack_client_t *client,
  323. JackBufferSizeCallback bufsize_callback,
  324. void *arg);
  325. /**
  326. * Tell the Jack server to call @a srate_callback whenever the system
  327. * sample rate changes.
  328. *
  329. * All "notification events" are received in a seperated non RT thread,
  330. * the code in the supplied function does not need to be
  331. * suitable for real-time execution.
  332. *
  333. * @return 0 on success, otherwise a non-zero error code
  334. */
  335. int jack_set_sample_rate_callback (jack_client_t *client,
  336. JackSampleRateCallback srate_callback,
  337. void *arg);
  338. /**
  339. * Tell the JACK server to call @a registration_callback whenever a
  340. * port is registered or unregistered, passing @a arg as a parameter.
  341. *
  342. * All "notification events" are received in a seperated non RT thread,
  343. * the code in the supplied function does not need to be
  344. * suitable for real-time execution.
  345. *
  346. * @return 0 on success, otherwise a non-zero error code
  347. */
  348. int jack_set_client_registration_callback (jack_client_t *,
  349. JackClientRegistrationCallback
  350. registration_callback, void *arg);
  351. /**
  352. * Tell the JACK server to call @a registration_callback whenever a
  353. * port is registered or unregistered, passing @a arg as a parameter.
  354. *
  355. * All "notification events" are received in a seperated non RT thread,
  356. * the code in the supplied function does not need to be
  357. * suitable for real-time execution.
  358. *
  359. * @return 0 on success, otherwise a non-zero error code
  360. */
  361. int jack_set_port_registration_callback (jack_client_t *,
  362. JackPortRegistrationCallback
  363. registration_callback, void *arg);
  364. /**
  365. * Tell the JACK server to call @a connect_callback whenever a
  366. * port is connected or disconnected, passing @a arg as a parameter.
  367. *
  368. * All "notification events" are received in a seperated non RT thread,
  369. * the code in the supplied function does not need to be
  370. * suitable for real-time execution.
  371. *
  372. * @return 0 on success, otherwise a non-zero error code
  373. */
  374. int jack_set_port_connect_callback (jack_client_t *,
  375. JackPortConnectCallback
  376. connect_callback, void *arg);
  377. /**
  378. * Tell the JACK server to call @a graph_callback whenever the
  379. * processing graph is reordered, passing @a arg as a parameter.
  380. *
  381. * All "notification events" are received in a seperated non RT thread,
  382. * the code in the supplied function does not need to be
  383. * suitable for real-time execution.
  384. *
  385. * @return 0 on success, otherwise a non-zero error code
  386. */
  387. int jack_set_graph_order_callback (jack_client_t *,
  388. JackGraphOrderCallback graph_callback,
  389. void *);
  390. /**
  391. * Tell the JACK server to call @a xrun_callback whenever there is a
  392. * xrun, passing @a arg as a parameter.
  393. *
  394. * All "notification events" are received in a seperated non RT thread,
  395. * the code in the supplied function does not need to be
  396. * suitable for real-time execution.
  397. *
  398. * @return 0 on success, otherwise a non-zero error code
  399. */
  400. int jack_set_xrun_callback (jack_client_t *,
  401. JackXRunCallback xrun_callback, void *arg);
  402. /**
  403. * Tell the Jack server that the program is ready to start processing
  404. * audio.
  405. *
  406. * @return 0 on success, otherwise a non-zero error code
  407. */
  408. int jack_activate (jack_client_t *client);
  409. /**
  410. * Tell the Jack server to remove this @a client from the process
  411. * graph. Also, disconnect all ports belonging to it, since inactive
  412. * clients have no port connections.
  413. *
  414. * @return 0 on success, otherwise a non-zero error code
  415. */
  416. int jack_deactivate (jack_client_t *client);
  417. /**
  418. * Create a new port for the client. This is an object used for moving
  419. * data of any type in or out of the client. Ports may be connected
  420. * in various ways.
  421. *
  422. * Each port has a short name. The port's full name contains the name
  423. * of the client concatenated with a colon (:) followed by its short
  424. * name. The jack_port_name_size() is the maximum length of this full
  425. * name. Exceeding that will cause the port registration to fail and
  426. * return NULL.
  427. *
  428. * All ports have a type, which may be any non-NULL and non-zero
  429. * length string, passed as an argument. Some port types are built
  430. * into the JACK API, currently only JACK_DEFAULT_AUDIO_TYPE.
  431. *
  432. * @param client pointer to JACK client structure.
  433. * @param port_name non-empty short name for the new port (not
  434. * including the leading @a "client_name:").
  435. * @param port_type port type name. If longer than
  436. * jack_port_type_size(), only that many characters are significant.
  437. * @param flags @ref JackPortFlags bit mask.
  438. * @param buffer_size must be non-zero if this is not a built-in @a
  439. * port_type. Otherwise, it is ignored.
  440. *
  441. * @return jack_port_t pointer on success, otherwise NULL.
  442. */
  443. jack_port_t * jack_port_register (jack_client_t *client,
  444. const char *port_name,
  445. const char *port_type,
  446. unsigned long flags,
  447. unsigned long buffer_size);
  448. /**
  449. * Remove the port from the client, disconnecting any existing
  450. * connections.
  451. *
  452. * @return 0 on success, otherwise a non-zero error code
  453. */
  454. int jack_port_unregister (jack_client_t *, jack_port_t *);
  455. /**
  456. * This returns a pointer to the memory area associated with the
  457. * specified port. For an output port, it will be a memory area
  458. * that can be written to; for an input port, it will be an area
  459. * containing the data from the port's connection(s), or
  460. * zero-filled. if there are multiple inbound connections, the data
  461. * will be mixed appropriately.
  462. *
  463. * FOR OUTPUT PORTS ONLY : DEPRECATED in Jack 2.0 !!
  464. * ---------------------------------------------------
  465. * You may cache the value returned, but only between calls to
  466. * your "blocksize" callback. For this reason alone, you should
  467. * either never cache the return value or ensure you have
  468. * a "blocksize" callback and be sure to invalidate the cached
  469. * address from there.
  470. *
  471. * Caching output ports is DEPRECATED in Jack 2.0, due to some new optimization (like "pipelining").
  472. * Port buffers have to be retrieved in each callback for proper functionning.
  473. */
  474. void * jack_port_get_buffer (jack_port_t *, jack_nframes_t);
  475. /**
  476. * @return the full name of the jack_port_t (including the @a
  477. * "client_name:" prefix).
  478. *
  479. * @see jack_port_name_size().
  480. */
  481. const char * jack_port_name (const jack_port_t *port);
  482. /**
  483. * @return the short name of the jack_port_t (not including the @a
  484. * "client_name:" prefix).
  485. *
  486. * @see jack_port_name_size().
  487. */
  488. const char * jack_port_short_name (const jack_port_t *port);
  489. /**
  490. * @return the @ref JackPortFlags of the jack_port_t.
  491. */
  492. int jack_port_flags (const jack_port_t *port);
  493. /**
  494. * @return the @a port type, at most jack_port_type_size() characters
  495. * including a final NULL.
  496. */
  497. const char * jack_port_type (const jack_port_t *port);
  498. /**
  499. * @return the @a port type id.
  500. */
  501. jack_port_type_id_t jack_port_type_id (const jack_port_t *port);
  502. /**
  503. * @return TRUE if the jack_port_t belongs to the jack_client_t.
  504. */
  505. int jack_port_is_mine (const jack_client_t *, const jack_port_t *port);
  506. /**
  507. * @return number of connections to or from @a port.
  508. *
  509. * @pre The calling client must own @a port.
  510. */
  511. int jack_port_connected (const jack_port_t *port);
  512. /**
  513. * @return TRUE if the locally-owned @a port is @b directly connected
  514. * to the @a port_name.
  515. *
  516. * @see jack_port_name_size()
  517. */
  518. int jack_port_connected_to (const jack_port_t *port,
  519. const char *port_name);
  520. /**
  521. * @return a null-terminated array of full port names to which the @a
  522. * port is connected. If none, returns NULL.
  523. *
  524. * The caller is responsible for calling free(3) on any non-NULL
  525. * returned value.
  526. *
  527. * @param port locally owned jack_port_t pointer.
  528. *
  529. * @see jack_port_name_size(), jack_port_get_all_connections()
  530. */
  531. const char ** jack_port_get_connections (const jack_port_t *port);
  532. /**
  533. * @return a null-terminated array of full port names to which the @a
  534. * port is connected. If none, returns NULL.
  535. *
  536. * The caller is responsible for calling free(3) on any non-NULL
  537. * returned value.
  538. *
  539. * This differs from jack_port_get_connections() in two important
  540. * respects:
  541. *
  542. * 1) You may not call this function from code that is
  543. * executed in response to a JACK event. For example,
  544. * you cannot use it in a GraphReordered handler.
  545. *
  546. * 2) You need not be the owner of the port to get information
  547. * about its connections.
  548. *
  549. * @see jack_port_name_size()
  550. */
  551. const char ** jack_port_get_all_connections (const jack_client_t *client,
  552. const jack_port_t *port);
  553. /**
  554. * A client may call this on a pair of its own ports to
  555. * semi-permanently wire them together. This means that
  556. * a client that wants to direct-wire an input port to
  557. * an output port can call this and then no longer
  558. * have to worry about moving data between them. Any data
  559. * arriving at the input port will appear automatically
  560. * at the output port.
  561. *
  562. * The 'destination' port must be an output port. The 'source'
  563. * port must be an input port. Both ports must belong to
  564. * the same client. You cannot use this to tie ports between
  565. * clients. That is what a connection is for.
  566. *
  567. * @return 0 on success, otherwise a non-zero error code
  568. */
  569. int jack_port_tie (jack_port_t *src, jack_port_t *dst);
  570. /**
  571. * This undoes the effect of jack_port_tie(). The port
  572. * should be same as the 'destination' port passed to
  573. * jack_port_tie().
  574. *
  575. * @return 0 on success, otherwise a non-zero error code
  576. */
  577. int jack_port_untie (jack_port_t *port);
  578. /**
  579. * @return the time (in frames) between data being available or
  580. * delivered at/to a port, and the time at which it arrived at or is
  581. * delivered to the "other side" of the port. E.g. for a physical
  582. * audio output port, this is the time between writing to the port and
  583. * when the signal will leave the connector. For a physical audio
  584. * input port, this is the time between the sound arriving at the
  585. * connector and the corresponding frames being readable from the
  586. * port.
  587. */
  588. jack_nframes_t jack_port_get_latency (jack_port_t *port);
  589. /**
  590. * The maximum of the sum of the latencies in every
  591. * connection path that can be drawn between the port and other
  592. * ports with the @ref JackPortIsTerminal flag set.
  593. */
  594. jack_nframes_t jack_port_get_total_latency (jack_client_t *,
  595. jack_port_t *port);
  596. /**
  597. * The port latency is zero by default. Clients that control
  598. * physical hardware with non-zero latency should call this
  599. * to set the latency to its correct value. Note that the value
  600. * should include any systemic latency present "outside" the
  601. * physical hardware controlled by the client. For example,
  602. * for a client controlling a digital audio interface connected
  603. * to an external digital converter, the latency setting should
  604. * include both buffering by the audio interface *and* the converter.
  605. */
  606. void jack_port_set_latency (jack_port_t *, jack_nframes_t);
  607. /**
  608. * Request a complete recomputation of a port's total latency. This
  609. * can be called by a client that has just changed the internal
  610. * latency of its port using @function jack_port_set_latency
  611. * and wants to ensure that all signal pathways in the graph
  612. * are updated with respect to the values that will be returned
  613. * by @function jack_port_get_total_latency.
  614. *
  615. * @return zero for successful execution of the request. non-zero
  616. * otherwise.
  617. */
  618. int jack_recompute_total_latency (jack_client_t*, jack_port_t* port);
  619. /**
  620. * Request a complete recomputation of all port latencies. This
  621. * can be called by a client that has just changed the internal
  622. * latency of its port using @function jack_port_set_latency
  623. * and wants to ensure that all signal pathways in the graph
  624. * are updated with respect to the values that will be returned
  625. * by @function jack_port_get_total_latency. It allows a client
  626. * to change multiple port latencies without triggering a
  627. * recompute for each change.
  628. *
  629. * @return zero for successful execution of the request. non-zero
  630. * otherwise.
  631. */
  632. int jack_recompute_total_latencies (jack_client_t*);
  633. /**
  634. * Modify a port's short name. May be called at any time. If the
  635. * resulting full name (including the @a "client_name:" prefix) is
  636. * longer than jack_port_name_size(), it will be truncated.
  637. *
  638. * @return 0 on success, otherwise a non-zero error code.
  639. */
  640. int jack_port_set_name (jack_port_t *port, const char *port_name);
  641. /**
  642. * Set @a alias as an alias for @a port. May be called at any time.
  643. * If the alias is longer than jack_port_name_size(), it will be truncated.
  644. *
  645. * After a successful call, and until JACK exits or
  646. * @function jack_port_unset_alias() is called, @alias may be
  647. * used as a alternate name for the port.
  648. *
  649. * Ports can have up to two aliases - if both are already
  650. * set, this function will return an error.
  651. *
  652. * @return 0 on success, otherwise a non-zero error code.
  653. */
  654. int jack_port_set_alias (jack_port_t *port, const char *alias);
  655. /**
  656. * Remove @a alias as an alias for @a port. May be called at any time.
  657. *
  658. * After a successful call, @a alias can no longer be
  659. * used as a alternate name for the port.
  660. *
  661. * @return 0 on success, otherwise a non-zero error code.
  662. */
  663. int jack_port_unset_alias (jack_port_t *port, const char *alias);
  664. /*
  665. * Get any aliases known for @port.
  666. *
  667. * @return the number of aliases discovered for the port
  668. */
  669. int jack_port_get_aliases (const jack_port_t *port, char* const aliases[2]);
  670. /**
  671. * If @ref JackPortCanMonitor is set for this @a port, turn input
  672. * monitoring on or off. Otherwise, do nothing.
  673. */
  674. int jack_port_request_monitor (jack_port_t *port, int onoff);
  675. /**
  676. * If @ref JackPortCanMonitor is set for this @a port_name, turn input
  677. * monitoring on or off. Otherwise, do nothing.
  678. *
  679. * @return 0 on success, otherwise a non-zero error code.
  680. *
  681. * @see jack_port_name_size()
  682. */
  683. int jack_port_request_monitor_by_name (jack_client_t *client,
  684. const char *port_name, int onoff);
  685. /**
  686. * If @ref JackPortCanMonitor is set for a port, this function turns
  687. * on input monitoring if it was off, and turns it off if only one
  688. * request has been made to turn it on. Otherwise it does nothing.
  689. *
  690. * @return 0 on success, otherwise a non-zero error code
  691. */
  692. int jack_port_ensure_monitor (jack_port_t *port, int onoff);
  693. /**
  694. * @return TRUE if input monitoring has been requested for @a port.
  695. */
  696. int jack_port_monitoring_input (jack_port_t *port);
  697. /**
  698. * Establish a connection between two ports.
  699. *
  700. * When a connection exists, data written to the source port will
  701. * be available to be read at the destination port.
  702. *
  703. * @pre The port types must be identical.
  704. *
  705. * @pre The @ref JackPortFlags of the @a source_port must include @ref
  706. * JackPortIsOutput.
  707. *
  708. * @pre The @ref JackPortFlags of the @a destination_port must include
  709. * @ref JackPortIsInput.
  710. *
  711. * @return 0 on success, EEXIST if the connection is already made,
  712. * otherwise a non-zero error code
  713. */
  714. int jack_connect (jack_client_t *,
  715. const char *source_port,
  716. const char *destination_port);
  717. /**
  718. * Remove a connection between two ports.
  719. *
  720. * @pre The port types must be identical.
  721. *
  722. * @pre The @ref JackPortFlags of the @a source_port must include @ref
  723. * JackPortIsOutput.
  724. *
  725. * @pre The @ref JackPortFlags of the @a destination_port must include
  726. * @ref JackPortIsInput.
  727. *
  728. * @return 0 on success, otherwise a non-zero error code
  729. */
  730. int jack_disconnect (jack_client_t *,
  731. const char *source_port,
  732. const char *destination_port);
  733. /**
  734. * Perform the same function as jack_disconnect() using port handles
  735. * rather than names. This avoids the name lookup inherent in the
  736. * name-based version.
  737. *
  738. * Clients connecting their own ports are likely to use this function,
  739. * while generic connection clients (e.g. patchbays) would use
  740. * jack_disconnect().
  741. */
  742. int jack_port_disconnect (jack_client_t *, jack_port_t *);
  743. /**
  744. * @return the maximum number of characters in a full JACK port name
  745. * including the final NULL character. This value is a constant.
  746. *
  747. * A port's full name contains the owning client name concatenated
  748. * with a colon (:) followed by its short name and a NULL
  749. * character.
  750. */
  751. int jack_port_name_size(void);
  752. /**
  753. * @return the maximum number of characters in a JACK port type name
  754. * including the final NULL character. This value is a constant.
  755. */
  756. int jack_port_type_size(void);
  757. /**
  758. * @return the sample rate of the jack system, as set by the user when
  759. * jackd was started.
  760. */
  761. jack_nframes_t jack_get_sample_rate (jack_client_t *);
  762. /**
  763. * @return the current maximum size that will ever be passed to the @a
  764. * process_callback. It should only be used *before* the client has
  765. * been activated. This size may change, clients that depend on it
  766. * must register a @a bufsize_callback so they will be notified if it
  767. * does.
  768. *
  769. * @see jack_set_buffer_size_callback()
  770. */
  771. jack_nframes_t jack_get_buffer_size (jack_client_t *);
  772. /**
  773. * @param port_name_pattern A regular expression used to select
  774. * ports by name. If NULL or of zero length, no selection based
  775. * on name will be carried out.
  776. * @param type_name_pattern A regular expression used to select
  777. * ports by type. If NULL or of zero length, no selection based
  778. * on type will be carried out.
  779. * @param flags A value used to select ports by their flags.
  780. * If zero, no selection based on flags will be carried out.
  781. *
  782. * @return a NULL-terminated array of ports that match the specified
  783. * arguments. The caller is responsible for calling free(3) any
  784. * non-NULL returned value.
  785. *
  786. * @see jack_port_name_size(), jack_port_type_size()
  787. */
  788. const char ** jack_get_ports (jack_client_t *,
  789. const char *port_name_pattern,
  790. const char *type_name_pattern,
  791. unsigned long flags);
  792. /**
  793. * @return address of the jack_port_t named @a port_name.
  794. *
  795. * @see jack_port_name_size()
  796. */
  797. jack_port_t * jack_port_by_name (jack_client_t *, const char *port_name);
  798. /**
  799. * @return address of the jack_port_t of a @a port_id.
  800. */
  801. jack_port_t * jack_port_by_id (jack_client_t *client,
  802. jack_port_id_t port_id);
  803. /**
  804. * Old-style interface to become the timebase for the entire JACK
  805. * subsystem.
  806. *
  807. * @deprecated This function still exists for compatibility with the
  808. * earlier transport interface, but it does nothing. Instead, see
  809. * transport.h and use jack_set_timebase_callback().
  810. *
  811. * @return ENOSYS, function not implemented.
  812. */
  813. int jack_engine_takeover_timebase (jack_client_t *);
  814. /**
  815. * @return the time in frames that has passed since the JACK server
  816. * began the current process cycle.
  817. */
  818. jack_nframes_t jack_frames_since_cycle_start (const jack_client_t *);
  819. /**
  820. * @return an estimate of the current time in frames. This is a
  821. * running counter, no significance should be attached to its value,
  822. * but it can be compared to a previously returned value.
  823. */
  824. jack_nframes_t jack_frame_time (const jack_client_t *);
  825. /**
  826. * @return the frame_time after the last processing of the graph
  827. * this is only to be used from the process callback.
  828. *
  829. * This function can be used to put timestamps generated by
  830. * jack_frame_time() in correlation to the current process cycle.
  831. */
  832. jack_nframes_t jack_last_frame_time (const jack_client_t *client);
  833. /**
  834. * @return estimated time in microseconds of the specified frame time
  835. */
  836. jack_time_t jack_frames_to_time(const jack_client_t *client, jack_nframes_t);
  837. /**
  838. * @return estimated time in frames for the specified system time.
  839. */
  840. jack_nframes_t jack_time_to_frames(const jack_client_t *client, jack_time_t);
  841. /**
  842. * @return return JACK's current system time in microseconds,
  843. * using JACK clock source.
  844. *
  845. * The value returned is guaranteed to be monotonic, but not linear.
  846. *
  847. * This function is a client version of @function jack_get_microseconds().
  848. */
  849. jack_time_t jack_get_time();
  850. /**
  851. * @return the current CPU load estimated by JACK. This is a running
  852. * average of the time it takes to execute a full process cycle for
  853. * all clients as a percentage of the real time available per cycle
  854. * determined by the buffer size and sample rate.
  855. */
  856. float jack_cpu_load (jack_client_t *client);
  857. /**
  858. * @return the pthread ID of the thread running the JACK client side
  859. * code.
  860. */
  861. pthread_t jack_client_thread_id (jack_client_t *);
  862. /**
  863. * Display JACK error message.
  864. *
  865. * Set via jack_set_error_function(), otherwise a JACK-provided
  866. * default will print @a msg (plus a newline) to stderr.
  867. *
  868. * @param msg error message text (no newline at end).
  869. */
  870. extern void (*jack_error_callback)(const char *msg);
  871. /**
  872. * Set the @ref jack_error_callback for error message display.
  873. *
  874. * The JACK library provides two built-in callbacks for this purpose:
  875. * default_jack_error_callback() and silent_jack_error_callback().
  876. */
  877. void jack_set_error_function (void (*func)(const char *));
  878. /**
  879. * Display JACK info message.
  880. *
  881. * Set via jack_set_info_function(), otherwise a JACK-provided
  882. * default will print @a msg (plus a newline) to stdout.
  883. *
  884. * @param msg info message text (no newline at end).
  885. */
  886. extern void (*jack_info_callback)(const char *msg);
  887. /**
  888. * Set the @ref jack_info_callback for info message display.
  889. */
  890. void jack_set_info_function (void (*func)(const char *));
  891. #ifdef __cplusplus
  892. }
  893. #endif
  894. #endif /* __jack_h__ */