Sync jack.h with jack1 one.
[jack2.git] / common / jack / jack.h
bloba59299dc5a8b60092c35e57b0b242c2691c3e154
1 /*
2 Copyright (C) 2001 Paul Davis
3 Copyright (C) 2004 Jack O'Quin
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 #ifndef __jack_h__
22 #define __jack_h__
24 #ifdef __cplusplus
25 extern "C"
27 #endif
29 #include <jack/systemdeps.h>
30 #include <jack/types.h>
31 #include <jack/transport.h>
33 /**
34 * Note: More documentation can be found in jack/types.h.
37 /**
38 * @defgroup ClientFunctions Creating & manipulating clients
39 * @{
42 /**
43 * Call this function to get version of the JACK, in form of several numbers
45 * @param major_ptr pointer to variable receiving major version of JACK.
47 * @param minor_ptr pointer to variable receiving minor version of JACK.
49 * @param major_ptr pointer to variable receiving micro version of JACK.
51 * @param major_ptr pointer to variable receiving protocol version of JACK.
54 void
55 jack_get_version(
56 int *major_ptr,
57 int *minor_ptr,
58 int *micro_ptr,
59 int *proto_ptr);
61 /**
62 * Call this function to get version of the JACK, in form of a string
64 * @return Human readable string describing JACK version being used.
67 const char *
68 jack_get_version_string();
70 /**
71 * Open an external client session with a JACK server. This interface
72 * is more complex but more powerful than jack_client_new(). With it,
73 * clients may choose which of several servers to connect, and control
74 * whether and how to start the server automatically, if it was not
75 * already running. There is also an option for JACK to generate a
76 * unique client name, when necessary.
78 * @param client_name of at most jack_client_name_size() characters.
79 * The name scope is local to each server. Unless forbidden by the
80 * @ref JackUseExactName option, the server will modify this name to
81 * create a unique variant, if needed.
83 * @param options formed by OR-ing together @ref JackOptions bits.
84 * Only the @ref JackOpenOptions bits are allowed.
86 * @param status (if non-NULL) an address for JACK to return
87 * information from the open operation. This status word is formed by
88 * OR-ing together the relevant @ref JackStatus bits.
91 * <b>Optional parameters:</b> depending on corresponding [@a options
92 * bits] additional parameters may follow @a status (in this order).
94 * @arg [@ref JackServerName] <em>(char *) server_name</em> selects
95 * from among several possible concurrent server instances. Server
96 * names are unique to each user. If unspecified, use "default"
97 * unless \$JACK_DEFAULT_SERVER is defined in the process environment.
99 * @return Opaque client handle if successful. If this is NULL, the
100 * open operation failed, @a *status includes @ref JackFailure and the
101 * caller is not a JACK client.
103 jack_client_t * jack_client_open (const char *client_name,
104 jack_options_t options,
105 jack_status_t *status, ...);
108 * \bold THIS FUNCTION IS DEPRECATED AND SHOULD NOT BE USED IN
109 * NEW JACK CLIENTS
111 * @deprecated Please use jack_client_open().
113 jack_client_t * jack_client_new (const char *client_name);
116 * Disconnects an external client from a JACK server.
118 * @return 0 on success, otherwise a non-zero error code
120 int jack_client_close (jack_client_t *client);
123 * @return the maximum number of characters in a JACK client name
124 * including the final NULL character. This value is a constant.
126 int jack_client_name_size (void);
129 * @return pointer to actual client name. This is useful when @ref
130 * JackUseExactName is not specified on open and @ref
131 * JackNameNotUnique status was returned. In that case, the actual
132 * name will differ from the @a client_name requested.
134 char * jack_get_client_name (jack_client_t *client);
137 * Load an internal client into the Jack server.
139 * Internal clients run inside the JACK server process. They can use
140 * most of the same functions as external clients. Each internal
141 * client must declare jack_initialize() and jack_finish() entry
142 * points, called at load and unload times. See inprocess.c for an
143 * example of how to write an internal client.
145 * @deprecated Please use jack_internal_client_load().
147 * @param client_name of at most jack_client_name_size() characters.
149 * @param load_name of a shared object file containing the code for
150 * the new client.
152 * @param load_init an arbitary string passed to the jack_initialize()
153 * routine of the new client (may be NULL).
155 * @return 0 if successful.
157 int jack_internal_client_new (const char *client_name,
158 const char *load_name,
159 const char *load_init);
162 * Remove an internal client from a JACK server.
164 * @deprecated Please use jack_internal_client_load().
166 void jack_internal_client_close (const char *client_name);
169 * Tell the Jack server that the program is ready to start processing
170 * audio.
172 * @return 0 on success, otherwise a non-zero error code
174 int jack_activate (jack_client_t *client);
177 * Tell the Jack server to remove this @a client from the process
178 * graph. Also, disconnect all ports belonging to it, since inactive
179 * clients have no port connections.
181 * @return 0 on success, otherwise a non-zero error code
183 int jack_deactivate (jack_client_t *client);
186 * @return pid of client. If not available, 0 will be returned.
188 int jack_get_client_pid (const char *name);
191 * @return the pthread ID of the thread running the JACK client side
192 * code.
194 pthread_t jack_client_thread_id (jack_client_t *);
196 /*@}*/
199 * @param client pointer to JACK client structure.
201 * Check if the JACK subsystem is running with -R (--realtime).
203 * @return 1 if JACK is running realtime, 0 otherwise
205 int jack_is_realtime (jack_client_t *client);
208 * @defgroup NonCallbackAPI The non-callback API
209 * @{
213 * \bold THIS FUNCTION IS DEPRECATED AND SHOULD NOT BE USED IN
214 * NEW JACK CLIENTS.
216 * @deprecated Please use jack_cycle_wait() and jack_cycle_signal() functions.
218 jack_nframes_t jack_thread_wait (jack_client_t*, int status);
221 * Wait until this JACK client should process data.
223 * @param client - pointer to a JACK client structure
225 * @return the number of frames of data to process
227 jack_nframes_t jack_cycle_wait (jack_client_t* client);
230 * Signal next clients in the graph.
232 * @param client - pointer to a JACK client structure
233 * @param status - if non-zero, calling thread should exit
235 void jack_cycle_signal (jack_client_t* client, int status);
238 * Tell the Jack server to call @a thread_callback in the RT thread.
239 * Typical use are in conjunction with @a jack_cycle_wait and @a jack_cycle_signal functions.
240 * The code in the supplied function must be suitable for real-time
241 * execution. That means that it cannot call functions that might
242 * block for a long time. This includes malloc, free, printf,
243 * pthread_mutex_lock, sleep, wait, poll, select, pthread_join,
244 * pthread_cond_wait, etc, etc. See
245 * http://jackit.sourceforge.net/docs/design/design.html#SECTION00411000000000000000
246 * for more information.
248 * NOTE: this function cannot be called while the client is activated
249 * (after jack_activate has been called.)
251 * @return 0 on success, otherwise a non-zero error code.
253 int jack_set_process_thread(jack_client_t* client, JackThreadCallback thread_callback, void *arg);
255 /*@}*/
258 * @defgroup ClientCallbacks Setting Client Callbacks
259 * @{
263 * Tell JACK to call @a thread_init_callback once just after
264 * the creation of the thread in which all other callbacks
265 * will be handled.
267 * The code in the supplied function does not need to be
268 * suitable for real-time execution.
270 * NOTE: this function cannot be called while the client is activated
271 * (after jack_activate has been called.)
273 * @return 0 on success, otherwise a non-zero error code, causing JACK
274 * to remove that client from the process() graph.
276 int jack_set_thread_init_callback (jack_client_t *client,
277 JackThreadInitCallback thread_init_callback,
278 void *arg);
281 * @param client pointer to JACK client structure.
282 * @param function The jack_shutdown function pointer.
283 * @param arg The arguments for the jack_shutdown function.
285 * Register a function (and argument) to be called if and when the
286 * JACK server shuts down the client thread. The function must
287 * be written as if it were an asynchonrous POSIX signal
288 * handler --- use only async-safe functions, and remember that it
289 * is executed from another thread. A typical function might
290 * set a flag or write to a pipe so that the rest of the
291 * application knows that the JACK client thread has shut
292 * down.
294 * NOTE: clients do not need to call this. It exists only
295 * to help more complex clients understand what is going
296 * on. It should be called before jack_client_activate().
298 * NOTE: if a client calls this AND jack_on_info_shutdown(), then
299 * the event of a client thread shutdown, the callback
300 * passed to this function will not be called, and the one passed to
301 * jack_on_info_shutdown() will.
303 void jack_on_shutdown (jack_client_t *client,
304 JackShutdownCallback shutdown_callback, void *arg);
307 * @param client pointer to JACK client structure.
308 * @param function The jack_info_shutdown function pointer.
309 * @param arg The arguments for the jack_info_shutdown function.
311 * Register a function (and argument) to be called if and when the
312 * JACK server shuts down the client thread. The function must
313 * be written as if it were an asynchonrous POSIX signal
314 * handler --- use only async-safe functions, and remember that it
315 * is executed from another thread. A typical function might
316 * set a flag or write to a pipe so that the rest of the
317 * application knows that the JACK client thread has shut
318 * down.
320 * NOTE: clients do not need to call this. It exists only
321 * to help more complex clients understand what is going
322 * on. It should be called before jack_client_activate().
324 * NOTE: if a client calls this AND jack_on_info_shutdown(), then
325 * the event of a client thread shutdown, the callback
326 * passed to this function will not be called, and the one passed to
327 * jack_on_info_shutdown() will.
329 void jack_on_info_shutdown (jack_client_t *client,
330 JackInfoShutdownCallback shutdown_callback, void *arg);
333 * Tell the Jack server to call @a process_callback whenever there is
334 * work be done, passing @a arg as the second argument.
336 * The code in the supplied function must be suitable for real-time
337 * execution. That means that it cannot call functions that might
338 * block for a long time. This includes malloc, free, printf,
339 * pthread_mutex_lock, sleep, wait, poll, select, pthread_join,
340 * pthread_cond_wait, etc, etc. See
341 * http://jackit.sourceforge.net/docs/design/design.html#SECTION00411000000000000000
342 * for more information.
344 * NOTE: this function cannot be called while the client is activated
345 * (after jack_activate has been called.)
347 * @return 0 on success, otherwise a non-zero error code.
349 int jack_set_process_callback (jack_client_t *client,
350 JackProcessCallback process_callback,
351 void *arg);
354 * Tell the Jack server to call @a freewheel_callback
355 * whenever we enter or leave "freewheel" mode, passing @a
356 * arg as the second argument. The first argument to the
357 * callback will be non-zero if JACK is entering freewheel
358 * mode, and zero otherwise.
360 * All "notification events" are received in a seperated non RT thread,
361 * the code in the supplied function does not need to be
362 * suitable for real-time execution.
364 * NOTE: this function cannot be called while the client is activated
365 * (after jack_activate has been called.)
367 * @return 0 on success, otherwise a non-zero error code.
369 int jack_set_freewheel_callback (jack_client_t *client,
370 JackFreewheelCallback freewheel_callback,
371 void *arg);
374 * Tell JACK to call @a bufsize_callback whenever the size of the the
375 * buffer that will be passed to the @a process_callback is about to
376 * change. Clients that depend on knowing the buffer size must supply
377 * a @a bufsize_callback before activating themselves.
379 * All "notification events" are received in a seperated non RT thread,
380 * the code in the supplied function does not need to be
381 * suitable for real-time execution.
383 * NOTE: this function cannot be called while the client is activated
384 * (after jack_activate has been called.)
386 * @param client pointer to JACK client structure.
387 * @param bufsize_callback function to call when the buffer size changes.
388 * @param arg argument for @a bufsize_callback.
390 * @return 0 on success, otherwise a non-zero error code
392 int jack_set_buffer_size_callback (jack_client_t *client,
393 JackBufferSizeCallback bufsize_callback,
394 void *arg);
397 * Tell the Jack server to call @a srate_callback whenever the system
398 * sample rate changes.
400 * All "notification events" are received in a seperated non RT thread,
401 * the code in the supplied function does not need to be
402 * suitable for real-time execution.
404 * NOTE: this function cannot be called while the client is activated
405 * (after jack_activate has been called.)
407 * @return 0 on success, otherwise a non-zero error code
409 int jack_set_sample_rate_callback (jack_client_t *client,
410 JackSampleRateCallback srate_callback,
411 void *arg);
414 * Tell the JACK server to call @a registration_callback whenever a
415 * port is registered or unregistered, passing @a arg as a parameter.
417 * All "notification events" are received in a seperated non RT thread,
418 * the code in the supplied function does not need to be
419 * suitable for real-time execution.
421 * NOTE: this function cannot be called while the client is activated
422 * (after jack_activate has been called.)
424 * @return 0 on success, otherwise a non-zero error code
426 int jack_set_client_registration_callback (jack_client_t *,
427 JackClientRegistrationCallback
428 registration_callback, void *arg);
431 * Tell the JACK server to call @a registration_callback whenever a
432 * port is registered or unregistered, passing @a arg as a parameter.
434 * All "notification events" are received in a seperated non RT thread,
435 * the code in the supplied function does not need to be
436 * suitable for real-time execution.
438 * NOTE: this function cannot be called while the client is activated
439 * (after jack_activate has been called.)
441 * @return 0 on success, otherwise a non-zero error code
443 int jack_set_port_registration_callback (jack_client_t *,
444 JackPortRegistrationCallback
445 registration_callback, void *arg);
448 * Tell the JACK server to call @a connect_callback whenever a
449 * port is connected or disconnected, passing @a arg as a parameter.
451 * All "notification events" are received in a seperated non RT thread,
452 * the code in the supplied function does not need to be
453 * suitable for real-time execution.
455 * NOTE: this function cannot be called while the client is activated
456 * (after jack_activate has been called.)
458 * @return 0 on success, otherwise a non-zero error code
460 int jack_set_port_connect_callback (jack_client_t *,
461 JackPortConnectCallback
462 connect_callback, void *arg);
465 * Tell the JACK server to call @a rename_callback whenever a
466 * port is renamed, passing @a arg as a parameter.
468 * All "notification events" are received in a seperated non RT thread,
469 * the code in the supplied function does not need to be
470 * suitable for real-time execution.
472 * NOTE: this function cannot be called while the client is activated
473 * (after jack_activate has been called.)
475 * @return 0 on success, otherwise a non-zero error code
477 int jack_set_port_rename_callback (jack_client_t *,
478 JackPortRenameCallback
479 rename_callback, void *arg);
482 * Tell the JACK server to call @a graph_callback whenever the
483 * processing graph is reordered, passing @a arg as a parameter.
485 * All "notification events" are received in a seperated non RT thread,
486 * the code in the supplied function does not need to be
487 * suitable for real-time execution.
489 * NOTE: this function cannot be called while the client is activated
490 * (after jack_activate has been called.)
492 * @return 0 on success, otherwise a non-zero error code
494 int jack_set_graph_order_callback (jack_client_t *,
495 JackGraphOrderCallback graph_callback,
496 void *);
499 * Tell the JACK server to call @a xrun_callback whenever there is a
500 * xrun, passing @a arg as a parameter.
502 * All "notification events" are received in a seperated non RT thread,
503 * the code in the supplied function does not need to be
504 * suitable for real-time execution.
506 * NOTE: this function cannot be called while the client is activated
507 * (after jack_activate has been called.)
509 * @return 0 on success, otherwise a non-zero error code
511 int jack_set_xrun_callback (jack_client_t *,
512 JackXRunCallback xrun_callback, void *arg);
514 /*@}*/
517 * @defgroup ServerClientControl Controlling & querying JACK server operation
518 * @{
522 * Start/Stop JACK's "freewheel" mode.
524 * When in "freewheel" mode, JACK no longer waits for
525 * any external event to begin the start of the next process
526 * cycle.
528 * As a result, freewheel mode causes "faster than realtime"
529 * execution of a JACK graph. If possessed, real-time
530 * scheduling is dropped when entering freewheel mode, and
531 * if appropriate it is reacquired when stopping.
533 * IMPORTANT: on systems using capabilities to provide real-time
534 * scheduling (i.e. Linux kernel 2.4), if onoff is zero, this function
535 * must be called from the thread that originally called jack_activate().
536 * This restriction does not apply to other systems (e.g. Linux kernel 2.6
537 * or OS X).
539 * @param client pointer to JACK client structure
540 * @param onoff if non-zero, freewheel mode starts. Otherwise
541 * freewheel mode ends.
543 * @return 0 on success, otherwise a non-zero error code.
545 int jack_set_freewheel(jack_client_t* client, int onoff);
548 * Change the buffer size passed to the @a process_callback.
550 * This operation stops the JACK engine process cycle, then calls all
551 * registered @a bufsize_callback functions before restarting the
552 * process cycle. This will cause a gap in the audio flow, so it
553 * should only be done at appropriate stopping points.
555 * @see jack_set_buffer_size_callback()
557 * @param client pointer to JACK client structure.
558 * @param nframes new buffer size. Must be a power of two.
560 * @return 0 on success, otherwise a non-zero error code
562 int jack_set_buffer_size (jack_client_t *client, jack_nframes_t nframes);
565 * @return the sample rate of the jack system, as set by the user when
566 * jackd was started.
568 jack_nframes_t jack_get_sample_rate (jack_client_t *);
571 * @return the current maximum size that will ever be passed to the @a
572 * process_callback. It should only be used *before* the client has
573 * been activated. This size may change, clients that depend on it
574 * must register a @a bufsize_callback so they will be notified if it
575 * does.
577 * @see jack_set_buffer_size_callback()
579 jack_nframes_t jack_get_buffer_size (jack_client_t *);
582 * Old-style interface to become the timebase for the entire JACK
583 * subsystem.
585 * @deprecated This function still exists for compatibility with the
586 * earlier transport interface, but it does nothing. Instead, see
587 * transport.h and use jack_set_timebase_callback().
589 * @return ENOSYS, function not implemented.
591 int jack_engine_takeover_timebase (jack_client_t *);
594 * @return the current CPU load estimated by JACK. This is a running
595 * average of the time it takes to execute a full process cycle for
596 * all clients as a percentage of the real time available per cycle
597 * determined by the buffer size and sample rate.
599 float jack_cpu_load (jack_client_t *client);
601 /*@}*/
604 * @defgroup PortFunctions Creating & manipulating ports
605 * @{
609 * Create a new port for the client. This is an object used for moving
610 * data of any type in or out of the client. Ports may be connected
611 * in various ways.
613 * Each port has a short name. The port's full name contains the name
614 * of the client concatenated with a colon (:) followed by its short
615 * name. The jack_port_name_size() is the maximum length of this full
616 * name. Exceeding that will cause the port registration to fail and
617 * return NULL.
619 * All ports have a type, which may be any non-NULL and non-zero
620 * length string, passed as an argument. Some port types are built
621 * into the JACK API, currently only JACK_DEFAULT_AUDIO_TYPE.
623 * @param client pointer to JACK client structure.
624 * @param port_name non-empty short name for the new port (not
625 * including the leading @a "client_name:").
626 * @param port_type port type name. If longer than
627 * jack_port_type_size(), only that many characters are significant.
628 * @param flags @ref JackPortFlags bit mask.
629 * @param buffer_size must be non-zero if this is not a built-in @a
630 * port_type. Otherwise, it is ignored.
632 * @return jack_port_t pointer on success, otherwise NULL.
634 jack_port_t * jack_port_register (jack_client_t *client,
635 const char *port_name,
636 const char *port_type,
637 unsigned long flags,
638 unsigned long buffer_size);
641 * Remove the port from the client, disconnecting any existing
642 * connections.
644 * @return 0 on success, otherwise a non-zero error code
646 int jack_port_unregister (jack_client_t *, jack_port_t *);
649 * This returns a pointer to the memory area associated with the
650 * specified port. For an output port, it will be a memory area
651 * that can be written to; for an input port, it will be an area
652 * containing the data from the port's connection(s), or
653 * zero-filled. if there are multiple inbound connections, the data
654 * will be mixed appropriately.
656 * FOR OUTPUT PORTS ONLY : DEPRECATED in Jack 2.0 !!
657 * ---------------------------------------------------
658 * You may cache the value returned, but only between calls to
659 * your "blocksize" callback. For this reason alone, you should
660 * either never cache the return value or ensure you have
661 * a "blocksize" callback and be sure to invalidate the cached
662 * address from there.
664 * Caching output ports is DEPRECATED in Jack 2.0, due to some new optimization (like "pipelining").
665 * Port buffers have to be retrieved in each callback for proper functionning.
667 void * jack_port_get_buffer (jack_port_t *, jack_nframes_t);
670 * @return the full name of the jack_port_t (including the @a
671 * "client_name:" prefix).
673 * @see jack_port_name_size().
675 const char * jack_port_name (const jack_port_t *port);
678 * @return the short name of the jack_port_t (not including the @a
679 * "client_name:" prefix).
681 * @see jack_port_name_size().
683 const char * jack_port_short_name (const jack_port_t *port);
686 * @return the @ref JackPortFlags of the jack_port_t.
688 int jack_port_flags (const jack_port_t *port);
691 * @return the @a port type, at most jack_port_type_size() characters
692 * including a final NULL.
694 const char * jack_port_type (const jack_port_t *port);
697 * @return the @a port type id.
699 jack_port_type_id_t jack_port_type_id (const jack_port_t *port);
702 * @return TRUE if the jack_port_t belongs to the jack_client_t.
704 int jack_port_is_mine (const jack_client_t *, const jack_port_t *port);
707 * @return number of connections to or from @a port.
709 * @pre The calling client must own @a port.
711 int jack_port_connected (const jack_port_t *port);
714 * @return TRUE if the locally-owned @a port is @b directly connected
715 * to the @a port_name.
717 * @see jack_port_name_size()
719 int jack_port_connected_to (const jack_port_t *port,
720 const char *port_name);
723 * @return a null-terminated array of full port names to which the @a
724 * port is connected. If none, returns NULL.
726 * The caller is responsible for calling free(3) on any non-NULL
727 * returned value.
729 * @param port locally owned jack_port_t pointer.
731 * @see jack_port_name_size(), jack_port_get_all_connections()
733 const char ** jack_port_get_connections (const jack_port_t *port);
736 * @return a null-terminated array of full port names to which the @a
737 * port is connected. If none, returns NULL.
739 * The caller is responsible for calling free(3) on any non-NULL
740 * returned value.
742 * This differs from jack_port_get_connections() in two important
743 * respects:
745 * 1) You may not call this function from code that is
746 * executed in response to a JACK event. For example,
747 * you cannot use it in a GraphReordered handler.
749 * 2) You need not be the owner of the port to get information
750 * about its connections.
752 * @see jack_port_name_size()
754 const char ** jack_port_get_all_connections (const jack_client_t *client,
755 const jack_port_t *port);
759 * @deprecated This function will be removed from a future version
760 * of JACK. Do not use it. There is no replacement. It has
761 * turned out to serve essentially no purpose in real-life
762 * JACK clients.
764 int jack_port_tie (jack_port_t *src, jack_port_t *dst);
768 * @deprecated This function will be removed from a future version
769 * of JACK. Do not use it. There is no replacement. It has
770 * turned out to serve essentially no purpose in real-life
771 * JACK clients.
773 int jack_port_untie (jack_port_t *port);
776 * @return the time (in frames) between data being available or
777 * delivered at/to a port, and the time at which it arrived at or is
778 * delivered to the "other side" of the port. E.g. for a physical
779 * audio output port, this is the time between writing to the port and
780 * when the signal will leave the connector. For a physical audio
781 * input port, this is the time between the sound arriving at the
782 * connector and the corresponding frames being readable from the
783 * port.
785 jack_nframes_t jack_port_get_latency (jack_port_t *port);
788 * The maximum of the sum of the latencies in every
789 * connection path that can be drawn between the port and other
790 * ports with the @ref JackPortIsTerminal flag set.
792 jack_nframes_t jack_port_get_total_latency (jack_client_t *,
793 jack_port_t *port);
796 * The port latency is zero by default. Clients that control
797 * physical hardware with non-zero latency should call this
798 * to set the latency to its correct value. Note that the value
799 * should include any systemic latency present "outside" the
800 * physical hardware controlled by the client. For example,
801 * for a client controlling a digital audio interface connected
802 * to an external digital converter, the latency setting should
803 * include both buffering by the audio interface *and* the converter.
805 void jack_port_set_latency (jack_port_t *, jack_nframes_t);
808 * Request a complete recomputation of a port's total latency. This
809 * can be called by a client that has just changed the internal
810 * latency of its port using @function jack_port_set_latency
811 * and wants to ensure that all signal pathways in the graph
812 * are updated with respect to the values that will be returned
813 * by @function jack_port_get_total_latency.
815 * @return zero for successful execution of the request. non-zero
816 * otherwise.
818 int jack_recompute_total_latency (jack_client_t*, jack_port_t* port);
821 * Request a complete recomputation of all port latencies. This
822 * can be called by a client that has just changed the internal
823 * latency of its port using @function jack_port_set_latency
824 * and wants to ensure that all signal pathways in the graph
825 * are updated with respect to the values that will be returned
826 * by @function jack_port_get_total_latency. It allows a client
827 * to change multiple port latencies without triggering a
828 * recompute for each change.
830 * @return zero for successful execution of the request. non-zero
831 * otherwise.
833 int jack_recompute_total_latencies (jack_client_t*);
836 * Modify a port's short name. May be called at any time. If the
837 * resulting full name (including the @a "client_name:" prefix) is
838 * longer than jack_port_name_size(), it will be truncated.
840 * @return 0 on success, otherwise a non-zero error code.
842 int jack_port_set_name (jack_port_t *port, const char *port_name);
845 * Set @a alias as an alias for @a port. May be called at any time.
846 * If the alias is longer than jack_port_name_size(), it will be truncated.
848 * After a successful call, and until JACK exits or
849 * @function jack_port_unset_alias() is called, @alias may be
850 * used as a alternate name for the port.
852 * Ports can have up to two aliases - if both are already
853 * set, this function will return an error.
855 * @return 0 on success, otherwise a non-zero error code.
857 int jack_port_set_alias (jack_port_t *port, const char *alias);
860 * Remove @a alias as an alias for @a port. May be called at any time.
862 * After a successful call, @a alias can no longer be
863 * used as a alternate name for the port.
865 * @return 0 on success, otherwise a non-zero error code.
867 int jack_port_unset_alias (jack_port_t *port, const char *alias);
870 * Get any aliases known for @port.
872 * @return the number of aliases discovered for the port
874 int jack_port_get_aliases (const jack_port_t *port, char* const aliases[2]);
877 * If @ref JackPortCanMonitor is set for this @a port, turn input
878 * monitoring on or off. Otherwise, do nothing.
880 int jack_port_request_monitor (jack_port_t *port, int onoff);
883 * If @ref JackPortCanMonitor is set for this @a port_name, turn input
884 * monitoring on or off. Otherwise, do nothing.
886 * @return 0 on success, otherwise a non-zero error code.
888 * @see jack_port_name_size()
890 int jack_port_request_monitor_by_name (jack_client_t *client,
891 const char *port_name, int onoff);
894 * If @ref JackPortCanMonitor is set for a port, this function turns
895 * on input monitoring if it was off, and turns it off if only one
896 * request has been made to turn it on. Otherwise it does nothing.
898 * @return 0 on success, otherwise a non-zero error code
900 int jack_port_ensure_monitor (jack_port_t *port, int onoff);
903 * @return TRUE if input monitoring has been requested for @a port.
905 int jack_port_monitoring_input (jack_port_t *port);
908 * Establish a connection between two ports.
910 * When a connection exists, data written to the source port will
911 * be available to be read at the destination port.
913 * @pre The port types must be identical.
915 * @pre The @ref JackPortFlags of the @a source_port must include @ref
916 * JackPortIsOutput.
918 * @pre The @ref JackPortFlags of the @a destination_port must include
919 * @ref JackPortIsInput.
921 * @return 0 on success, EEXIST if the connection is already made,
922 * otherwise a non-zero error code
924 int jack_connect (jack_client_t *,
925 const char *source_port,
926 const char *destination_port);
929 * Remove a connection between two ports.
931 * @pre The port types must be identical.
933 * @pre The @ref JackPortFlags of the @a source_port must include @ref
934 * JackPortIsOutput.
936 * @pre The @ref JackPortFlags of the @a destination_port must include
937 * @ref JackPortIsInput.
939 * @return 0 on success, otherwise a non-zero error code
941 int jack_disconnect (jack_client_t *,
942 const char *source_port,
943 const char *destination_port);
946 * Perform the same function as jack_disconnect() using port handles
947 * rather than names. This avoids the name lookup inherent in the
948 * name-based version.
950 * Clients connecting their own ports are likely to use this function,
951 * while generic connection clients (e.g. patchbays) would use
952 * jack_disconnect().
954 int jack_port_disconnect (jack_client_t *, jack_port_t *);
957 * @return the maximum number of characters in a full JACK port name
958 * including the final NULL character. This value is a constant.
960 * A port's full name contains the owning client name concatenated
961 * with a colon (:) followed by its short name and a NULL
962 * character.
964 int jack_port_name_size(void);
967 * @return the maximum number of characters in a JACK port type name
968 * including the final NULL character. This value is a constant.
970 int jack_port_type_size(void);
972 /*@}*/
975 * @defgroup PortSearching Looking up ports
976 * @{
980 * @param port_name_pattern A regular expression used to select
981 * ports by name. If NULL or of zero length, no selection based
982 * on name will be carried out.
983 * @param type_name_pattern A regular expression used to select
984 * ports by type. If NULL or of zero length, no selection based
985 * on type will be carried out.
986 * @param flags A value used to select ports by their flags.
987 * If zero, no selection based on flags will be carried out.
989 * @return a NULL-terminated array of ports that match the specified
990 * arguments. The caller is responsible for calling free(3) any
991 * non-NULL returned value.
993 * @see jack_port_name_size(), jack_port_type_size()
995 const char ** jack_get_ports (jack_client_t *,
996 const char *port_name_pattern,
997 const char *type_name_pattern,
998 unsigned long flags);
1001 * @return address of the jack_port_t named @a port_name.
1003 * @see jack_port_name_size()
1005 jack_port_t * jack_port_by_name (jack_client_t *, const char *port_name);
1008 * @return address of the jack_port_t of a @a port_id.
1010 jack_port_t * jack_port_by_id (jack_client_t *client,
1011 jack_port_id_t port_id);
1013 /*@}*/
1016 * @defgroup TimeFunctions Handling time
1017 * @{
1019 * JACK time is in units of 'frames', according to the current sample rate.
1020 * The absolute value of frame times is meaningless, frame times have meaning
1021 * only relative to each other.
1025 * @return the estimated time in frames that has passed since the JACK
1026 * server began the current process cycle.
1028 jack_nframes_t jack_frames_since_cycle_start (const jack_client_t *);
1031 * @return the estimated current time in frames.
1032 * This function is intended for use in other threads (not the process
1033 * callback). The return value can be compared with the value of
1034 * jack_last_frame_time to relate time in other threads to JACK time.
1036 jack_nframes_t jack_frame_time (const jack_client_t *);
1039 * @return the precise time at the start of the current process cycle.
1040 * This function may only be used from the process callback, and can
1041 * be used to interpret timestamps generated by jack_frame_time() in
1042 * other threads with respect to the current process cycle.
1044 * This is the only jack time function that returns exact time:
1045 * when used during the process callback it always returns the same
1046 * value (until the next process callback, where it will return
1047 * that value + nframes, etc). The return value is guaranteed to be
1048 * monotonic and linear in this fashion unless an xrun occurs.
1049 * If an xrun occurs, clients must check this value again, as time
1050 * may have advanced in a non-linear way (e.g. cycles may have been skipped).
1052 jack_nframes_t jack_last_frame_time (const jack_client_t *client);
1055 * @return the estimated time in microseconds of the specified frame time
1057 jack_time_t jack_frames_to_time(const jack_client_t *client, jack_nframes_t);
1060 * @return the estimated time in frames for the specified system time.
1062 jack_nframes_t jack_time_to_frames(const jack_client_t *client, jack_time_t);
1065 * @return return JACK's current system time in microseconds,
1066 * using the JACK clock source.
1068 * The value returned is guaranteed to be monotonic, but not linear.
1070 jack_time_t jack_get_time();
1072 /*@}*/
1075 * @defgroup ErrorOutput Controlling error/information output
1077 /*@{*/
1080 * Display JACK error message.
1082 * Set via jack_set_error_function(), otherwise a JACK-provided
1083 * default will print @a msg (plus a newline) to stderr.
1085 * @param msg error message text (no newline at end).
1087 extern void (*jack_error_callback)(const char *msg);
1090 * Set the @ref jack_error_callback for error message display.
1091 * Set it to NULL to restore default_jack_error_callback function.
1093 * The JACK library provides two built-in callbacks for this purpose:
1094 * default_jack_error_callback() and silent_jack_error_callback().
1096 void jack_set_error_function (void (*func)(const char *));
1099 * Display JACK info message.
1101 * Set via jack_set_info_function(), otherwise a JACK-provided
1102 * default will print @a msg (plus a newline) to stdout.
1104 * @param msg info message text (no newline at end).
1106 extern void (*jack_info_callback)(const char *msg);
1109 * Set the @ref jack_info_callback for info message display.
1110 * Set it to NULL to restore default_jack_info_callback function.
1112 * The JACK library provides two built-in callbacks for this purpose:
1113 * default_jack_info_callback() and silent_jack_info_callback().
1115 void jack_set_info_function (void (*func)(const char *));
1117 /*@}*/
1120 * The free function to be used on memory returned by jack_port_get_connections,
1121 * jack_port_get_all_connections and jack_get_ports functions.
1122 * This is MANDATORY on Windows when otherwise all nasty runtime version related crashes can occur.
1123 * Developers are strongly encouraged to use this function instead of the standard "free" function in new code.
1126 void jack_free(void* ptr);
1129 #ifdef __cplusplus
1131 #endif
1133 #endif /* __jack_h__ */