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.

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