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.

785 lines
26KB

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