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.

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