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.

946 lines
35KB

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