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.

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