jack1 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.

879 lines
29KB

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