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.

868 lines
32KB

  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. $Id: jack.h,v 1.5.2.6 2006/06/20 14:44:00 letz Exp $
  16. */
  17. #ifndef __jack_h__
  18. #define __jack_h__
  19. #ifdef __cplusplus
  20. extern "C"
  21. {
  22. #endif
  23. #ifdef WIN32
  24. #include <windows.h>
  25. typedef HANDLE pthread_t;
  26. #else
  27. #include <pthread.h>
  28. #endif
  29. /*
  30. #include <jack/types.h>
  31. #include <jack/transport.h>
  32. */
  33. #include "types.h"
  34. #include "transport.h"
  35. /**
  36. * Note: More documentation can be found in jack/types.h.
  37. */
  38. /**
  39. * Open an external client session with a JACK server. This interface
  40. * is more complex but more powerful than jack_client_new(). With it,
  41. * clients may choose which of several servers to connect, and control
  42. * whether and how to start the server automatically, if it was not
  43. * already running. There is also an option for JACK to generate a
  44. * unique client name, when necessary.
  45. *
  46. * @param client_name of at most jack_client_name_size() characters.
  47. * The name scope is local to each server. Unless forbidden by the
  48. * @ref JackUseExactName option, the server will modify this name to
  49. * create a unique variant, if needed.
  50. *
  51. * @param options formed by OR-ing together @ref JackOptions bits.
  52. * Only the @ref JackOpenOptions bits are allowed.
  53. *
  54. * @param status (if non-NULL) an address for JACK to return
  55. * information from the open operation. This status word is formed by
  56. * OR-ing together the relevant @ref JackStatus bits.
  57. *
  58. *
  59. * <b>Optional parameters:</b> depending on corresponding [@a options
  60. * bits] additional parameters may follow @a status (in this order).
  61. *
  62. * @arg [@ref JackServerName] <em>(char *) server_name</em> selects
  63. * from among several possible concurrent server instances. Server
  64. * names are unique to each user. If unspecified, use "default"
  65. * unless \$JACK_DEFAULT_SERVER is defined in the process environment.
  66. *
  67. * @return Opaque client handle if successful. If this is NULL, the
  68. * open operation failed, @a *status includes @ref JackFailure and the
  69. * caller is not a JACK client.
  70. */
  71. jack_client_t * jack_client_open (const char *client_name,
  72. jack_options_t options,
  73. jack_status_t *status, ...);
  74. /**
  75. * Attempt to become an external client of the Jack server.
  76. *
  77. * JACK is evolving a mechanism for automatically starting the server
  78. * when needed. As a transition, jack_client_new() only does this
  79. * when \$JACK_START_SERVER is defined in the environment of the
  80. * calling process. In the future this will become normal behavior.
  81. * For full control of this feature, use jack_client_open(), instead.
  82. * In either case, defining \$JACK_NO_START_SERVER disables this
  83. * feature.
  84. *
  85. * @param client_name of at most jack_client_name_size() characters.
  86. * If this name is already in use, the request fails.
  87. *
  88. * @return Opaque client handle if successful, otherwise NULL.
  89. *
  90. * @note Failure generally means that the JACK server is not running.
  91. * If there was some other problem, it will be reported via the @ref
  92. * jack_error_callback mechanism. Use jack_client_open() and check
  93. * the @a status parameter for more detailed information.
  94. */
  95. jack_client_t * jack_client_new (const char *client_name);
  96. /**
  97. * Disconnects an external client from a JACK server.
  98. *
  99. * @return 0 on success, otherwise a non-zero error code
  100. */
  101. int jack_client_close (jack_client_t *client);
  102. /**
  103. * @return the maximum number of characters in a JACK client name
  104. * including the final NULL character. This value is a constant.
  105. */
  106. int jack_client_name_size (void);
  107. /**
  108. * @return pointer to actual client name. This is useful when @ref
  109. * JackUseExactName is not specified on open and @ref
  110. * JackNameNotUnique status was returned. In that case, the actual
  111. * name will differ from the @a client_name requested.
  112. */
  113. char * jack_get_client_name (jack_client_t *client);
  114. /**
  115. * Load an internal client into the Jack server.
  116. *
  117. * Internal clients run inside the JACK server process. They can use
  118. * most of the same functions as external clients. Each internal
  119. * client must declare jack_initialize() and jack_finish() entry
  120. * points, called at load and unload times. See inprocess.c for an
  121. * example of how to write an internal client.
  122. *
  123. * @deprecated Please use jack_internal_client_load().
  124. *
  125. * @param client_name of at most jack_client_name_size() characters.
  126. *
  127. * @param load_name of a shared object file containing the code for
  128. * the new client.
  129. *
  130. * @param load_init an arbitary string passed to the jack_initialize()
  131. * routine of the new client (may be NULL).
  132. *
  133. * @return 0 if successful.
  134. */
  135. int jack_internal_client_new (const char *client_name,
  136. const char *load_name,
  137. const char *load_init);
  138. jack_client_t* my_jack_internal_client_new(const char* client_name, const char* dll_name, const char* object_data);
  139. /**
  140. * Remove an internal client from a JACK server.
  141. *
  142. * @deprecated Please use jack_internal_client_load().
  143. */
  144. void jack_internal_client_close (const char *client_name);
  145. void my_jack_internal_client_close (jack_client_t* client);
  146. /**
  147. * @param client pointer to JACK client structure.
  148. *
  149. * Check if the JACK subsystem is running with -R (--realtime).
  150. *
  151. * @return 1 if JACK is running realtime, 0 otherwise
  152. */
  153. int jack_is_realtime (jack_client_t *client);
  154. /**
  155. * @param client pointer to JACK client structure.
  156. * @param function The jack_shutdown function pointer.
  157. * @param arg The arguments for the jack_shutdown function.
  158. *
  159. * Register a function (and argument) to be called if and when the
  160. * JACK server shuts down the client thread. The function must
  161. * be written as if it were an asynchonrous POSIX signal
  162. * handler --- use only async-safe functions, and remember that it
  163. * is executed from another thread. A typical function might
  164. * set a flag or write to a pipe so that the rest of the
  165. * application knows that the JACK client thread has shut
  166. * down.
  167. *
  168. * NOTE: clients do not need to call this. It exists only
  169. * to help more complex clients understand what is going
  170. * on. It should be called before jack_client_activate().
  171. */
  172. void jack_on_shutdown (jack_client_t *client,
  173. void (*function)(void *arg), void *arg);
  174. /**
  175. * Tell the Jack server to call @a process_callback whenever there is
  176. * work be done, passing @a arg as the second argument.
  177. *
  178. * The code in the supplied function must be suitable for real-time
  179. * execution. That means that it cannot call functions that might
  180. * block for a long time.  This includes malloc, free, printf,
  181. * pthread_mutex_lock, sleep, wait, poll, select, pthread_join,
  182. * pthread_cond_wait, etc, etc.  See
  183. * http://jackit.sourceforge.net/docs/design/design.html#SECTION00411000000000000000
  184. * for more information.
  185. *
  186. * @return 0 on success, otherwise a non-zero error code, causing JACK
  187. * to remove that client from the process() graph.
  188. */
  189. int jack_set_process_callback (jack_client_t *client,
  190. JackProcessCallback process_callback,
  191. void *arg);
  192. /**
  193. * Tell JACK to call @a thread_init_callback once just after
  194. * the creation of the thread in which all other callbacks
  195. * will be handled.
  196. *
  197. * The code in the supplied function does not need to be
  198. * suitable for real-time execution.
  199. *
  200. * @return 0 on success, otherwise a non-zero error code, causing JACK
  201. * to remove that client from the process() graph.
  202. */
  203. int jack_set_thread_init_callback (jack_client_t *client,
  204. JackThreadInitCallback thread_init_callback,
  205. void *arg);
  206. /**
  207. * Tell the Jack server to call @a freewheel_callback
  208. * whenever we enter or leave "freewheel" mode, passing @a
  209. * arg as the second argument. The first argument to the
  210. * callback will be non-zero if JACK is entering freewheel
  211. * mode, and zero otherwise.
  212. *
  213. * @return 0 on success, otherwise a non-zero error code.
  214. */
  215. int jack_set_freewheel_callback (jack_client_t *client,
  216. JackFreewheelCallback freewheel_callback,
  217. void *arg);
  218. /**
  219. * Start/Stop JACK's "freewheel" mode.
  220. *
  221. * When in "freewheel" mode, JACK no longer waits for
  222. * any external event to begin the start of the next process
  223. * cycle.
  224. *
  225. * As a result, freewheel mode causes "faster than realtime"
  226. * execution of a JACK graph. If possessed, real-time
  227. * scheduling is dropped when entering freewheel mode, and
  228. * if appropriate it is reacquired when stopping.
  229. *
  230. * IMPORTANT: on systems using capabilities to provide real-time
  231. * scheduling (i.e. Linux kernel 2.4), if onoff is zero, this function
  232. * must be called from the thread that originally called jack_activate().
  233. * This restriction does not apply to other systems (e.g. Linux kernel 2.6
  234. * or OS X).
  235. *
  236. * @param client pointer to JACK client structure
  237. * @param onoff if non-zero, freewheel mode starts. Otherwise
  238. * freewheel mode ends.
  239. *
  240. * @return 0 on success, otherwise a non-zero error code.
  241. */
  242. int jack_set_freewheel(jack_client_t* client, int onoff);
  243. /**
  244. * Change the buffer size passed to the @a process_callback.
  245. *
  246. * This operation stops the JACK engine process cycle, then calls all
  247. * registered @a bufsize_callback functions before restarting the
  248. * process cycle. This will cause a gap in the audio flow, so it
  249. * should only be done at appropriate stopping points.
  250. *
  251. * @see jack_set_buffer_size_callback()
  252. *
  253. * @param client pointer to JACK client structure.
  254. * @param nframes new buffer size. Must be a power of two.
  255. *
  256. * @return 0 on success, otherwise a non-zero error code
  257. */
  258. int jack_set_buffer_size (jack_client_t *client, jack_nframes_t nframes);
  259. /**
  260. * Tell JACK to call @a bufsize_callback whenever the size of the the
  261. * buffer that will be passed to the @a process_callback is about to
  262. * change. Clients that depend on knowing the buffer size must supply
  263. * a @a bufsize_callback before activating themselves.
  264. *
  265. * @param client pointer to JACK client structure.
  266. * @param bufsize_callback function to call when the buffer size changes.
  267. * @param arg argument for @a bufsize_callback.
  268. *
  269. * @return 0 on success, otherwise a non-zero error code
  270. */
  271. int jack_set_buffer_size_callback (jack_client_t *client,
  272. JackBufferSizeCallback bufsize_callback,
  273. void *arg);
  274. /**
  275. * Tell the Jack server to call @a srate_callback whenever the system
  276. * sample rate changes.
  277. *
  278. * @return 0 on success, otherwise a non-zero error code
  279. */
  280. int jack_set_sample_rate_callback (jack_client_t *client,
  281. JackSampleRateCallback srate_callback,
  282. void *arg);
  283. /**
  284. * Tell the JACK server to call @a registration_callback whenever a
  285. * port is registered or unregistered, passing @a arg as a parameter.
  286. *
  287. * @return 0 on success, otherwise a non-zero error code
  288. */
  289. int jack_set_client_registration_callback (jack_client_t *,
  290. JackClientRegistrationCallback
  291. registration_callback, void *arg);
  292. /**
  293. * Tell the JACK server to call @a registration_callback whenever a
  294. * port is registered or unregistered, passing @a arg as a parameter.
  295. *
  296. * @return 0 on success, otherwise a non-zero error code
  297. */
  298. int jack_set_port_registration_callback (jack_client_t *,
  299. JackPortRegistrationCallback
  300. registration_callback, void *arg);
  301. /**
  302. * Tell the JACK server to call @a graph_callback whenever the
  303. * processing graph is reordered, passing @a arg as a parameter.
  304. *
  305. * @return 0 on success, otherwise a non-zero error code
  306. */
  307. int jack_set_graph_order_callback (jack_client_t *,
  308. JackGraphOrderCallback graph_callback,
  309. void *);
  310. /**
  311. * Tell the JACK server to call @a xrun_callback whenever there is a
  312. * xrun, passing @a arg as a parameter.
  313. *
  314. * @return 0 on success, otherwise a non-zero error code
  315. */
  316. int jack_set_xrun_callback (jack_client_t *,
  317. JackXRunCallback xrun_callback, void *arg);
  318. /**
  319. * Tell the Jack server that the program is ready to start processing
  320. * audio.
  321. *
  322. * @return 0 on success, otherwise a non-zero error code
  323. */
  324. int jack_activate (jack_client_t *client);
  325. /**
  326. * Tell the Jack server to remove this @a client from the process
  327. * graph. Also, disconnect all ports belonging to it, since inactive
  328. * clients have no port connections.
  329. *
  330. * @return 0 on success, otherwise a non-zero error code
  331. */
  332. int jack_deactivate (jack_client_t *client);
  333. /**
  334. * Create a new port for the client. This is an object used for moving
  335. * data of any type in or out of the client. Ports may be connected
  336. * in various ways.
  337. *
  338. * Each port has a short name. The port's full name contains the name
  339. * of the client concatenated with a colon (:) followed by its short
  340. * name. The jack_port_name_size() is the maximum length of this full
  341. * name. Exceeding that will cause the port registration to fail and
  342. * return NULL.
  343. *
  344. * All ports have a type, which may be any non-NULL and non-zero
  345. * length string, passed as an argument. Some port types are built
  346. * into the JACK API, currently only JACK_DEFAULT_AUDIO_TYPE.
  347. *
  348. * @param client pointer to JACK client structure.
  349. * @param port_name non-empty short name for the new port (not
  350. * including the leading @a "client_name:").
  351. * @param port_type port type name. If longer than
  352. * jack_port_type_size(), only that many characters are significant.
  353. * @param flags @ref JackPortFlags bit mask.
  354. * @param buffer_size must be non-zero if this is not a built-in @a
  355. * port_type. Otherwise, it is ignored.
  356. *
  357. * @return jack_port_t pointer on success, otherwise NULL.
  358. */
  359. jack_port_t * jack_port_register (jack_client_t *client,
  360. const char *port_name,
  361. const char *port_type,
  362. unsigned long flags,
  363. unsigned long buffer_size);
  364. /**
  365. * Remove the port from the client, disconnecting any existing
  366. * connections.
  367. *
  368. * @return 0 on success, otherwise a non-zero error code
  369. */
  370. int jack_port_unregister (jack_client_t *, jack_port_t *);
  371. /**
  372. * This returns a pointer to the memory area associated with the
  373. * specified port. For an output port, it will be a memory area
  374. * that can be written to; for an input port, it will be an area
  375. * containing the data from the port's connection(s), or
  376. * zero-filled. if there are multiple inbound connections, the data
  377. * will be mixed appropriately.
  378. *
  379. * FOR OUTPUT PORTS ONLY
  380. * ---------------------
  381. * You may cache the value returned, but only between calls to
  382. * your "blocksize" callback. For this reason alone, you should
  383. * either never cache the return value or ensure you have
  384. * a "blocksize" callback and be sure to invalidate the cached
  385. * address from there.
  386. */
  387. void * jack_port_get_buffer (jack_port_t *, jack_nframes_t);
  388. /**
  389. * @return the full name of the jack_port_t (including the @a
  390. * "client_name:" prefix).
  391. *
  392. * @see jack_port_name_size().
  393. */
  394. const char * jack_port_name (const jack_port_t *port);
  395. /**
  396. * @return the short name of the jack_port_t (not including the @a
  397. * "client_name:" prefix).
  398. *
  399. * @see jack_port_name_size().
  400. */
  401. const char * jack_port_short_name (const jack_port_t *port);
  402. /**
  403. * @return the @ref JackPortFlags of the jack_port_t.
  404. */
  405. int jack_port_flags (const jack_port_t *port);
  406. /**
  407. * @return the @a port type, at most jack_port_type_size() characters
  408. * including a final NULL.
  409. */
  410. const char * jack_port_type (const jack_port_t *port);
  411. /**
  412. * @return TRUE if the jack_port_t belongs to the jack_client_t.
  413. */
  414. int jack_port_is_mine (const jack_client_t *, const jack_port_t *port);
  415. /**
  416. * @return number of connections to or from @a port.
  417. *
  418. * @pre The calling client must own @a port.
  419. */
  420. int jack_port_connected (const jack_port_t *port);
  421. /**
  422. * @return TRUE if the locally-owned @a port is @b directly connected
  423. * to the @a port_name.
  424. *
  425. * @see jack_port_name_size()
  426. */
  427. int jack_port_connected_to (const jack_port_t *port,
  428. const char *port_name);
  429. /**
  430. * @return a null-terminated array of full port names to which the @a
  431. * port is connected. If none, returns NULL.
  432. *
  433. * The caller is responsible for calling free(3) on any non-NULL
  434. * returned value.
  435. *
  436. * @param port locally owned jack_port_t pointer.
  437. *
  438. * @see jack_port_name_size(), jack_port_get_all_connections()
  439. */
  440. const char ** jack_port_get_connections (const jack_port_t *port);
  441. /**
  442. * @return a null-terminated array of full port names to which the @a
  443. * port is connected. If none, returns NULL.
  444. *
  445. * The caller is responsible for calling free(3) on any non-NULL
  446. * returned value.
  447. *
  448. * This differs from jack_port_get_connections() in two important
  449. * respects:
  450. *
  451. * 1) You may not call this function from code that is
  452. * executed in response to a JACK event. For example,
  453. * you cannot use it in a GraphReordered handler.
  454. *
  455. * 2) You need not be the owner of the port to get information
  456. * about its connections.
  457. *
  458. * @see jack_port_name_size()
  459. */
  460. const char ** jack_port_get_all_connections (const jack_client_t *client,
  461. const jack_port_t *port);
  462. /**
  463. * A client may call this on a pair of its own ports to
  464. * semi-permanently wire them together. This means that
  465. * a client that wants to direct-wire an input port to
  466. * an output port can call this and then no longer
  467. * have to worry about moving data between them. Any data
  468. * arriving at the input port will appear automatically
  469. * at the output port.
  470. *
  471. * The 'destination' port must be an output port. The 'source'
  472. * port must be an input port. Both ports must belong to
  473. * the same client. You cannot use this to tie ports between
  474. * clients. That is what a connection is for.
  475. *
  476. * @return 0 on success, otherwise a non-zero error code
  477. */
  478. int jack_port_tie (jack_port_t *src, jack_port_t *dst);
  479. /**
  480. * This undoes the effect of jack_port_tie(). The port
  481. * should be same as the 'destination' port passed to
  482. * jack_port_tie().
  483. *
  484. * @return 0 on success, otherwise a non-zero error code
  485. */
  486. int jack_port_untie (jack_port_t *port);
  487. /**
  488. * A client may call this function to prevent other objects
  489. * from changing the connection status of a port. The port
  490. * must be owned by the calling client.
  491. *
  492. * @return 0 on success, otherwise a non-zero error code
  493. */
  494. int jack_port_lock (jack_client_t *, jack_port_t *);
  495. /**
  496. * This allows other objects to change the connection status of a port.
  497. *
  498. * @return 0 on success, otherwise a non-zero error code
  499. */
  500. int jack_port_unlock (jack_client_t *, jack_port_t *);
  501. /**
  502. * @return the time (in frames) between data being available or
  503. * delivered at/to a port, and the time at which it arrived at or is
  504. * delivered to the "other side" of the port. E.g. for a physical
  505. * audio output port, this is the time between writing to the port and
  506. * when the signal will leave the connector. For a physical audio
  507. * input port, this is the time between the sound arriving at the
  508. * connector and the corresponding frames being readable from the
  509. * port.
  510. */
  511. jack_nframes_t jack_port_get_latency (jack_port_t *port);
  512. /**
  513. * The maximum of the sum of the latencies in every
  514. * connection path that can be drawn between the port and other
  515. * ports with the @ref JackPortIsTerminal flag set.
  516. */
  517. jack_nframes_t jack_port_get_total_latency (jack_client_t *,
  518. jack_port_t *port);
  519. /**
  520. * The port latency is zero by default. Clients that control
  521. * physical hardware with non-zero latency should call this
  522. * to set the latency to its correct value. Note that the value
  523. * should include any systemic latency present "outside" the
  524. * physical hardware controlled by the client. For example,
  525. * for a client controlling a digital audio interface connected
  526. * to an external digital converter, the latency setting should
  527. * include both buffering by the audio interface *and* the converter.
  528. */
  529. void jack_port_set_latency (jack_port_t *, jack_nframes_t);
  530. /**
  531. *
  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. #ifdef __cplusplus
  780. }
  781. #endif
  782. #endif /* __jack_h__ */