Add a string parameter to server ==> client notification, add a new InfoShutdown...
[jack2.git] / common / jack / jack.h
blobebdded774f4c6baa15c5678e07b3fbbbfad4209a
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 * @deprecated 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 void jack_on_shutdown (jack_client_t *client,
299 JackShutdownCallback shutdown_callback, void *arg);
302 * @param client pointer to JACK client structure.
303 * @param function The jack_shutdown function pointer.
304 * @param arg The arguments for the jack_shutdown function.
306 * Register a function (and argument) to be called if and when the
307 * JACK server shuts down the client thread. The function must
308 * be written as if it were an asynchonrous POSIX signal
309 * handler --- use only async-safe functions, and remember that it
310 * is executed from another thread. A typical function might
311 * set a flag or write to a pipe so that the rest of the
312 * application knows that the JACK client thread has shut
313 * down.
315 * NOTE: clients do not need to call this. It exists only
316 * to help more complex clients understand what is going
317 * on. It should be called before jack_client_activate().
319 void jack_on_info_shutdown (jack_client_t *client,
320 JackInfoShutdownCallback shutdown_callback, void *arg);
323 * Tell the Jack server to call @a process_callback whenever there is
324 * work be done, passing @a arg as the second argument.
326 * The code in the supplied function must be suitable for real-time
327 * execution. That means that it cannot call functions that might
328 * block for a long time. This includes malloc, free, printf,
329 * pthread_mutex_lock, sleep, wait, poll, select, pthread_join,
330 * pthread_cond_wait, etc, etc. See
331 * http://jackit.sourceforge.net/docs/design/design.html#SECTION00411000000000000000
332 * for more information.
334 * NOTE: this function cannot be called while the client is activated
335 * (after jack_activate has been called.)
337 * @return 0 on success, otherwise a non-zero error code.
339 int jack_set_process_callback (jack_client_t *client,
340 JackProcessCallback process_callback,
341 void *arg);
344 * Tell the Jack server to call @a freewheel_callback
345 * whenever we enter or leave "freewheel" mode, passing @a
346 * arg as the second argument. The first argument to the
347 * callback will be non-zero if JACK is entering freewheel
348 * mode, and zero otherwise.
350 * All "notification events" are received in a seperated non RT thread,
351 * the code in the supplied function does not need to be
352 * suitable for real-time execution.
354 * NOTE: this function cannot be called while the client is activated
355 * (after jack_activate has been called.)
357 * @return 0 on success, otherwise a non-zero error code.
359 int jack_set_freewheel_callback (jack_client_t *client,
360 JackFreewheelCallback freewheel_callback,
361 void *arg);
364 * Tell JACK to call @a bufsize_callback whenever the size of the the
365 * buffer that will be passed to the @a process_callback is about to
366 * change. Clients that depend on knowing the buffer size must supply
367 * a @a bufsize_callback before activating themselves.
369 * All "notification events" are received in a seperated non RT thread,
370 * the code in the supplied function does not need to be
371 * suitable for real-time execution.
373 * NOTE: this function cannot be called while the client is activated
374 * (after jack_activate has been called.)
376 * @param client pointer to JACK client structure.
377 * @param bufsize_callback function to call when the buffer size changes.
378 * @param arg argument for @a bufsize_callback.
380 * @return 0 on success, otherwise a non-zero error code
382 int jack_set_buffer_size_callback (jack_client_t *client,
383 JackBufferSizeCallback bufsize_callback,
384 void *arg);
387 * Tell the Jack server to call @a srate_callback whenever the system
388 * sample rate changes.
390 * All "notification events" are received in a seperated non RT thread,
391 * the code in the supplied function does not need to be
392 * suitable for real-time execution.
394 * NOTE: this function cannot be called while the client is activated
395 * (after jack_activate has been called.)
397 * @return 0 on success, otherwise a non-zero error code
399 int jack_set_sample_rate_callback (jack_client_t *client,
400 JackSampleRateCallback srate_callback,
401 void *arg);
404 * Tell the JACK server to call @a registration_callback whenever a
405 * port is registered or unregistered, passing @a arg as a parameter.
407 * All "notification events" are received in a seperated non RT thread,
408 * the code in the supplied function does not need to be
409 * suitable for real-time execution.
411 * NOTE: this function cannot be called while the client is activated
412 * (after jack_activate has been called.)
414 * @return 0 on success, otherwise a non-zero error code
416 int jack_set_client_registration_callback (jack_client_t *,
417 JackClientRegistrationCallback
418 registration_callback, void *arg);
421 * Tell the JACK server to call @a registration_callback whenever a
422 * port is registered or unregistered, passing @a arg as a parameter.
424 * All "notification events" are received in a seperated non RT thread,
425 * the code in the supplied function does not need to be
426 * suitable for real-time execution.
428 * NOTE: this function cannot be called while the client is activated
429 * (after jack_activate has been called.)
431 * @return 0 on success, otherwise a non-zero error code
433 int jack_set_port_registration_callback (jack_client_t *,
434 JackPortRegistrationCallback
435 registration_callback, void *arg);
438 * Tell the JACK server to call @a connect_callback whenever a
439 * port is connected or disconnected, passing @a arg as a parameter.
441 * All "notification events" are received in a seperated non RT thread,
442 * the code in the supplied function does not need to be
443 * suitable for real-time execution.
445 * NOTE: this function cannot be called while the client is activated
446 * (after jack_activate has been called.)
448 * @return 0 on success, otherwise a non-zero error code
450 int jack_set_port_connect_callback (jack_client_t *,
451 JackPortConnectCallback
452 connect_callback, void *arg);
455 * Tell the JACK server to call @a rename_callback whenever a
456 * port is renamed, passing @a arg as a parameter.
458 * All "notification events" are received in a seperated non RT thread,
459 * the code in the supplied function does not need to be
460 * suitable for real-time execution.
462 * NOTE: this function cannot be called while the client is activated
463 * (after jack_activate has been called.)
465 * @return 0 on success, otherwise a non-zero error code
467 int jack_set_port_rename_callback (jack_client_t *,
468 JackPortRenameCallback
469 rename_callback, void *arg);
472 * Tell the JACK server to call @a graph_callback whenever the
473 * processing graph is reordered, passing @a arg as a parameter.
475 * All "notification events" are received in a seperated non RT thread,
476 * the code in the supplied function does not need to be
477 * suitable for real-time execution.
479 * NOTE: this function cannot be called while the client is activated
480 * (after jack_activate has been called.)
482 * @return 0 on success, otherwise a non-zero error code
484 int jack_set_graph_order_callback (jack_client_t *,
485 JackGraphOrderCallback graph_callback,
486 void *);
489 * Tell the JACK server to call @a xrun_callback whenever there is a
490 * xrun, passing @a arg as a parameter.
492 * All "notification events" are received in a seperated non RT thread,
493 * the code in the supplied function does not need to be
494 * suitable for real-time execution.
496 * NOTE: this function cannot be called while the client is activated
497 * (after jack_activate has been called.)
499 * @return 0 on success, otherwise a non-zero error code
501 int jack_set_xrun_callback (jack_client_t *,
502 JackXRunCallback xrun_callback, void *arg);
504 /*@}*/
507 * @defgroup ServerClientControl Controlling & querying JACK server operation
508 * @{
512 * Start/Stop JACK's "freewheel" mode.
514 * When in "freewheel" mode, JACK no longer waits for
515 * any external event to begin the start of the next process
516 * cycle.
518 * As a result, freewheel mode causes "faster than realtime"
519 * execution of a JACK graph. If possessed, real-time
520 * scheduling is dropped when entering freewheel mode, and
521 * if appropriate it is reacquired when stopping.
523 * IMPORTANT: on systems using capabilities to provide real-time
524 * scheduling (i.e. Linux kernel 2.4), if onoff is zero, this function
525 * must be called from the thread that originally called jack_activate().
526 * This restriction does not apply to other systems (e.g. Linux kernel 2.6
527 * or OS X).
529 * @param client pointer to JACK client structure
530 * @param onoff if non-zero, freewheel mode starts. Otherwise
531 * freewheel mode ends.
533 * @return 0 on success, otherwise a non-zero error code.
535 int jack_set_freewheel(jack_client_t* client, int onoff);
538 * Change the buffer size passed to the @a process_callback.
540 * This operation stops the JACK engine process cycle, then calls all
541 * registered @a bufsize_callback functions before restarting the
542 * process cycle. This will cause a gap in the audio flow, so it
543 * should only be done at appropriate stopping points.
545 * @see jack_set_buffer_size_callback()
547 * @param client pointer to JACK client structure.
548 * @param nframes new buffer size. Must be a power of two.
550 * @return 0 on success, otherwise a non-zero error code
552 int jack_set_buffer_size (jack_client_t *client, jack_nframes_t nframes);
555 * @return the sample rate of the jack system, as set by the user when
556 * jackd was started.
558 jack_nframes_t jack_get_sample_rate (jack_client_t *);
561 * @return the current maximum size that will ever be passed to the @a
562 * process_callback. It should only be used *before* the client has
563 * been activated. This size may change, clients that depend on it
564 * must register a @a bufsize_callback so they will be notified if it
565 * does.
567 * @see jack_set_buffer_size_callback()
569 jack_nframes_t jack_get_buffer_size (jack_client_t *);
572 * Old-style interface to become the timebase for the entire JACK
573 * subsystem.
575 * @deprecated This function still exists for compatibility with the
576 * earlier transport interface, but it does nothing. Instead, see
577 * transport.h and use jack_set_timebase_callback().
579 * @return ENOSYS, function not implemented.
581 int jack_engine_takeover_timebase (jack_client_t *);
584 * @return the current CPU load estimated by JACK. This is a running
585 * average of the time it takes to execute a full process cycle for
586 * all clients as a percentage of the real time available per cycle
587 * determined by the buffer size and sample rate.
589 float jack_cpu_load (jack_client_t *client);
591 /*@}*/
594 * @defgroup PortFunctions Creating & manipulating ports
595 * @{
599 * Create a new port for the client. This is an object used for moving
600 * data of any type in or out of the client. Ports may be connected
601 * in various ways.
603 * Each port has a short name. The port's full name contains the name
604 * of the client concatenated with a colon (:) followed by its short
605 * name. The jack_port_name_size() is the maximum length of this full
606 * name. Exceeding that will cause the port registration to fail and
607 * return NULL.
609 * All ports have a type, which may be any non-NULL and non-zero
610 * length string, passed as an argument. Some port types are built
611 * into the JACK API, currently only JACK_DEFAULT_AUDIO_TYPE.
613 * @param client pointer to JACK client structure.
614 * @param port_name non-empty short name for the new port (not
615 * including the leading @a "client_name:").
616 * @param port_type port type name. If longer than
617 * jack_port_type_size(), only that many characters are significant.
618 * @param flags @ref JackPortFlags bit mask.
619 * @param buffer_size must be non-zero if this is not a built-in @a
620 * port_type. Otherwise, it is ignored.
622 * @return jack_port_t pointer on success, otherwise NULL.
624 jack_port_t * jack_port_register (jack_client_t *client,
625 const char *port_name,
626 const char *port_type,
627 unsigned long flags,
628 unsigned long buffer_size);
631 * Remove the port from the client, disconnecting any existing
632 * connections.
634 * @return 0 on success, otherwise a non-zero error code
636 int jack_port_unregister (jack_client_t *, jack_port_t *);
639 * This returns a pointer to the memory area associated with the
640 * specified port. For an output port, it will be a memory area
641 * that can be written to; for an input port, it will be an area
642 * containing the data from the port's connection(s), or
643 * zero-filled. if there are multiple inbound connections, the data
644 * will be mixed appropriately.
646 * FOR OUTPUT PORTS ONLY : DEPRECATED in Jack 2.0 !!
647 * ---------------------------------------------------
648 * You may cache the value returned, but only between calls to
649 * your "blocksize" callback. For this reason alone, you should
650 * either never cache the return value or ensure you have
651 * a "blocksize" callback and be sure to invalidate the cached
652 * address from there.
654 * Caching output ports is DEPRECATED in Jack 2.0, due to some new optimization (like "pipelining").
655 * Port buffers have to be retrieved in each callback for proper functionning.
657 void * jack_port_get_buffer (jack_port_t *, jack_nframes_t);
660 * @return the full name of the jack_port_t (including the @a
661 * "client_name:" prefix).
663 * @see jack_port_name_size().
665 const char * jack_port_name (const jack_port_t *port);
668 * @return the short name of the jack_port_t (not including the @a
669 * "client_name:" prefix).
671 * @see jack_port_name_size().
673 const char * jack_port_short_name (const jack_port_t *port);
676 * @return the @ref JackPortFlags of the jack_port_t.
678 int jack_port_flags (const jack_port_t *port);
681 * @return the @a port type, at most jack_port_type_size() characters
682 * including a final NULL.
684 const char * jack_port_type (const jack_port_t *port);
687 * @return the @a port type id.
689 jack_port_type_id_t jack_port_type_id (const jack_port_t *port);
692 * @return TRUE if the jack_port_t belongs to the jack_client_t.
694 int jack_port_is_mine (const jack_client_t *, const jack_port_t *port);
697 * @return number of connections to or from @a port.
699 * @pre The calling client must own @a port.
701 int jack_port_connected (const jack_port_t *port);
704 * @return TRUE if the locally-owned @a port is @b directly connected
705 * to the @a port_name.
707 * @see jack_port_name_size()
709 int jack_port_connected_to (const jack_port_t *port,
710 const char *port_name);
713 * @return a null-terminated array of full port names to which the @a
714 * port is connected. If none, returns NULL.
716 * The caller is responsible for calling free(3) on any non-NULL
717 * returned value.
719 * @param port locally owned jack_port_t pointer.
721 * @see jack_port_name_size(), jack_port_get_all_connections()
723 const char ** jack_port_get_connections (const jack_port_t *port);
726 * @return a null-terminated array of full port names to which the @a
727 * port is connected. If none, returns NULL.
729 * The caller is responsible for calling free(3) on any non-NULL
730 * returned value.
732 * This differs from jack_port_get_connections() in two important
733 * respects:
735 * 1) You may not call this function from code that is
736 * executed in response to a JACK event. For example,
737 * you cannot use it in a GraphReordered handler.
739 * 2) You need not be the owner of the port to get information
740 * about its connections.
742 * @see jack_port_name_size()
744 const char ** jack_port_get_all_connections (const jack_client_t *client,
745 const jack_port_t *port);
749 * @deprecated This function will be removed from a future version
750 * of JACK. Do not use it. There is no replacement. It has
751 * turned out to serve essentially no purpose in real-life
752 * JACK clients.
754 int jack_port_tie (jack_port_t *src, jack_port_t *dst);
758 * @deprecated This function will be removed from a future version
759 * of JACK. Do not use it. There is no replacement. It has
760 * turned out to serve essentially no purpose in real-life
761 * JACK clients.
763 int jack_port_untie (jack_port_t *port);
766 * @return the time (in frames) between data being available or
767 * delivered at/to a port, and the time at which it arrived at or is
768 * delivered to the "other side" of the port. E.g. for a physical
769 * audio output port, this is the time between writing to the port and
770 * when the signal will leave the connector. For a physical audio
771 * input port, this is the time between the sound arriving at the
772 * connector and the corresponding frames being readable from the
773 * port.
775 jack_nframes_t jack_port_get_latency (jack_port_t *port);
778 * The maximum of the sum of the latencies in every
779 * connection path that can be drawn between the port and other
780 * ports with the @ref JackPortIsTerminal flag set.
782 jack_nframes_t jack_port_get_total_latency (jack_client_t *,
783 jack_port_t *port);
786 * The port latency is zero by default. Clients that control
787 * physical hardware with non-zero latency should call this
788 * to set the latency to its correct value. Note that the value
789 * should include any systemic latency present "outside" the
790 * physical hardware controlled by the client. For example,
791 * for a client controlling a digital audio interface connected
792 * to an external digital converter, the latency setting should
793 * include both buffering by the audio interface *and* the converter.
795 void jack_port_set_latency (jack_port_t *, jack_nframes_t);
798 * Request a complete recomputation of a port's total latency. This
799 * can be called by a client that has just changed the internal
800 * latency of its port using @function jack_port_set_latency
801 * and wants to ensure that all signal pathways in the graph
802 * are updated with respect to the values that will be returned
803 * by @function jack_port_get_total_latency.
805 * @return zero for successful execution of the request. non-zero
806 * otherwise.
808 int jack_recompute_total_latency (jack_client_t*, jack_port_t* port);
811 * Request a complete recomputation of all port latencies. This
812 * can be called by a client that has just changed the internal
813 * latency of its port using @function jack_port_set_latency
814 * and wants to ensure that all signal pathways in the graph
815 * are updated with respect to the values that will be returned
816 * by @function jack_port_get_total_latency. It allows a client
817 * to change multiple port latencies without triggering a
818 * recompute for each change.
820 * @return zero for successful execution of the request. non-zero
821 * otherwise.
823 int jack_recompute_total_latencies (jack_client_t*);
826 * Modify a port's short name. May be called at any time. If the
827 * resulting full name (including the @a "client_name:" prefix) is
828 * longer than jack_port_name_size(), it will be truncated.
830 * @return 0 on success, otherwise a non-zero error code.
832 int jack_port_set_name (jack_port_t *port, const char *port_name);
835 * Set @a alias as an alias for @a port. May be called at any time.
836 * If the alias is longer than jack_port_name_size(), it will be truncated.
838 * After a successful call, and until JACK exits or
839 * @function jack_port_unset_alias() is called, @alias may be
840 * used as a alternate name for the port.
842 * Ports can have up to two aliases - if both are already
843 * set, this function will return an error.
845 * @return 0 on success, otherwise a non-zero error code.
847 int jack_port_set_alias (jack_port_t *port, const char *alias);
850 * Remove @a alias as an alias for @a port. May be called at any time.
852 * After a successful call, @a alias can no longer be
853 * used as a alternate name for the port.
855 * @return 0 on success, otherwise a non-zero error code.
857 int jack_port_unset_alias (jack_port_t *port, const char *alias);
860 * Get any aliases known for @port.
862 * @return the number of aliases discovered for the port
864 int jack_port_get_aliases (const jack_port_t *port, char* const aliases[2]);
867 * If @ref JackPortCanMonitor is set for this @a port, turn input
868 * monitoring on or off. Otherwise, do nothing.
870 int jack_port_request_monitor (jack_port_t *port, int onoff);
873 * If @ref JackPortCanMonitor is set for this @a port_name, turn input
874 * monitoring on or off. Otherwise, do nothing.
876 * @return 0 on success, otherwise a non-zero error code.
878 * @see jack_port_name_size()
880 int jack_port_request_monitor_by_name (jack_client_t *client,
881 const char *port_name, int onoff);
884 * If @ref JackPortCanMonitor is set for a port, this function turns
885 * on input monitoring if it was off, and turns it off if only one
886 * request has been made to turn it on. Otherwise it does nothing.
888 * @return 0 on success, otherwise a non-zero error code
890 int jack_port_ensure_monitor (jack_port_t *port, int onoff);
893 * @return TRUE if input monitoring has been requested for @a port.
895 int jack_port_monitoring_input (jack_port_t *port);
898 * Establish a connection between two ports.
900 * When a connection exists, data written to the source port will
901 * be available to be read at the destination port.
903 * @pre The port types must be identical.
905 * @pre The @ref JackPortFlags of the @a source_port must include @ref
906 * JackPortIsOutput.
908 * @pre The @ref JackPortFlags of the @a destination_port must include
909 * @ref JackPortIsInput.
911 * @return 0 on success, EEXIST if the connection is already made,
912 * otherwise a non-zero error code
914 int jack_connect (jack_client_t *,
915 const char *source_port,
916 const char *destination_port);
919 * Remove a connection between two ports.
921 * @pre The port types must be identical.
923 * @pre The @ref JackPortFlags of the @a source_port must include @ref
924 * JackPortIsOutput.
926 * @pre The @ref JackPortFlags of the @a destination_port must include
927 * @ref JackPortIsInput.
929 * @return 0 on success, otherwise a non-zero error code
931 int jack_disconnect (jack_client_t *,
932 const char *source_port,
933 const char *destination_port);
936 * Perform the same function as jack_disconnect() using port handles
937 * rather than names. This avoids the name lookup inherent in the
938 * name-based version.
940 * Clients connecting their own ports are likely to use this function,
941 * while generic connection clients (e.g. patchbays) would use
942 * jack_disconnect().
944 int jack_port_disconnect (jack_client_t *, jack_port_t *);
947 * @return the maximum number of characters in a full JACK port name
948 * including the final NULL character. This value is a constant.
950 * A port's full name contains the owning client name concatenated
951 * with a colon (:) followed by its short name and a NULL
952 * character.
954 int jack_port_name_size(void);
957 * @return the maximum number of characters in a JACK port type name
958 * including the final NULL character. This value is a constant.
960 int jack_port_type_size(void);
962 /*@}*/
965 * @defgroup PortSearching Looking up ports
966 * @{
970 * @param port_name_pattern A regular expression used to select
971 * ports by name. If NULL or of zero length, no selection based
972 * on name will be carried out.
973 * @param type_name_pattern A regular expression used to select
974 * ports by type. If NULL or of zero length, no selection based
975 * on type will be carried out.
976 * @param flags A value used to select ports by their flags.
977 * If zero, no selection based on flags will be carried out.
979 * @return a NULL-terminated array of ports that match the specified
980 * arguments. The caller is responsible for calling free(3) any
981 * non-NULL returned value.
983 * @see jack_port_name_size(), jack_port_type_size()
985 const char ** jack_get_ports (jack_client_t *,
986 const char *port_name_pattern,
987 const char *type_name_pattern,
988 unsigned long flags);
991 * @return address of the jack_port_t named @a port_name.
993 * @see jack_port_name_size()
995 jack_port_t * jack_port_by_name (jack_client_t *, const char *port_name);
998 * @return address of the jack_port_t of a @a port_id.
1000 jack_port_t * jack_port_by_id (jack_client_t *client,
1001 jack_port_id_t port_id);
1003 /*@}*/
1006 * @defgroup TimeFunctions Handling time
1007 * @{
1009 * JACK time is in units of 'frames', according to the current sample rate.
1010 * The absolute value of frame times is meaningless, frame times have meaning
1011 * only relative to each other.
1015 * @return the estimated time in frames that has passed since the JACK
1016 * server began the current process cycle.
1018 jack_nframes_t jack_frames_since_cycle_start (const jack_client_t *);
1021 * @return the estimated current time in frames.
1022 * This function is intended for use in other threads (not the process
1023 * callback). The return value can be compared with the value of
1024 * jack_last_frame_time to relate time in other threads to JACK time.
1026 jack_nframes_t jack_frame_time (const jack_client_t *);
1029 * @return the precise time at the start of the current process cycle.
1030 * This function may only be used from the process callback, and can
1031 * be used to interpret timestamps generated by jack_frame_time() in
1032 * other threads with respect to the current process cycle.
1034 * This is the only jack time function that returns exact time:
1035 * when used during the process callback it always returns the same
1036 * value (until the next process callback, where it will return
1037 * that value + nframes, etc). The return value is guaranteed to be
1038 * monotonic and linear in this fashion unless an xrun occurs.
1039 * If an xrun occurs, clients must check this value again, as time
1040 * may have advanced in a non-linear way (e.g. cycles may have been skipped).
1042 jack_nframes_t jack_last_frame_time (const jack_client_t *client);
1045 * @return the estimated time in microseconds of the specified frame time
1047 jack_time_t jack_frames_to_time(const jack_client_t *client, jack_nframes_t);
1050 * @return the estimated time in frames for the specified system time.
1052 jack_nframes_t jack_time_to_frames(const jack_client_t *client, jack_time_t);
1055 * @return return JACK's current system time in microseconds,
1056 * using the JACK clock source.
1058 * The value returned is guaranteed to be monotonic, but not linear.
1060 jack_time_t jack_get_time();
1062 /*@}*/
1065 * @defgroup ErrorOutput Controlling error/information output
1067 /*@{*/
1070 * Display JACK error message.
1072 * Set via jack_set_error_function(), otherwise a JACK-provided
1073 * default will print @a msg (plus a newline) to stderr.
1075 * @param msg error message text (no newline at end).
1077 extern void (*jack_error_callback)(const char *msg);
1080 * Set the @ref jack_error_callback for error message display.
1081 * Set it to NULL to restore default_jack_error_callback function.
1083 * The JACK library provides two built-in callbacks for this purpose:
1084 * default_jack_error_callback() and silent_jack_error_callback().
1086 void jack_set_error_function (void (*func)(const char *));
1089 * Display JACK info message.
1091 * Set via jack_set_info_function(), otherwise a JACK-provided
1092 * default will print @a msg (plus a newline) to stdout.
1094 * @param msg info message text (no newline at end).
1096 extern void (*jack_info_callback)(const char *msg);
1099 * Set the @ref jack_info_callback for info message display.
1100 * Set it to NULL to restore default_jack_info_callback function.
1102 * The JACK library provides two built-in callbacks for this purpose:
1103 * default_jack_info_callback() and silent_jack_info_callback().
1105 void jack_set_info_function (void (*func)(const char *));
1107 /*@}*/
1110 * The free function to be used on memory returned by jack_port_get_connections,
1111 * jack_port_get_all_connections and jack_get_ports functions.
1112 * This is MANDATORY on Windows when otherwise all nasty runtime version related crashes can occur.
1113 * Developers are strongly encouraged to use this function instead of the standard "free" function in new code.
1116 void jack_free(void* ptr);
1119 #ifdef __cplusplus
1121 #endif
1123 #endif /* __jack_h__ */