jack1 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

801 lines
27KB

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