summaryrefslogtreecommitdiffstats
path: root/pipewire-jack/jack
diff options
context:
space:
mode:
Diffstat (limited to 'pipewire-jack/jack')
-rw-r--r--pipewire-jack/jack/control.h658
-rw-r--r--pipewire-jack/jack/intclient.h130
-rw-r--r--pipewire-jack/jack/jack.h1477
-rw-r--r--pipewire-jack/jack/jslist.h293
-rw-r--r--pipewire-jack/jack/metadata.h322
-rw-r--r--pipewire-jack/jack/midiport.h197
-rw-r--r--pipewire-jack/jack/net.h429
-rw-r--r--pipewire-jack/jack/ringbuffer.h243
-rw-r--r--pipewire-jack/jack/session.h302
-rw-r--r--pipewire-jack/jack/statistics.h57
-rw-r--r--pipewire-jack/jack/systemdeps.h141
-rw-r--r--pipewire-jack/jack/thread.h160
-rw-r--r--pipewire-jack/jack/transport.h247
-rw-r--r--pipewire-jack/jack/types.h740
-rw-r--r--pipewire-jack/jack/uuid.h50
-rw-r--r--pipewire-jack/jack/weakjack.h125
-rw-r--r--pipewire-jack/jack/weakmacros.h97
17 files changed, 5668 insertions, 0 deletions
diff --git a/pipewire-jack/jack/control.h b/pipewire-jack/jack/control.h
new file mode 100644
index 0000000..e466abc
--- /dev/null
+++ b/pipewire-jack/jack/control.h
@@ -0,0 +1,658 @@
+/* -*- Mode: C ; c-basic-offset: 4 -*- */
+/*
+ JACK control API
+
+ Copyright (C) 2008 Nedko Arnaudov
+ Copyright (C) 2008 GRAME
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+/**
+ * @file jack/control.h
+ * @ingroup publicheader
+ * @brief JACK control API
+ *
+ */
+
+#ifndef JACKCTL_H__2EEDAD78_DF4C_4B26_83B7_4FF1A446A47E__INCLUDED
+#define JACKCTL_H__2EEDAD78_DF4C_4B26_83B7_4FF1A446A47E__INCLUDED
+
+#include <jack/types.h>
+#include <jack/jslist.h>
+#include <jack/systemdeps.h>
+#if !defined(sun) && !defined(__sun__)
+#include <stdbool.h>
+#endif
+
+/** Parameter types, intentionally similar to jack_driver_param_type_t */
+typedef enum
+{
+ JackParamInt = 1, /**< @brief value type is a signed integer */
+ JackParamUInt, /**< @brief value type is an unsigned integer */
+ JackParamChar, /**< @brief value type is a char */
+ JackParamString, /**< @brief value type is a string with max size of ::JACK_PARAM_STRING_MAX+1 chars */
+ JackParamBool, /**< @brief value type is a boolean */
+} jackctl_param_type_t;
+
+/** Driver types */
+typedef enum
+{
+ JackMaster = 1, /**< @brief master driver */
+ JackSlave /**< @brief slave driver */
+} jackctl_driver_type_t;
+
+/** @brief Max value that jackctl_param_type_t type can have */
+#define JACK_PARAM_MAX (JackParamBool + 1)
+
+/** @brief Max length of string parameter value, excluding terminating null char */
+#define JACK_PARAM_STRING_MAX 127
+
+/** @brief Type for parameter value */
+/* intentionally similar to jack_driver_param_value_t */
+union jackctl_parameter_value
+{
+ uint32_t ui; /**< @brief member used for ::JackParamUInt */
+ int32_t i; /**< @brief member used for ::JackParamInt */
+ char c; /**< @brief member used for ::JackParamChar */
+ char str[JACK_PARAM_STRING_MAX + 1]; /**< @brief member used for ::JackParamString */
+ bool b; /**< @brief member used for ::JackParamBool */
+};
+
+/** opaque type for server object */
+typedef struct jackctl_server jackctl_server_t;
+
+/** opaque type for driver object */
+typedef struct jackctl_driver jackctl_driver_t;
+
+/** opaque type for internal client object */
+typedef struct jackctl_internal jackctl_internal_t;
+
+/** opaque type for parameter object */
+typedef struct jackctl_parameter jackctl_parameter_t;
+
+/** opaque type for sigmask object */
+typedef struct jackctl_sigmask jackctl_sigmask_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+#if 0
+} /* Adjust editor indent */
+#endif
+
+/**
+ * @defgroup ControlAPI The API for starting and controlling a JACK server
+ * @{
+ */
+
+/**
+ * Call this function to setup process signal handling. As a general
+ * rule, it is required for proper operation for the server object.
+ *
+ * @param flags signals setup flags, use 0 for none. Currently no
+ * flags are defined
+ *
+ * @return the configurated signal set.
+ */
+jackctl_sigmask_t *
+jackctl_setup_signals(
+ unsigned int flags);
+
+/**
+ * Call this function to wait on a signal set.
+ *
+ * @param signals signals set to wait on
+ */
+void
+jackctl_wait_signals(
+ jackctl_sigmask_t * signals);
+
+/**
+ * \bold THIS FUNCTION IS DEPRECATED AND SHOULD NOT BE USED IN
+ * NEW JACK PROJECTS
+ *
+ * @deprecated Please use jackctl_server_create2().
+ */
+jackctl_server_t *
+jackctl_server_create(
+ bool (* on_device_acquire)(const char * device_name),
+ void (* on_device_release)(const char * device_name));
+
+/**
+ * Call this function to create server object.
+ *
+ * @param on_device_acquire - Optional callback to be called before device is acquired. If false is returned, device usage will fail
+ * @param on_device_release - Optional callback to be called after device is released.
+ * @param on_device_reservation_loop - Optional callback to be called when looping/idling the reservation.
+ *
+ * @return server object handle, NULL if creation of server object
+ * failed. Successfully created server object must be destroyed with
+ * paired call to ::jackctl_server_destroy
+ */
+jackctl_server_t *
+jackctl_server_create2(
+ bool (* on_device_acquire)(const char * device_name),
+ void (* on_device_release)(const char * device_name),
+ void (* on_device_reservation_loop)(void));
+
+/**
+ * Call this function to destroy server object.
+ *
+ * @param server server object handle to destroy
+ */
+void
+jackctl_server_destroy(
+ jackctl_server_t * server);
+
+/**
+ * Call this function to open JACK server
+ *
+ * @param server server object handle
+ * @param driver driver to use
+ *
+ * @return success status: true - success, false - fail
+ */
+bool
+jackctl_server_open(
+ jackctl_server_t * server,
+ jackctl_driver_t * driver);
+
+/**
+ * Call this function to start JACK server
+ *
+ * @param server server object handle
+ *
+ * @return success status: true - success, false - fail
+ */
+bool
+jackctl_server_start(
+ jackctl_server_t * server);
+
+/**
+ * Call this function to stop JACK server
+ *
+ * @param server server object handle
+ *
+ * @return success status: true - success, false - fail
+ */
+bool
+jackctl_server_stop(
+ jackctl_server_t * server);
+
+/**
+ * Call this function to close JACK server
+ *
+ * @param server server object handle
+ *
+ * @return success status: true - success, false - fail
+ */
+bool
+jackctl_server_close(
+ jackctl_server_t * server);
+
+/**
+ * Call this function to get list of available drivers. List node data
+ * pointers is a driver object handle (::jackctl_driver_t).
+ *
+ * @param server server object handle to get drivers for
+ *
+ * @return Single linked list of driver object handles. Must not be
+ * modified. Always same for same server object.
+ */
+const JSList *
+jackctl_server_get_drivers_list(
+ jackctl_server_t * server);
+
+/**
+ * Call this function to get list of server parameters. List node data
+ * pointers is a parameter object handle (::jackctl_parameter_t).
+ *
+ * @param server server object handle to get parameters for
+ *
+ * @return Single linked list of parameter object handles. Must not be
+ * modified. Always same for same server object.
+ */
+const JSList *
+jackctl_server_get_parameters(
+ jackctl_server_t * server);
+
+/**
+ * Call this function to get list of available internal clients. List node data
+ * pointers is a internal client object handle (::jackctl_internal_t).
+ *
+ * @param server server object handle to get internal clients for
+ *
+ * @return Single linked list of internal client object handles. Must not be
+ * modified. Always same for same server object.
+ */
+const JSList *
+jackctl_server_get_internals_list(
+ jackctl_server_t * server);
+
+/**
+ * Call this function to load one internal client.
+ * (can be used when the server is running)
+ *
+ * @param server server object handle
+ * @param internal internal to use
+ *
+ * @return success status: true - success, false - fail
+ */
+bool
+jackctl_server_load_internal(
+ jackctl_server_t * server,
+ jackctl_internal_t * internal);
+
+/**
+ * Call this function to unload one internal client.
+ * (can be used when the server is running)
+ *
+ * @param server server object handle
+ * @param internal internal to unload
+ *
+ * @return success status: true - success, false - fail
+ */
+bool
+jackctl_server_unload_internal(
+ jackctl_server_t * server,
+ jackctl_internal_t * internal);
+
+/**
+ * Call this function to load a session file.
+ * (can be used when the server is running)
+ *
+ * @param server server object handle
+ * @param file the session file to load, containing a list of
+ * internal clients and connections to be made.
+ *
+ * @return success status: true - success, false - fail
+ */
+bool jackctl_server_load_session_file(
+ jackctl_server_t * server_ptr,
+ const char * file);
+
+/**
+ * Call this function to add a slave in the driver slave list.
+ * (cannot be used when the server is running that is between
+ * jackctl_server_start and jackctl_server_stop)
+ *
+ * @param server server object handle
+ * @param driver driver to add in the driver slave list.
+ *
+ * @return success status: true - success, false - fail
+ */
+bool
+jackctl_server_add_slave(jackctl_server_t * server,
+ jackctl_driver_t * driver);
+
+/**
+ * Call this function to remove a slave from the driver slave list.
+ * (cannot be used when the server is running that is between
+ * jackctl_server_start and jackctl_server_stop)
+ *
+ * @param server server object handle
+ * @param driver driver to remove from the driver slave list.
+ *
+ * @return success status: true - success, false - fail
+ */
+bool
+jackctl_server_remove_slave(jackctl_server_t * server,
+ jackctl_driver_t * driver);
+
+/**
+ * Call this function to switch master driver.
+ *
+ * @param server server object handle
+ * @param driver driver to switch to
+ *
+ * @return success status: true - success, false - fail
+ */
+bool
+jackctl_server_switch_master(jackctl_server_t * server,
+ jackctl_driver_t * driver);
+
+
+/**
+ * Call this function to get name of driver.
+ *
+ * @param driver driver object handle to get name of
+ *
+ * @return driver name. Must not be modified. Always same for same
+ * driver object.
+ */
+const char *
+jackctl_driver_get_name(
+ jackctl_driver_t * driver);
+
+/**
+ * Call this function to get type of driver.
+ *
+ * @param driver driver object handle to get name of
+ *
+ * @return driver type. Must not be modified. Always same for same
+ * driver object.
+ */
+jackctl_driver_type_t
+jackctl_driver_get_type(
+ jackctl_driver_t * driver);
+
+/**
+ * Call this function to get list of driver parameters. List node data
+ * pointers is a parameter object handle (::jackctl_parameter_t).
+ *
+ * @param driver driver object handle to get parameters for
+ *
+ * @return Single linked list of parameter object handles. Must not be
+ * modified. Always same for same driver object.
+ */
+const JSList *
+jackctl_driver_get_parameters(
+ jackctl_driver_t * driver);
+
+/**
+ * Call this function to parse parameters for a driver.
+ *
+ * @param driver driver object handle
+ * @param argc parameter list len
+ * @param argv parameter list, as an array of char*
+ *
+ * @return success status: true - success, false - fail
+ */
+int
+jackctl_driver_params_parse(
+ jackctl_driver_t * driver,
+ int argc,
+ char* argv[]);
+
+/**
+ * Call this function to get name of internal client.
+ *
+ * @param internal internal object handle to get name of
+ *
+ * @return internal name. Must not be modified. Always same for same
+ * internal object.
+ */
+const char *
+jackctl_internal_get_name(
+ jackctl_internal_t * internal);
+
+/**
+ * Call this function to get list of internal parameters. List node data
+ * pointers is a parameter object handle (::jackctl_parameter_t).
+ *
+ * @param internal internal object handle to get parameters for
+ *
+ * @return Single linked list of parameter object handles. Must not be
+ * modified. Always same for same internal object.
+ */
+const JSList *
+jackctl_internal_get_parameters(
+ jackctl_internal_t * internal);
+
+/**
+ * Call this function to get parameter name.
+ *
+ * @param parameter parameter object handle to get name of
+ *
+ * @return parameter name. Must not be modified. Always same for same
+ * parameter object.
+ */
+const char *
+jackctl_parameter_get_name(
+ jackctl_parameter_t * parameter);
+
+/**
+ * Call this function to get parameter short description.
+ *
+ * @param parameter parameter object handle to get short description of
+ *
+ * @return parameter short description. Must not be modified. Always
+ * same for same parameter object.
+ */
+const char *
+jackctl_parameter_get_short_description(
+ jackctl_parameter_t * parameter);
+
+/**
+ * Call this function to get parameter long description.
+ *
+ * @param parameter parameter object handle to get long description of
+ *
+ * @return parameter long description. Must not be modified. Always
+ * same for same parameter object.
+ */
+const char *
+jackctl_parameter_get_long_description(
+ jackctl_parameter_t * parameter);
+
+/**
+ * Call this function to get parameter type.
+ *
+ * @param parameter parameter object handle to get type of
+ *
+ * @return parameter type. Always same for same parameter object.
+ */
+jackctl_param_type_t
+jackctl_parameter_get_type(
+ jackctl_parameter_t * parameter);
+
+/**
+ * Call this function to get parameter character.
+ *
+ * @param parameter parameter object handle to get character of
+ *
+ * @return character.
+ */
+char
+jackctl_parameter_get_id(
+ jackctl_parameter_t * parameter);
+
+/**
+ * Call this function to check whether parameter has been set, or its
+ * default value is being used.
+ *
+ * @param parameter parameter object handle to check
+ *
+ * @return true - parameter is set, false - parameter is using default
+ * value.
+ */
+bool
+jackctl_parameter_is_set(
+ jackctl_parameter_t * parameter);
+
+/**
+ * Call this function to reset parameter to its default value.
+ *
+ * @param parameter parameter object handle to reset value of
+ *
+ * @return success status: true - success, false - fail
+ */
+bool
+jackctl_parameter_reset(
+ jackctl_parameter_t * parameter);
+
+/**
+ * Call this function to get parameter value.
+ *
+ * @param parameter parameter object handle to get value of
+ *
+ * @return parameter value.
+ */
+union jackctl_parameter_value
+jackctl_parameter_get_value(
+ jackctl_parameter_t * parameter);
+
+/**
+ * Call this function to set parameter value.
+ *
+ * @param parameter parameter object handle to get value of
+ * @param value_ptr pointer to variable containing parameter value
+ *
+ * @return success status: true - success, false - fail
+ */
+bool
+jackctl_parameter_set_value(
+ jackctl_parameter_t * parameter,
+ const union jackctl_parameter_value * value_ptr);
+
+/**
+ * Call this function to get parameter default value.
+ *
+ * @param parameter parameter object handle to get default value of
+ *
+ * @return parameter default value.
+ */
+union jackctl_parameter_value
+jackctl_parameter_get_default_value(
+ jackctl_parameter_t * parameter);
+
+/**
+ * Call this function check whether parameter has range constraint.
+ *
+ * @param parameter object handle of parameter to check
+ *
+ * @return whether parameter has range constraint.
+ */
+bool
+jackctl_parameter_has_range_constraint(
+ jackctl_parameter_t * parameter);
+
+/**
+ * Call this function check whether parameter has enumeration constraint.
+ *
+ * @param parameter object handle of parameter to check
+ *
+ * @return whether parameter has enumeration constraint.
+ */
+bool
+jackctl_parameter_has_enum_constraint(
+ jackctl_parameter_t * parameter);
+
+/**
+ * Call this function get how many enumeration values parameter has.
+ *
+ * @param parameter object handle of parameter
+ *
+ * @return number of enumeration values
+ */
+uint32_t
+jackctl_parameter_get_enum_constraints_count(
+ jackctl_parameter_t * parameter);
+
+/**
+ * Call this function to get parameter enumeration value.
+ *
+ * @param parameter object handle of parameter
+ * @param index index of parameter enumeration value
+ *
+ * @return enumeration value.
+ */
+union jackctl_parameter_value
+jackctl_parameter_get_enum_constraint_value(
+ jackctl_parameter_t * parameter,
+ uint32_t index);
+
+/**
+ * Call this function to get parameter enumeration value description.
+ *
+ * @param parameter object handle of parameter
+ * @param index index of parameter enumeration value
+ *
+ * @return enumeration value description.
+ */
+const char *
+jackctl_parameter_get_enum_constraint_description(
+ jackctl_parameter_t * parameter,
+ uint32_t index);
+
+/**
+ * Call this function to get parameter range.
+ *
+ * @param parameter object handle of parameter
+ * @param min_ptr pointer to variable receiving parameter minimum value
+ * @param max_ptr pointer to variable receiving parameter maximum value
+ */
+void
+jackctl_parameter_get_range_constraint(
+ jackctl_parameter_t * parameter,
+ union jackctl_parameter_value * min_ptr,
+ union jackctl_parameter_value * max_ptr);
+
+/**
+ * Call this function to check whether parameter constraint is strict,
+ * i.e. whether supplying non-matching value will not work for sure.
+ *
+ * @param parameter parameter object handle to check
+ *
+ * @return whether parameter constraint is strict.
+ */
+bool
+jackctl_parameter_constraint_is_strict(
+ jackctl_parameter_t * parameter);
+
+/**
+ * Call this function to check whether parameter has fake values,
+ * i.e. values have no user meaningful meaning and only value
+ * description is meaningful to user.
+ *
+ * @param parameter parameter object handle to check
+ *
+ * @return whether parameter constraint is strict.
+ */
+bool
+jackctl_parameter_constraint_is_fake_value(
+ jackctl_parameter_t * parameter);
+
+/**
+ * Call this function to log an error message.
+ *
+ * @param format string
+ */
+void
+jack_error(
+ const char *format,
+ ...);
+
+/**
+ * Call this function to log an information message.
+ *
+ * @param format string
+ */
+void
+jack_info(
+ const char *format,
+ ...);
+
+/**
+ * Call this function to log an information message but only when
+ * verbose mode is enabled.
+ *
+ * @param format string
+ */
+void
+jack_log(
+ const char *format,
+ ...);
+
+/* @} */
+
+#if 0
+{ /* Adjust editor indent */
+#endif
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef JACKCTL_H__2EEDAD78_DF4C_4B26_83B7_4FF1A446A47E__INCLUDED */
diff --git a/pipewire-jack/jack/intclient.h b/pipewire-jack/jack/intclient.h
new file mode 100644
index 0000000..d4503ae
--- /dev/null
+++ b/pipewire-jack/jack/intclient.h
@@ -0,0 +1,130 @@
+/*
+* Copyright (C) 2004 Jack O'Quin
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation; either version 2.1 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*
+*/
+
+#ifndef __jack_intclient_h__
+#define __jack_intclient_h__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <jack/types.h>
+
+/**
+ * Get an internal client's name. This is useful when @ref
+ * JackUseExactName was not specified on jack_internal_client_load()
+ * and @ref JackNameNotUnique status was returned. In that case, the
+ * actual name will differ from the @a client_name requested.
+ *
+ * @param client requesting JACK client's handle.
+ *
+ * @param intclient handle returned from jack_internal_client_load()
+ * or jack_internal_client_handle().
+ *
+ * @return NULL if unsuccessful, otherwise pointer to the internal
+ * client name obtained from the heap via malloc(). The caller should
+ * jack_free() this storage when no longer needed.
+ */
+char *jack_get_internal_client_name (jack_client_t *client,
+ jack_intclient_t intclient);
+
+/**
+ * Return the @ref jack_intclient_t handle for an internal client
+ * running in the JACK server.
+ *
+ * @param client requesting JACK client's handle.
+ *
+ * @param client_name for the internal client of no more than
+ * jack_client_name_size() characters. The name scope is local to the
+ * current server.
+ *
+ * @param status (if non-NULL) an address for JACK to return
+ * information from this operation. This status word is formed by
+ * OR-ing together the relevant @ref JackStatus bits.
+ *
+ * @return Opaque internal client handle if successful. If 0, the
+ * internal client was not found, and @a *status includes the @ref
+ * JackNoSuchClient and @ref JackFailure bits.
+ */
+jack_intclient_t jack_internal_client_handle (jack_client_t *client,
+ const char *client_name,
+ jack_status_t *status);
+
+/**
+ * Load an internal client into the JACK server.
+ *
+ * Internal clients run inside the JACK server process. They can use
+ * most of the same functions as external clients. Each internal
+ * client is built as a shared object module, which must declare
+ * jack_initialize() and jack_finish() entry points called at load and
+ * unload times. See @ref inprocess.c for an example.
+ *
+ * @param client loading JACK client's handle.
+ *
+ * @param client_name of at most jack_client_name_size() characters
+ * for the internal client to load. The name scope is local to the
+ * current server.
+ *
+ * @param options formed by OR-ing together @ref JackOptions bits.
+ * Only the @ref JackLoadOptions bits are valid.
+ *
+ * @param status (if non-NULL) an address for JACK to return
+ * information from the load operation. This status word is formed by
+ * OR-ing together the relevant @ref JackStatus bits.
+ *
+ * <b>Optional parameters:</b> depending on corresponding [@a options
+ * bits] additional parameters may follow @a status (in this order).
+ *
+ * @arg [@ref JackLoadName] <em>(char *) load_name</em> is the shared
+ * object file from which to load the new internal client (otherwise
+ * use the @a client_name).
+ *
+ * @arg [@ref JackLoadInit] <em>(char *) load_init</em> an arbitrary
+ * string passed to the internal client's jack_initialize() routine
+ * (otherwise NULL), of no more than @ref JACK_LOAD_INIT_LIMIT bytes.
+ *
+ * @return Opaque internal client handle if successful. If this is 0,
+ * the load operation failed, the internal client was not loaded, and
+ * @a *status includes the @ref JackFailure bit.
+ */
+jack_intclient_t jack_internal_client_load (jack_client_t *client,
+ const char *client_name,
+ jack_options_t options,
+ jack_status_t *status, ...);
+/**
+ * Unload an internal client from a JACK server. This calls the
+ * intclient's jack_finish() entry point then removes it. See @ref
+ * inprocess.c for an example.
+ *
+ * @param client unloading JACK client's handle.
+ *
+ * @param intclient handle returned from jack_internal_client_load() or
+ * jack_internal_client_handle().
+ *
+ * @return 0 if successful, otherwise @ref JackStatus bits.
+ */
+jack_status_t jack_internal_client_unload (jack_client_t *client,
+ jack_intclient_t intclient);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __jack_intclient_h__ */
diff --git a/pipewire-jack/jack/jack.h b/pipewire-jack/jack/jack.h
new file mode 100644
index 0000000..2b83cb1
--- /dev/null
+++ b/pipewire-jack/jack/jack.h
@@ -0,0 +1,1477 @@
+/*
+ Copyright (C) 2001 Paul Davis
+ Copyright (C) 2004 Jack O'Quin
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+
+#ifndef __jack_h__
+#define __jack_h__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <jack/systemdeps.h>
+#include <jack/types.h>
+#include <jack/transport.h>
+
+/**
+ * Note: More documentation can be found in jack/types.h.
+ */
+
+ /*************************************************************
+ * NOTE: JACK_WEAK_EXPORT ***MUST*** be used on every function
+ * added to the JACK API after the 0.116.2 release.
+ *
+ * Functions that predate this release are marked with
+ * JACK_WEAK_OPTIONAL_EXPORT which can be defined at compile
+ * time in a variety of ways. The default definition is empty,
+ * so that these symbols get normal linkage. If you wish to
+ * use all JACK symbols with weak linkage, include
+ * <jack/weakjack.h> before jack.h.
+ *************************************************************/
+
+#include <jack/weakmacros.h>
+
+/**
+ * Call this function to get version of the JACK, in form of several numbers
+ *
+ * @param major_ptr pointer to variable receiving major version of JACK.
+ *
+ * @param minor_ptr pointer to variable receiving minor version of JACK.
+ *
+ * @param major_ptr pointer to variable receiving micro version of JACK.
+ *
+ * @param major_ptr pointer to variable receiving protocol version of JACK.
+ *
+ */
+void
+jack_get_version(
+ int *major_ptr,
+ int *minor_ptr,
+ int *micro_ptr,
+ int *proto_ptr) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Call this function to get version of the JACK, in form of a string
+ *
+ * @return Human readable string describing JACK version being used.
+ *
+ */
+const char *
+jack_get_version_string(void) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * @defgroup ClientFunctions Creating & manipulating clients
+ * @{
+ */
+
+/**
+ * Open an external client session with a JACK server. This interface
+ * is more complex but more powerful than jack_client_new(). With it,
+ * clients may choose which of several servers to connect, and control
+ * whether and how to start the server automatically, if it was not
+ * already running. There is also an option for JACK to generate a
+ * unique client name, when necessary.
+ *
+ * @param client_name of at most jack_client_name_size() characters.
+ * The name scope is local to each server. Unless forbidden by the
+ * @ref JackUseExactName option, the server will modify this name to
+ * create a unique variant, if needed.
+ *
+ * @param options formed by OR-ing together @ref JackOptions bits.
+ * Only the @ref JackOpenOptions bits are allowed.
+ *
+ * @param status (if non-NULL) an address for JACK to return
+ * information from the open operation. This status word is formed by
+ * OR-ing together the relevant @ref JackStatus bits.
+ *
+ *
+ * <b>Optional parameters:</b> depending on corresponding [@a options
+ * bits] additional parameters may follow @a status (in this order).
+ *
+ * @arg [@ref JackServerName] <em>(char *) server_name</em> selects
+ * from among several possible concurrent server instances. Server
+ * names are unique to each user. If unspecified, use "default"
+ * unless \$JACK_DEFAULT_SERVER is defined in the process environment.
+ *
+ * @return Opaque client handle if successful. If this is NULL, the
+ * open operation failed, @a *status includes @ref JackFailure and the
+ * caller is not a JACK client.
+ */
+jack_client_t * jack_client_open (const char *client_name,
+ jack_options_t options,
+ jack_status_t *status, ...) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+* \bold THIS FUNCTION IS DEPRECATED AND SHOULD NOT BE USED IN
+* NEW JACK CLIENTS
+*
+* @deprecated Please use jack_client_open().
+*/
+jack_client_t * jack_client_new (const char *client_name) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
+
+/**
+ * Disconnects an external client from a JACK server.
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+int jack_client_close (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * @return the maximum number of characters in a JACK client name
+ * including the final NULL character. This value is a constant.
+ */
+int jack_client_name_size (void) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * @return pointer to actual client name. This is useful when @ref
+ * JackUseExactName is not specified on open and @ref
+ * JackNameNotUnique status was returned. In that case, the actual
+ * name will differ from the @a client_name requested.
+ */
+char * jack_get_client_name (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Get the session ID for a client name.
+ *
+ * The session manager needs this to reassociate a client name to the session_id.
+ *
+ * The caller is responsible for calling jack_free(3) on any non-NULL
+ * returned value.
+ */
+char *jack_get_uuid_for_client_name (jack_client_t *client,
+ const char *client_name) JACK_WEAK_EXPORT;
+
+/**
+ * Get the client name for a session_id.
+ *
+ * In order to snapshot the graph connections, the session manager needs to map
+ * session_ids to client names.
+ *
+ * The caller is responsible for calling jack_free(3) on any non-NULL
+ * returned value.
+ */
+char *jack_get_client_name_by_uuid (jack_client_t *client,
+ const char *client_uuid ) JACK_WEAK_EXPORT;
+
+/**
+ * Load an internal client into the Jack server.
+ *
+ * Internal clients run inside the JACK server process. They can use
+ * most of the same functions as external clients. Each internal
+ * client must declare jack_initialize() and jack_finish() entry
+ * points, called at load and unload times. See inprocess.c for an
+ * example of how to write an internal client.
+ *
+ * @deprecated Please use jack_internal_client_load().
+ *
+ * @param client_name of at most jack_client_name_size() characters.
+ *
+ * @param load_name of a shared object file containing the code for
+ * the new client.
+ *
+ * @param load_init an arbitrary string passed to the jack_initialize()
+ * routine of the new client (may be NULL).
+ *
+ * @return 0 if successful.
+ */
+int jack_internal_client_new (const char *client_name,
+ const char *load_name,
+ const char *load_init) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
+
+/**
+ * Remove an internal client from a JACK server.
+ *
+ * @deprecated Please use jack_internal_client_unload().
+ */
+void jack_internal_client_close (const char *client_name) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
+
+/**
+ * Tell the Jack server that the program is ready to start processing
+ * audio.
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+int jack_activate (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Tell the Jack server to remove this @a client from the process
+ * graph. Also, disconnect all ports belonging to it, since inactive
+ * clients have no port connections.
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+int jack_deactivate (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * @return pid of client. If not available, 0 will be returned.
+ */
+int jack_get_client_pid (const char *name) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * @return the pthread ID of the thread running the JACK client side
+ * real-time code.
+ */
+jack_native_thread_t jack_client_thread_id (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT;
+
+/*@}*/
+
+/**
+ * @param client pointer to JACK client structure.
+ *
+ * Check if the JACK subsystem is running with -R (--realtime).
+ *
+ * @return 1 if JACK is running realtime, 0 otherwise
+ */
+int jack_is_realtime (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * @defgroup NonCallbackAPI The non-callback API
+ * @{
+ */
+
+/**
+ * \bold THIS FUNCTION IS DEPRECATED AND SHOULD NOT BE USED IN
+ * NEW JACK CLIENTS.
+ *
+ * @deprecated Please use jack_cycle_wait() and jack_cycle_signal() functions.
+ */
+jack_nframes_t jack_thread_wait (jack_client_t *client, int status) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Wait until this JACK client should process data.
+ *
+ * @param client - pointer to a JACK client structure
+ *
+ * @return the number of frames of data to process
+ */
+jack_nframes_t jack_cycle_wait (jack_client_t* client) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Signal next clients in the graph.
+ *
+ * @param client - pointer to a JACK client structure
+ * @param status - if non-zero, calling thread should exit
+ */
+void jack_cycle_signal (jack_client_t* client, int status) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Tell the Jack server to call @a thread_callback in the RT thread.
+ * Typical use are in conjunction with @a jack_cycle_wait and @a jack_cycle_signal functions.
+ * The code in the supplied function must be suitable for real-time
+ * execution. That means that it cannot call functions that might
+ * block for a long time. This includes malloc, free, printf,
+ * pthread_mutex_lock, sleep, wait, poll, select, pthread_join,
+ * pthread_cond_wait, etc, etc. See
+ * http://jackit.sourceforge.net/docs/design/design.html#SECTION00411000000000000000
+ * for more information.
+ *
+ * NOTE: this function cannot be called while the client is activated
+ * (after jack_activate has been called.)
+ *
+ * @return 0 on success, otherwise a non-zero error code.
+*/
+int jack_set_process_thread(jack_client_t* client, JackThreadCallback thread_callback, void *arg) JACK_OPTIONAL_WEAK_EXPORT;
+
+/*@}*/
+
+/**
+ * @defgroup ClientCallbacks Setting Client Callbacks
+ * @{
+ */
+
+/**
+ * Tell JACK to call @a thread_init_callback once just after
+ * the creation of the thread in which all other callbacks
+ * will be handled.
+ *
+ * The code in the supplied function does not need to be
+ * suitable for real-time execution.
+ *
+ * NOTE: this function cannot be called while the client is activated
+ * (after jack_activate has been called.)
+ *
+ * @return 0 on success, otherwise a non-zero error code, causing JACK
+ * to remove that client from the process() graph.
+ */
+int jack_set_thread_init_callback (jack_client_t *client,
+ JackThreadInitCallback thread_init_callback,
+ void *arg) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * @param client pointer to JACK client structure.
+ * @param function The jack_shutdown function pointer.
+ * @param arg The arguments for the jack_shutdown function.
+ *
+ * Register a function (and argument) to be called if and when the
+ * JACK server shuts down the client thread. The function must
+ * be written as if it were an asynchronous POSIX signal
+ * handler --- use only async-safe functions, and remember that it
+ * is executed from another thread. A typical function might
+ * set a flag or write to a pipe so that the rest of the
+ * application knows that the JACK client thread has shut
+ * down.
+ *
+ * NOTE: clients do not need to call this. It exists only
+ * to help more complex clients understand what is going
+ * on. It should be called before jack_client_activate().
+ *
+ * NOTE: if a client calls this AND jack_on_info_shutdown(), then
+ * in case of a client thread shutdown, the callback
+ * passed to this function will not be called, and the one passed to
+ * jack_on_info_shutdown() will.
+ *
+ * NOTE: application should typically signal another thread to correctly
+ * finish cleanup, that is by calling "jack_client_close"
+ * (since "jack_client_close" cannot be called directly in the context
+ * of the thread that calls the shutdown callback).
+ */
+void jack_on_shutdown (jack_client_t *client,
+ JackShutdownCallback shutdown_callback, void *arg) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * @param client pointer to JACK client structure.
+ * @param function The jack_info_shutdown function pointer.
+ * @param arg The arguments for the jack_info_shutdown function.
+ *
+ * Register a function (and argument) to be called if and when the
+ * JACK server shuts down the client thread. The function must
+ * be written as if it were an asynchronous POSIX signal
+ * handler --- use only async-safe functions, and remember that it
+ * is executed from another thread. A typical function might
+ * set a flag or write to a pipe so that the rest of the
+ * application knows that the JACK client thread has shut
+ * down.
+ *
+ * NOTE: clients do not need to call this. It exists only
+ * to help more complex clients understand what is going
+ * on. It should be called before jack_client_activate().
+ *
+ * NOTE: if a client calls this AND jack_on_shutdown(), then
+ * in case of a client thread shutdown, the callback passed to
+ * jack_on_info_shutdown() will be called.
+ *
+ * NOTE: application should typically signal another thread to correctly
+ * finish cleanup, that is by calling "jack_client_close"
+ * (since "jack_client_close" cannot be called directly in the context
+ * of the thread that calls the shutdown callback).
+ */
+void jack_on_info_shutdown (jack_client_t *client,
+ JackInfoShutdownCallback shutdown_callback, void *arg) JACK_WEAK_EXPORT;
+
+/**
+ * Tell the Jack server to call @a process_callback whenever there is
+ * work be done, passing @a arg as the second argument.
+ *
+ * The code in the supplied function must be suitable for real-time
+ * execution. That means that it cannot call functions that might
+ * block for a long time. This includes malloc, free, printf,
+ * pthread_mutex_lock, sleep, wait, poll, select, pthread_join,
+ * pthread_cond_wait, etc, etc. See
+ * http://jackit.sourceforge.net/docs/design/design.html#SECTION00411000000000000000
+ * for more information.
+ *
+ * NOTE: this function cannot be called while the client is activated
+ * (after jack_activate has been called.)
+ *
+ * @return 0 on success, otherwise a non-zero error code.
+ */
+int jack_set_process_callback (jack_client_t *client,
+ JackProcessCallback process_callback,
+ void *arg) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Tell the Jack server to call @a freewheel_callback
+ * whenever we enter or leave "freewheel" mode, passing @a
+ * arg as the second argument. The first argument to the
+ * callback will be non-zero if JACK is entering freewheel
+ * mode, and zero otherwise.
+ *
+ * All "notification events" are received in a separated non RT thread,
+ * the code in the supplied function does not need to be
+ * suitable for real-time execution.
+ *
+ * NOTE: this function cannot be called while the client is activated
+ * (after jack_activate has been called.)
+ *
+ * @return 0 on success, otherwise a non-zero error code.
+ */
+int jack_set_freewheel_callback (jack_client_t *client,
+ JackFreewheelCallback freewheel_callback,
+ void *arg) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Tell JACK to call @a bufsize_callback whenever the size of the
+ * buffer that will be passed to the @a process_callback is about to
+ * change. Clients that depend on knowing the buffer size must supply
+ * a @a bufsize_callback before activating themselves.
+ *
+ * All "notification events" are received in a separated non RT thread,
+ * the code in the supplied function does not need to be
+ * suitable for real-time execution.
+ *
+ * NOTE: this function cannot be called while the client is activated
+ * (after jack_activate has been called.)
+ *
+ * @param client pointer to JACK client structure.
+ * @param bufsize_callback function to call when the buffer size changes.
+ * @param arg argument for @a bufsize_callback.
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+int jack_set_buffer_size_callback (jack_client_t *client,
+ JackBufferSizeCallback bufsize_callback,
+ void *arg) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Tell the Jack server to call @a srate_callback whenever the system
+ * sample rate changes.
+ *
+ * All "notification events" are received in a separated non RT thread,
+ * the code in the supplied function does not need to be
+ * suitable for real-time execution.
+ *
+ * NOTE: this function cannot be called while the client is activated
+ * (after jack_activate has been called.)
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+int jack_set_sample_rate_callback (jack_client_t *client,
+ JackSampleRateCallback srate_callback,
+ void *arg) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Tell the JACK server to call @a client_registration_callback whenever a
+ * client is registered or unregistered, passing @a arg as a parameter.
+ *
+ * All "notification events" are received in a separated non RT thread,
+ * the code in the supplied function does not need to be
+ * suitable for real-time execution.
+ *
+ * NOTE: this function cannot be called while the client is activated
+ * (after jack_activate has been called.)
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+int jack_set_client_registration_callback (jack_client_t *client,
+ JackClientRegistrationCallback
+ registration_callback, void *arg) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Tell the JACK server to call @a registration_callback whenever a
+ * port is registered or unregistered, passing @a arg as a parameter.
+ *
+ * All "notification events" are received in a separated non RT thread,
+ * the code in the supplied function does not need to be
+ * suitable for real-time execution.
+ *
+ * NOTE: this function cannot be called while the client is activated
+ * (after jack_activate has been called.)
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+ int jack_set_port_registration_callback (jack_client_t *client,
+ JackPortRegistrationCallback
+ registration_callback, void *arg) JACK_OPTIONAL_WEAK_EXPORT;
+
+ /**
+ * Tell the JACK server to call @a connect_callback whenever a
+ * port is connected or disconnected, passing @a arg as a parameter.
+ *
+ * All "notification events" are received in a separated non RT thread,
+ * the code in the supplied function does not need to be
+ * suitable for real-time execution.
+ *
+ * NOTE: this function cannot be called while the client is activated
+ * (after jack_activate has been called.)
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+int jack_set_port_connect_callback (jack_client_t *client,
+ JackPortConnectCallback
+ connect_callback, void *arg) JACK_OPTIONAL_WEAK_EXPORT;
+
+ /**
+ * Tell the JACK server to call @a rename_callback whenever a
+ * port is renamed, passing @a arg as a parameter.
+ *
+ * All "notification events" are received in a separated non RT thread,
+ * the code in the supplied function does not need to be
+ * suitable for real-time execution.
+ *
+ * NOTE: this function cannot be called while the client is activated
+ * (after jack_activate has been called.)
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+int jack_set_port_rename_callback (jack_client_t *client,
+ JackPortRenameCallback
+ rename_callback, void *arg) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Tell the JACK server to call @a graph_callback whenever the
+ * processing graph is reordered, passing @a arg as a parameter.
+ *
+ * All "notification events" are received in a separated non RT thread,
+ * the code in the supplied function does not need to be
+ * suitable for real-time execution.
+ *
+ * NOTE: this function cannot be called while the client is activated
+ * (after jack_activate has been called.)
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+int jack_set_graph_order_callback (jack_client_t *client,
+ JackGraphOrderCallback graph_callback,
+ void *) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Tell the JACK server to call @a xrun_callback whenever there is a
+ * xrun, passing @a arg as a parameter.
+ *
+ * All "notification events" are received in a separated non RT thread,
+ * the code in the supplied function does not need to be
+ * suitable for real-time execution.
+ *
+ * NOTE: this function cannot be called while the client is activated
+ * (after jack_activate has been called.)
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+int jack_set_xrun_callback (jack_client_t *client,
+ JackXRunCallback xrun_callback, void *arg) JACK_OPTIONAL_WEAK_EXPORT;
+
+/*@}*/
+
+/**
+ * Tell the Jack server to call @a latency_callback whenever it
+ * is necessary to recompute the latencies for some or all
+ * Jack ports.
+ *
+ * @a latency_callback will be called twice each time it is
+ * needed, once being passed JackCaptureLatency and once
+ * JackPlaybackLatency. See @ref LatencyFunctions for
+ * the definition of each type of latency and related functions.
+ *
+ * <b>IMPORTANT: Most JACK clients do NOT need to register a latency
+ * callback.</b>
+ *
+ * Clients that meet any of the following conditions do NOT
+ * need to register a latency callback:
+ *
+ * - have only input ports
+ * - have only output ports
+ * - their output is totally unrelated to their input
+ * - their output is not delayed relative to their input
+ * (i.e. data that arrives in a given process()
+ * callback is processed and output again in the
+ * same callback)
+ *
+ * Clients NOT registering a latency callback MUST also
+ * satisfy this condition:
+ *
+ * - have no multiple distinct internal signal pathways
+ *
+ * This means that if your client has more than 1 input and
+ * output port, and considers them always "correlated"
+ * (e.g. as a stereo pair), then there is only 1 (e.g. stereo)
+ * signal pathway through the client. This would be true,
+ * for example, of a stereo FX rack client that has a
+ * left/right input pair and a left/right output pair.
+ *
+ * However, this is somewhat a matter of perspective. The
+ * same FX rack client could be connected so that its
+ * two input ports were connected to entirely separate
+ * sources. Under these conditions, the fact that the client
+ * does not register a latency callback MAY result
+ * in port latency values being incorrect.
+ *
+ * Clients that do not meet any of those conditions SHOULD
+ * register a latency callback.
+ *
+ * Another case is when a client wants to use
+ * @ref jack_port_get_latency_range(), which only returns meaningful
+ * values when ports get connected and latency values change.
+ *
+ * See the documentation for @ref jack_port_set_latency_range()
+ * on how the callback should operate. Remember that the @a mode
+ * argument given to the latency callback will need to be
+ * passed into @ref jack_port_set_latency_range()
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+int jack_set_latency_callback (jack_client_t *client,
+ JackLatencyCallback latency_callback,
+ void *) JACK_WEAK_EXPORT;
+/*@}*/
+
+/**
+ * @defgroup ServerClientControl Controlling & querying JACK server operation
+ * @{
+ */
+
+/**
+ * Start/Stop JACK's "freewheel" mode.
+ *
+ * When in "freewheel" mode, JACK no longer waits for
+ * any external event to begin the start of the next process
+ * cycle.
+ *
+ * As a result, freewheel mode causes "faster than realtime"
+ * execution of a JACK graph. If possessed, real-time
+ * scheduling is dropped when entering freewheel mode, and
+ * if appropriate it is reacquired when stopping.
+ *
+ * IMPORTANT: on systems using capabilities to provide real-time
+ * scheduling (i.e. Linux kernel 2.4), if onoff is zero, this function
+ * must be called from the thread that originally called jack_activate().
+ * This restriction does not apply to other systems (e.g. Linux kernel 2.6
+ * or OS X).
+ *
+ * @param client pointer to JACK client structure
+ * @param onoff if non-zero, freewheel mode starts. Otherwise
+ * freewheel mode ends.
+ *
+ * @return 0 on success, otherwise a non-zero error code.
+ */
+int jack_set_freewheel(jack_client_t* client, int onoff) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Change the buffer size passed to the @a process_callback.
+ *
+ * This operation stops the JACK engine process cycle, then calls all
+ * registered @a bufsize_callback functions before restarting the
+ * process cycle. This will cause a gap in the audio flow, so it
+ * should only be done at appropriate stopping points.
+ *
+ * @see jack_set_buffer_size_callback()
+ *
+ * @param client pointer to JACK client structure.
+ * @param nframes new buffer size. Must be a power of two.
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+int jack_set_buffer_size (jack_client_t *client, jack_nframes_t nframes) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * @return the sample rate of the jack system, as set by the user when
+ * jackd was started.
+ */
+jack_nframes_t jack_get_sample_rate (jack_client_t *) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * @return the current maximum size that will ever be passed to the @a
+ * process_callback. It should only be used *before* the client has
+ * been activated. This size may change, clients that depend on it
+ * must register a @a bufsize_callback so they will be notified if it
+ * does.
+ *
+ * @see jack_set_buffer_size_callback()
+ */
+jack_nframes_t jack_get_buffer_size (jack_client_t *) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Old-style interface to become the timebase for the entire JACK
+ * subsystem.
+ *
+ * @deprecated This function still exists for compatibility with the
+ * earlier transport interface, but it does nothing. Instead, see
+ * transport.h and use jack_set_timebase_callback().
+ *
+ * @return ENOSYS, function not implemented.
+ */
+int jack_engine_takeover_timebase (jack_client_t *) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
+
+/**
+ * @return the current CPU load estimated by JACK. This is a running
+ * average of the time it takes to execute a full process cycle for
+ * all clients as a percentage of the real time available per cycle
+ * determined by the buffer size and sample rate.
+ */
+float jack_cpu_load (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT;
+
+/*@}*/
+
+/**
+ * @defgroup PortFunctions Creating & manipulating ports
+ * @{
+ */
+
+/**
+ * Create a new port for the client. This is an object used for moving
+ * data of any type in or out of the client. Ports may be connected
+ * in various ways.
+ *
+ * Each port has a short name. The port's full name contains the name
+ * of the client concatenated with a colon (:) followed by its short
+ * name. The jack_port_name_size() is the maximum length of this full
+ * name. Exceeding that will cause the port registration to fail and
+ * return NULL.
+ *
+ * The @a port_name must be unique among all ports owned by this client.
+ * If the name is not unique, the registration will fail.
+ *
+ * All ports have a type, which may be any non-NULL and non-zero
+ * length string, passed as an argument. Some port types are built
+ * into the JACK API, currently only JACK_DEFAULT_AUDIO_TYPE.
+ *
+ * @param client pointer to JACK client structure.
+ * @param port_name non-empty short name for the new port (not
+ * including the leading @a "client_name:"). Must be unique.
+ * @param port_type port type name. If longer than
+ * jack_port_type_size(), only that many characters are significant.
+ * @param flags @ref JackPortFlags bit mask.
+ * @param buffer_size must be non-zero if this is not a built-in @a
+ * port_type. Otherwise, it is ignored.
+ *
+ * @return jack_port_t pointer on success, otherwise NULL.
+ */
+jack_port_t * jack_port_register (jack_client_t *client,
+ const char *port_name,
+ const char *port_type,
+ unsigned long flags,
+ unsigned long buffer_size) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Remove the port from the client, disconnecting any existing
+ * connections.
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+int jack_port_unregister (jack_client_t *client, jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * This returns a pointer to the memory area associated with the
+ * specified port. For an output port, it will be a memory area
+ * that can be written to; for an input port, it will be an area
+ * containing the data from the port's connection(s), or
+ * zero-filled. if there are multiple inbound connections, the data
+ * will be mixed appropriately.
+ *
+ * FOR OUTPUT PORTS ONLY : DEPRECATED in Jack 2.0 !!
+ * ---------------------------------------------------
+ * You may cache the value returned, but only between calls to
+ * your "blocksize" callback. For this reason alone, you should
+ * either never cache the return value or ensure you have
+ * a "blocksize" callback and be sure to invalidate the cached
+ * address from there.
+ *
+ * Caching output ports is DEPRECATED in Jack 2.0, due to some new optimization (like "pipelining").
+ * Port buffers have to be retrieved in each callback for proper functioning.
+ */
+void * jack_port_get_buffer (jack_port_t *port, jack_nframes_t) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * @return the UUID of the jack_port_t
+ *
+ * @see jack_uuid_to_string() to convert into a string representation
+ */
+jack_uuid_t jack_port_uuid (const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * @return the full name of the jack_port_t (including the @a
+ * "client_name:" prefix).
+ *
+ * @see jack_port_name_size().
+ */
+const char * jack_port_name (const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * @return the short name of the jack_port_t (not including the @a
+ * "client_name:" prefix).
+ *
+ * @see jack_port_name_size().
+ */
+const char * jack_port_short_name (const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * @return the @ref JackPortFlags of the jack_port_t.
+ */
+int jack_port_flags (const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * @return the @a port type, at most jack_port_type_size() characters
+ * including a final NULL.
+ */
+const char * jack_port_type (const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
+
+ /**
+ * @return the @a port type id.
+ */
+jack_port_type_id_t jack_port_type_id (const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * @return TRUE if the jack_port_t belongs to the jack_client_t.
+ */
+int jack_port_is_mine (const jack_client_t *client, const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * @return number of connections to or from @a port.
+ *
+ * @pre The calling client must own @a port.
+ */
+int jack_port_connected (const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * @return TRUE if the locally-owned @a port is @b directly connected
+ * to the @a port_name.
+ *
+ * @see jack_port_name_size()
+ */
+int jack_port_connected_to (const jack_port_t *port,
+ const char *port_name) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * @return a null-terminated array of full port names to which the @a
+ * port is connected. If none, returns NULL.
+ *
+ * The caller is responsible for calling jack_free() on any non-NULL
+ * returned value.
+ *
+ * @param port locally owned jack_port_t pointer.
+ *
+ * @see jack_port_name_size(), jack_port_get_all_connections()
+ */
+const char ** jack_port_get_connections (const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * @return a null-terminated array of full port names to which the @a
+ * port is connected. If none, returns NULL.
+ *
+ * The caller is responsible for calling jack_free() on any non-NULL
+ * returned value.
+ *
+ * This differs from jack_port_get_connections() in two important
+ * respects:
+ *
+ * 1) You may not call this function from code that is
+ * executed in response to a JACK event. For example,
+ * you cannot use it in a GraphReordered handler.
+ *
+ * 2) You need not be the owner of the port to get information
+ * about its connections.
+ *
+ * @see jack_port_name_size()
+ */
+const char ** jack_port_get_all_connections (const jack_client_t *client,
+ const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ *
+ * @deprecated This function will be removed from a future version
+ * of JACK. Do not use it. There is no replacement. It has
+ * turned out to serve essentially no purpose in real-life
+ * JACK clients.
+ */
+int jack_port_tie (jack_port_t *src, jack_port_t *dst) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
+
+/**
+ *
+ * @deprecated This function will be removed from a future version
+ * of JACK. Do not use it. There is no replacement. It has
+ * turned out to serve essentially no purpose in real-life
+ * JACK clients.
+ */
+int jack_port_untie (jack_port_t *port) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
+
+/**
+ * \bold THIS FUNCTION IS DEPRECATED AND SHOULD NOT BE USED IN
+ * NEW JACK CLIENTS
+ *
+ * Modify a port's short name. May be called at any time. If the
+ * resulting full name (including the @a "client_name:" prefix) is
+ * longer than jack_port_name_size(), it will be truncated.
+ *
+ * @return 0 on success, otherwise a non-zero error code.
+ */
+int jack_port_set_name (jack_port_t *port, const char *port_name) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
+
+/**
+ * Modify a port's short name. May NOT be called from a callback handling a server event.
+ * If the resulting full name (including the @a "client_name:" prefix) is
+ * longer than jack_port_name_size(), it will be truncated.
+ *
+ * @return 0 on success, otherwise a non-zero error code.
+ *
+ * This differs from jack_port_set_name() by triggering PortRename notifications to
+ * clients that have registered a port rename handler.
+ */
+int jack_port_rename (jack_client_t* client, jack_port_t *port, const char *port_name) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Set @a alias as an alias for @a port. May be called at any time.
+ * If the alias is longer than jack_port_name_size(), it will be truncated.
+ *
+ * After a successful call, and until JACK exits or
+ * @function jack_port_unset_alias() is called, @alias may be
+ * used as a alternate name for the port.
+ *
+ * Ports can have up to two aliases - if both are already
+ * set, this function will return an error.
+ *
+ * @return 0 on success, otherwise a non-zero error code.
+ */
+int jack_port_set_alias (jack_port_t *port, const char *alias) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Remove @a alias as an alias for @a port. May be called at any time.
+ *
+ * After a successful call, @a alias can no longer be
+ * used as a alternate name for the port.
+ *
+ * @return 0 on success, otherwise a non-zero error code.
+ */
+int jack_port_unset_alias (jack_port_t *port, const char *alias) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Get any aliases known for @port.
+ *
+ * @return the number of aliases discovered for the port
+ */
+int jack_port_get_aliases (const jack_port_t *port, char* const aliases[2]) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * If @ref JackPortCanMonitor is set for this @a port, turn input
+ * monitoring on or off. Otherwise, do nothing.
+ */
+int jack_port_request_monitor (jack_port_t *port, int onoff) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * If @ref JackPortCanMonitor is set for this @a port_name, turn input
+ * monitoring on or off. Otherwise, do nothing.
+ *
+ * @return 0 on success, otherwise a non-zero error code.
+ *
+ * @see jack_port_name_size()
+ */
+int jack_port_request_monitor_by_name (jack_client_t *client,
+ const char *port_name, int onoff) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * If @ref JackPortCanMonitor is set for a port, this function turns
+ * on input monitoring if it was off, and turns it off if only one
+ * request has been made to turn it on. Otherwise it does nothing.
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+int jack_port_ensure_monitor (jack_port_t *port, int onoff) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * @return TRUE if input monitoring has been requested for @a port.
+ */
+int jack_port_monitoring_input (jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Establish a connection between two ports.
+ *
+ * When a connection exists, data written to the source port will
+ * be available to be read at the destination port.
+ *
+ * @pre The port types must be identical.
+ *
+ * @pre The @ref JackPortFlags of the @a source_port must include @ref
+ * JackPortIsOutput.
+ *
+ * @pre The @ref JackPortFlags of the @a destination_port must include
+ * @ref JackPortIsInput.
+ *
+ * @return 0 on success, EEXIST if the connection is already made,
+ * otherwise a non-zero error code
+ */
+int jack_connect (jack_client_t *client,
+ const char *source_port,
+ const char *destination_port) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Remove a connection between two ports.
+ *
+ * @pre The port types must be identical.
+ *
+ * @pre The @ref JackPortFlags of the @a source_port must include @ref
+ * JackPortIsOutput.
+ *
+ * @pre The @ref JackPortFlags of the @a destination_port must include
+ * @ref JackPortIsInput.
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+int jack_disconnect (jack_client_t *client,
+ const char *source_port,
+ const char *destination_port) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Perform the same function as jack_disconnect() using port handles
+ * rather than names. This avoids the name lookup inherent in the
+ * name-based version.
+ *
+ * Clients connecting their own ports are likely to use this function,
+ * while generic connection clients (e.g. patchbays) would use
+ * jack_disconnect().
+ */
+int jack_port_disconnect (jack_client_t *client, jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * @return the maximum number of characters in a full JACK port name
+ * including the final NULL character. This value is a constant.
+ *
+ * A port's full name contains the owning client name concatenated
+ * with a colon (:) followed by its short name and a NULL
+ * character.
+ */
+int jack_port_name_size(void) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * @return the maximum number of characters in a JACK port type name
+ * including the final NULL character. This value is a constant.
+ */
+int jack_port_type_size(void) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * @return the buffersize of a port of type @arg port_type.
+ *
+ * this function may only be called in a buffer_size callback.
+ */
+size_t jack_port_type_get_buffer_size (jack_client_t *client, const char *port_type) JACK_WEAK_EXPORT;
+
+/*@}*/
+
+/**
+ * @defgroup LatencyFunctions Managing and determining latency
+ *
+ * The purpose of JACK's latency API is to allow clients to
+ * easily answer two questions:
+ *
+ * - How long has it been since the data read from a port arrived
+ * at the edge of the JACK graph (either via a physical port
+ * or being synthesized from scratch)?
+ *
+ * - How long will it be before the data written to a port arrives
+ * at the edge of a JACK graph?
+
+ * To help answering these two questions, all JACK ports have two
+ * latency values associated with them, both measured in frames:
+ *
+ * <b>capture latency</b>: how long since the data read from
+ * the buffer of a port arrived at
+ * a port marked with JackPortIsTerminal.
+ * The data will have come from the "outside
+ * world" if the terminal port is also
+ * marked with JackPortIsPhysical, or
+ * will have been synthesized by the client
+ * that owns the terminal port.
+ *
+ * <b>playback latency</b>: how long until the data
+ * written to the buffer of port will reach a port
+ * marked with JackPortIsTerminal.
+ *
+ * Both latencies might potentially have more than one value
+ * because there may be multiple pathways to/from a given port
+ * and a terminal port. Latency is therefore generally
+ * expressed a min/max pair.
+ *
+ * In most common setups, the minimum and maximum latency
+ * are the same, but this design accommodates more complex
+ * routing, and allows applications (and thus users) to
+ * detect cases where routing is creating an anomalous
+ * situation that may either need fixing or more
+ * sophisticated handling by clients that care about
+ * latency.
+ *
+ * See also @ref jack_set_latency_callback for details on how
+ * clients that add latency to the signal path should interact
+ * with JACK to ensure that the correct latency figures are
+ * used.
+ * @{
+ */
+
+/**
+ * The port latency is zero by default. Clients that control
+ * physical hardware with non-zero latency should call this
+ * to set the latency to its correct value. Note that the value
+ * should include any systemic latency present "outside" the
+ * physical hardware controlled by the client. For example,
+ * for a client controlling a digital audio interface connected
+ * to an external digital converter, the latency setting should
+ * include both buffering by the audio interface *and* the converter.
+ *
+ * @deprecated This method will be removed in the next major
+ * release of JACK. It should not be used in new code, and should
+ * be replaced by a latency callback that calls @ref
+ * jack_port_set_latency_range().
+ */
+void jack_port_set_latency (jack_port_t *port, jack_nframes_t) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
+
+/**
+ * return the latency range defined by @a mode for
+ * @a port, in frames.
+ *
+ * See @ref LatencyFunctions for the definition of each latency value.
+ *
+ * This function is best used from callbacks, specifically the latency callback.
+ * Before a port is connected, this returns the default latency: zero.
+ * Therefore it only makes sense to call jack_port_get_latency_range() when
+ * the port is connected, and that gets signalled by the latency callback.
+ * See @ref jack_set_latency_callback() for details.
+ */
+void jack_port_get_latency_range (jack_port_t *port, jack_latency_callback_mode_t mode, jack_latency_range_t *range) JACK_WEAK_EXPORT;
+
+/**
+ * set the minimum and maximum latencies defined by
+ * @a mode for @a port, in frames.
+ *
+ * See @ref LatencyFunctions for the definition of each latency value.
+ *
+ * This function should ONLY be used inside a latency
+ * callback. The client should determine the current
+ * value of the latency using @ref jack_port_get_latency_range()
+ * (called using the same mode as @a mode)
+ * and then add some number of frames to that reflects
+ * latency added by the client.
+ *
+ * How much latency a client adds will vary
+ * dramatically. For most clients, the answer is zero
+ * and there is no reason for them to register a latency
+ * callback and thus they should never call this
+ * function.
+ *
+ * More complex clients that take an input signal,
+ * transform it in some way and output the result but
+ * not during the same process() callback will
+ * generally know a single constant value to add
+ * to the value returned by @ref jack_port_get_latency_range().
+ *
+ * Such clients would register a latency callback (see
+ * @ref jack_set_latency_callback) and must know what input
+ * ports feed which output ports as part of their
+ * internal state. Their latency callback will update
+ * the ports' latency values appropriately.
+ *
+ * A pseudo-code example will help. The @a mode argument to the latency
+ * callback will determine whether playback or capture
+ * latency is being set. The callback will use
+ * @ref jack_port_set_latency_range() as follows:
+ *
+ * \code
+ * jack_latency_range_t range;
+ * if (mode == JackPlaybackLatency) {
+ * foreach input_port in (all self-registered port) {
+ * jack_port_get_latency_range (port_feeding_input_port, JackPlaybackLatency, &range);
+ * range.min += min_delay_added_as_signal_flows_from port_feeding to input_port;
+ * range.max += max_delay_added_as_signal_flows_from port_feeding to input_port;
+ * jack_port_set_latency_range (input_port, JackPlaybackLatency, &range);
+ * }
+ * } else if (mode == JackCaptureLatency) {
+ * foreach output_port in (all self-registered port) {
+ * jack_port_get_latency_range (port_fed_by_output_port, JackCaptureLatency, &range);
+ * range.min += min_delay_added_as_signal_flows_from_output_port_to_fed_by_port;
+ * range.max += max_delay_added_as_signal_flows_from_output_port_to_fed_by_port;
+ * jack_port_set_latency_range (output_port, JackCaptureLatency, &range);
+ * }
+ * }
+ * \endcode
+ *
+ * In this relatively simple pseudo-code example, it is assumed that
+ * each input port or output is connected to only 1 output or input
+ * port respectively.
+ *
+ * If a port is connected to more than 1 other port, then the
+ * range.min and range.max values passed to @ref
+ * jack_port_set_latency_range() should reflect the minimum and
+ * maximum values across all connected ports.
+ *
+ * See the description of @ref jack_set_latency_callback for more
+ * information.
+ */
+void jack_port_set_latency_range (jack_port_t *port, jack_latency_callback_mode_t mode, jack_latency_range_t *range) JACK_WEAK_EXPORT;
+
+/**
+ * Request a complete recomputation of all port latencies. This
+ * can be called by a client that has just changed the internal
+ * latency of its port using jack_port_set_latency
+ * and wants to ensure that all signal pathways in the graph
+ * are updated with respect to the values that will be returned
+ * by jack_port_get_total_latency. It allows a client
+ * to change multiple port latencies without triggering a
+ * recompute for each change.
+ *
+ * @return zero for successful execution of the request. non-zero
+ * otherwise.
+ */
+int jack_recompute_total_latencies (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * @return the time (in frames) between data being available or
+ * delivered at/to a port, and the time at which it arrived at or is
+ * delivered to the "other side" of the port. E.g. for a physical
+ * audio output port, this is the time between writing to the port and
+ * when the signal will leave the connector. For a physical audio
+ * input port, this is the time between the sound arriving at the
+ * connector and the corresponding frames being readable from the
+ * port.
+ *
+ * @deprecated This method will be removed in the next major
+ * release of JACK. It should not be used in new code, and should
+ * be replaced by jack_port_get_latency_range() in any existing
+ * use cases.
+ */
+jack_nframes_t jack_port_get_latency (jack_port_t *port) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
+
+/**
+ * The maximum of the sum of the latencies in every
+ * connection path that can be drawn between the port and other
+ * ports with the @ref JackPortIsTerminal flag set.
+ *
+ * @deprecated This method will be removed in the next major
+ * release of JACK. It should not be used in new code, and should
+ * be replaced by jack_port_get_latency_range() in any existing
+ * use cases.
+ */
+jack_nframes_t jack_port_get_total_latency (jack_client_t *client,
+ jack_port_t *port) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
+
+/**
+ * Request a complete recomputation of a port's total latency. This
+ * can be called by a client that has just changed the internal
+ * latency of its port using jack_port_set_latency
+ * and wants to ensure that all signal pathways in the graph
+ * are updated with respect to the values that will be returned
+ * by jack_port_get_total_latency.
+ *
+ * @return zero for successful execution of the request. non-zero
+ * otherwise.
+ *
+ * @deprecated This method will be removed in the next major
+ * release of JACK. It should not be used in new code, and should
+ * be replaced by jack_recompute_total_latencies() in any existing
+ * use cases.
+ */
+int jack_recompute_total_latency (jack_client_t*, jack_port_t* port) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
+
+/*@}*/
+
+/**
+ * @defgroup PortSearching Looking up ports
+ * @{
+ */
+
+/**
+ * @param port_name_pattern A regular expression used to select
+ * ports by name. If NULL or of zero length, no selection based
+ * on name will be carried out.
+ * @param type_name_pattern A regular expression used to select
+ * ports by type. If NULL or of zero length, no selection based
+ * on type will be carried out.
+ * @param flags A value used to select ports by their flags.
+ * If zero, no selection based on flags will be carried out.
+ *
+ * @return a NULL-terminated array of ports that match the specified
+ * arguments. The caller is responsible for calling jack_free() any
+ * non-NULL returned value.
+ *
+ * @see jack_port_name_size(), jack_port_type_size()
+ */
+const char ** jack_get_ports (jack_client_t *client,
+ const char *port_name_pattern,
+ const char *type_name_pattern,
+ unsigned long flags) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * @return address of the jack_port_t named @a port_name.
+ *
+ * @see jack_port_name_size()
+ */
+jack_port_t * jack_port_by_name (jack_client_t *client, const char *port_name) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * @return address of the jack_port_t of a @a port_id.
+ */
+jack_port_t * jack_port_by_id (jack_client_t *client,
+ jack_port_id_t port_id) JACK_OPTIONAL_WEAK_EXPORT;
+
+/*@}*/
+
+/**
+ * @defgroup TimeFunctions Handling time
+ * @{
+ *
+ * JACK time is in units of 'frames', according to the current sample rate.
+ * The absolute value of frame times is meaningless, frame times have meaning
+ * only relative to each other.
+ */
+
+/**
+ * @return the estimated time in frames that has passed since the JACK
+ * server began the current process cycle.
+ */
+jack_nframes_t jack_frames_since_cycle_start (const jack_client_t *) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * @return the estimated current time in frames.
+ * This function is intended for use in other threads (not the process
+ * callback). The return value can be compared with the value of
+ * jack_last_frame_time to relate time in other threads to JACK time.
+ */
+jack_nframes_t jack_frame_time (const jack_client_t *) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * @return the precise time at the start of the current process cycle.
+ * This function may only be used from the process callback, and can
+ * be used to interpret timestamps generated by jack_frame_time() in
+ * other threads with respect to the current process cycle.
+ *
+ * This is the only jack time function that returns exact time:
+ * when used during the process callback it always returns the same
+ * value (until the next process callback, where it will return
+ * that value + nframes, etc). The return value is guaranteed to be
+ * monotonic and linear in this fashion unless an xrun occurs.
+ * If an xrun occurs, clients must check this value again, as time
+ * may have advanced in a non-linear way (e.g. cycles may have been skipped).
+ */
+jack_nframes_t jack_last_frame_time (const jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * This function may only be used from the process callback.
+ * It provides the internal cycle timing information as used by
+ * most of the other time related functions. This allows the
+ * caller to map between frame counts and microseconds with full
+ * precision (i.e. without rounding frame times to integers),
+ * and also provides e.g. the microseconds time of the start of
+ * the current cycle directly (it has to be computed otherwise).
+ *
+ * If the return value is zero, the following information is
+ * provided in the variables pointed to by the arguments:
+ *
+ * current_frames: the frame time counter at the start of the
+ * current cycle, same as jack_last_frame_time().
+ * current_usecs: the microseconds time at the start of the
+ * current cycle.
+ * next_usecs: the microseconds time of the start of the next
+ * next cycle as computed by the DLL.
+ * period_usecs: the current best estimate of the period time in
+ * microseconds.
+ *
+ * NOTES:
+ *
+ * Because of the types used, all the returned values except period_usecs
+ * are unsigned. In computations mapping between frames and microseconds
+ * *signed* differences are required. The easiest way is to compute those
+ * separately and assign them to the appropriate signed variables,
+ * int32_t for frames and int64_t for usecs. See the implementation of
+ * jack_frames_to_time() and Jack_time_to_frames() for an example.
+ *
+ * Unless there was an xrun, skipped cycles, or the current cycle is the
+ * first after freewheeling or starting Jack, the value of current_usecs
+ * will always be the value of next_usecs of the previous cycle.
+ *
+ * The value of period_usecs will in general NOT be exactly equal to
+ * the difference of next_usecs and current_usecs. This is because to
+ * ensure stability of the DLL and continuity of the mapping, a fraction
+ * of the loop error must be included in next_usecs. For an accurate
+ * mapping between frames and microseconds, the difference of next_usecs
+ * and current_usecs should be used, and not period_usecs.
+ *
+ * @return zero if OK, non-zero otherwise.
+ */
+int jack_get_cycle_times(const jack_client_t *client,
+ jack_nframes_t *current_frames,
+ jack_time_t *current_usecs,
+ jack_time_t *next_usecs,
+ float *period_usecs) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * @return the estimated time in microseconds of the specified frame time
+ */
+jack_time_t jack_frames_to_time(const jack_client_t *client, jack_nframes_t) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * @return the estimated time in frames for the specified system time.
+ */
+jack_nframes_t jack_time_to_frames(const jack_client_t *client, jack_time_t) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * @return return JACK's current system time in microseconds,
+ * using the JACK clock source.
+ *
+ * The value returned is guaranteed to be monotonic, but not linear.
+ */
+jack_time_t jack_get_time(void) JACK_OPTIONAL_WEAK_EXPORT;
+
+/*@}*/
+
+/**
+ * @defgroup ErrorOutput Controlling error/information output
+ */
+/*@{*/
+
+/**
+ * Display JACK error message.
+ *
+ * Set via jack_set_error_function(), otherwise a JACK-provided
+ * default will print @a msg (plus a newline) to stderr.
+ *
+ * @param msg error message text (no newline at end).
+ */
+extern void (*jack_error_callback)(const char *msg) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Set the @ref jack_error_callback for error message display.
+ * Set it to NULL to restore default_jack_error_callback function.
+ *
+ * The JACK library provides two built-in callbacks for this purpose:
+ * default_jack_error_callback() and silent_jack_error_callback().
+ */
+void jack_set_error_function (void (*func)(const char *)) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Display JACK info message.
+ *
+ * Set via jack_set_info_function(), otherwise a JACK-provided
+ * default will print @a msg (plus a newline) to stdout.
+ *
+ * @param msg info message text (no newline at end).
+ */
+extern void (*jack_info_callback)(const char *msg) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Set the @ref jack_info_callback for info message display.
+ * Set it to NULL to restore default_jack_info_callback function.
+ *
+ * The JACK library provides two built-in callbacks for this purpose:
+ * default_jack_info_callback() and silent_jack_info_callback().
+ */
+void jack_set_info_function (void (*func)(const char *)) JACK_OPTIONAL_WEAK_EXPORT;
+
+/*@}*/
+
+/**
+ * The free function to be used on memory returned by jack_port_get_connections,
+ * jack_port_get_all_connections, jack_get_ports and jack_get_internal_client_name functions.
+ * This is MANDATORY on Windows when otherwise all nasty runtime version related crashes can occur.
+ * Developers are strongly encouraged to use this function instead of the standard "free" function in new code.
+ *
+ * @param ptr the memory pointer to be deallocated.
+ */
+void jack_free(void* ptr) JACK_OPTIONAL_WEAK_EXPORT;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __jack_h__ */
diff --git a/pipewire-jack/jack/jslist.h b/pipewire-jack/jack/jslist.h
new file mode 100644
index 0000000..3ec0ce9
--- /dev/null
+++ b/pipewire-jack/jack/jslist.h
@@ -0,0 +1,293 @@
+/*
+ Based on gslist.c from glib-1.2.9 (LGPL).
+
+ Adaption to JACK, Copyright (C) 2002 Kai Vehmanen.
+ - replaced use of gtypes with normal ANSI C types
+ - glib's memory allocation routines replaced with
+ malloc/free calls
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+
+#ifndef __jack_jslist_h__
+#define __jack_jslist_h__
+
+#include <stdlib.h>
+#include <jack/systemdeps.h>
+
+#ifdef sun
+#define __inline__
+#endif
+
+typedef struct _JSList JSList;
+
+typedef int (*JCompareFunc) (void* a, void* b);
+struct _JSList
+{
+ void *data;
+ JSList *next;
+};
+
+static __inline__
+JSList*
+jack_slist_alloc (void)
+{
+ JSList *new_list;
+
+ new_list = (JSList*)malloc(sizeof(JSList));
+ if (new_list) {
+ new_list->data = NULL;
+ new_list->next = NULL;
+ }
+
+ return new_list;
+}
+
+static __inline__
+JSList*
+jack_slist_prepend (JSList* list, void* data)
+{
+ JSList *new_list;
+
+ new_list = (JSList*)malloc(sizeof(JSList));
+ if (new_list) {
+ new_list->data = data;
+ new_list->next = list;
+ }
+
+ return new_list;
+}
+
+#define jack_slist_next(slist) ((slist) ? (((JSList *)(slist))->next) : NULL)
+static __inline__
+JSList*
+jack_slist_last (JSList *list)
+{
+ if (list) {
+ while (list->next)
+ list = list->next;
+ }
+
+ return list;
+}
+
+static __inline__
+JSList*
+jack_slist_remove_link (JSList *list,
+ JSList *link)
+{
+ JSList *tmp;
+ JSList *prev;
+
+ prev = NULL;
+ tmp = list;
+
+ while (tmp) {
+ if (tmp == link) {
+ if (prev)
+ prev->next = tmp->next;
+ if (list == tmp)
+ list = list->next;
+
+ tmp->next = NULL;
+ break;
+ }
+
+ prev = tmp;
+ tmp = tmp->next;
+ }
+
+ return list;
+}
+
+static __inline__
+void
+jack_slist_free (JSList *list)
+{
+ while (list) {
+ JSList *next = list->next;
+ free(list);
+ list = next;
+ }
+}
+
+static __inline__
+void
+jack_slist_free_1 (JSList *list)
+{
+ if (list) {
+ free(list);
+ }
+}
+
+static __inline__
+JSList*
+jack_slist_remove (JSList *list,
+ void *data)
+{
+ JSList *tmp;
+ JSList *prev;
+
+ prev = NULL;
+ tmp = list;
+
+ while (tmp) {
+ if (tmp->data == data) {
+ if (prev)
+ prev->next = tmp->next;
+ if (list == tmp)
+ list = list->next;
+
+ tmp->next = NULL;
+ jack_slist_free (tmp);
+
+ break;
+ }
+
+ prev = tmp;
+ tmp = tmp->next;
+ }
+
+ return list;
+}
+
+static __inline__
+unsigned int
+jack_slist_length (JSList *list)
+{
+ unsigned int length;
+
+ length = 0;
+ while (list) {
+ length++;
+ list = list->next;
+ }
+
+ return length;
+}
+
+static __inline__
+JSList*
+jack_slist_find (JSList *list,
+ void *data)
+{
+ while (list) {
+ if (list->data == data)
+ break;
+ list = list->next;
+ }
+
+ return list;
+}
+
+static __inline__
+JSList*
+jack_slist_copy (JSList *list)
+{
+ JSList *new_list = NULL;
+
+ if (list) {
+ JSList *last;
+
+ new_list = jack_slist_alloc ();
+ new_list->data = list->data;
+ last = new_list;
+ list = list->next;
+ while (list) {
+ last->next = jack_slist_alloc ();
+ last = last->next;
+ last->data = list->data;
+ list = list->next;
+ }
+ }
+
+ return new_list;
+}
+
+static __inline__
+JSList*
+jack_slist_append (JSList *list,
+ void *data)
+{
+ JSList *new_list;
+ JSList *last;
+
+ new_list = jack_slist_alloc ();
+ new_list->data = data;
+
+ if (list) {
+ last = jack_slist_last (list);
+ last->next = new_list;
+
+ return list;
+ } else
+ return new_list;
+}
+
+static __inline__
+JSList*
+jack_slist_sort_merge (JSList *l1,
+ JSList *l2,
+ JCompareFunc compare_func)
+{
+ JSList list, *l;
+
+ l = &list;
+
+ while (l1 && l2) {
+ if (compare_func(l1->data, l2->data) < 0) {
+ l = l->next = l1;
+ l1 = l1->next;
+ } else {
+ l = l->next = l2;
+ l2 = l2->next;
+ }
+ }
+ l->next = l1 ? l1 : l2;
+
+ return list.next;
+}
+
+static __inline__
+JSList*
+jack_slist_sort (JSList *list,
+ JCompareFunc compare_func)
+{
+ JSList *l1, *l2;
+
+ if (!list)
+ return NULL;
+ if (!list->next)
+ return list;
+
+ l1 = list;
+ l2 = list->next;
+
+ while ((l2 = l2->next) != NULL) {
+ if ((l2 = l2->next) == NULL)
+ break;
+ l1 = l1->next;
+ }
+ l2 = l1->next;
+ l1->next = NULL;
+
+ return jack_slist_sort_merge (jack_slist_sort (list, compare_func),
+ jack_slist_sort (l2, compare_func),
+ compare_func);
+}
+
+#endif /* __jack_jslist_h__ */
+
diff --git a/pipewire-jack/jack/metadata.h b/pipewire-jack/jack/metadata.h
new file mode 100644
index 0000000..75a4105
--- /dev/null
+++ b/pipewire-jack/jack/metadata.h
@@ -0,0 +1,322 @@
+/*
+ Copyright (C) 2011-2014 David Robillard
+ Copyright (C) 2013 Paul Davis
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or (at
+ your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file jack/metadata.h
+ * @ingroup publicheader
+ * @brief JACK Metadata API
+ *
+ */
+
+#ifndef __jack_metadata_h__
+#define __jack_metadata_h__
+
+#include <jack/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @defgroup Metadata Metadata API.
+ * @{
+ */
+
+/**
+ * A single property (key:value pair).
+ *
+ * Although there is no semantics imposed on metadata keys and values, it is
+ * much less useful to use it to associate highly structured data with a port
+ * (or client), since this then implies the need for some (presumably
+ * library-based) code to parse the structure and be able to use it.
+ *
+ * The real goal of the metadata API is to be able to tag ports (and clients)
+ * with small amounts of data that is outside of the core JACK API but
+ * nevertheless useful.
+ */
+typedef struct {
+ /** The key of this property (URI string). */
+ const char* key;
+
+ /** The property value (null-terminated string). */
+ const char* data;
+
+ /**
+ * Type of data, either a MIME type or URI.
+ *
+ * If type is NULL or empty, the data is assumed to be a UTF-8 encoded
+ * string (text/plain). The data is a null-terminated string regardless of
+ * type, so values can always be copied, but clients should not try to
+ * interpret values of an unknown type.
+ *
+ * Example values:
+ * - image/png;base64 (base64 encoded PNG image)
+ * - http://www.w3.org/2001/XMLSchema#int (integer)
+ *
+ * Official types are preferred, but clients may use any syntactically
+ * valid MIME type (which start with a type and slash, like "text/...").
+ * If a URI type is used, it must be a complete absolute URI
+ * (which start with a scheme and colon, like "http:").
+ */
+ const char* type;
+} jack_property_t;
+
+/**
+ * Set a property on @p subject.
+ *
+ * See the above documentation for rules about @p subject and @p key.
+ * @param subject The subject to set the property on.
+ * @param key The key of the property.
+ * @param value The value of the property.
+ * @param type The type of the property. See the discussion of
+ * types in the definition of jack_property_t above.
+ * @return 0 on success.
+ */
+int
+jack_set_property(jack_client_t*,
+ jack_uuid_t subject,
+ const char* key,
+ const char* value,
+ const char* type);
+
+/**
+ * Get a property on @p subject.
+ *
+ * @param subject The subject to get the property from.
+ * @param key The key of the property.
+ * @param value Set to the value of the property if found, or NULL otherwise.
+ * The caller must free this value with jack_free().
+ * @param type The type of the property if set, or NULL. See the discussion
+ * of types in the definition of jack_property_t above.
+ * If non-null, the caller must free this value with jack_free().
+ *
+ * @return 0 on success, -1 if the @p subject has no @p key property.
+ */
+int
+jack_get_property(jack_uuid_t subject,
+ const char* key,
+ char** value,
+ char** type);
+
+/**
+ * A description of a subject (a set of properties).
+ */
+typedef struct {
+ jack_uuid_t subject; /**< Subject being described. */
+ uint32_t property_cnt; /**< Number of elements in "properties". */
+ jack_property_t* properties; /**< Array of properties. */
+ uint32_t property_size; /**< Private, do not use. */
+} jack_description_t;
+
+/**
+ * Free a description.
+ *
+ * @param desc a jack_description_t whose associated memory will all be released
+ * @param free_description_itself if non-zero, then @param desc will also be passed to free()
+ */
+void
+jack_free_description (jack_description_t* desc, int free_description_itself);
+
+/**
+ * Get a description of @p subject.
+ * @param subject The subject to get all properties of.
+ * @param desc Set to the description of subject if found, or NULL otherwise.
+ * The caller must free this value with jack_free_description().
+ * @return the number of properties, -1 if no @p subject with any properties exists.
+ */
+int
+jack_get_properties (jack_uuid_t subject,
+ jack_description_t* desc);
+
+/**
+ * Get descriptions for all subjects with metadata.
+ * @param descs Set to an array of descriptions.
+ * The caller must free each of these with jack_free_description(),
+ * and the array itself with jack_free().
+ * @return the number of descriptions, or -1 on error.
+ */
+int
+jack_get_all_properties (jack_description_t** descs);
+
+/**
+ * Remove a single property on a subject.
+ *
+ * @param client The JACK client making the request to remove the property.
+ * @param subject The subject to remove the property from.
+ * @param key The key of the property to be removed.
+ *
+ * @return 0 on success, -1 otherwise
+ */
+int jack_remove_property (jack_client_t* client, jack_uuid_t subject, const char* key);
+
+/**
+ * Remove all properties on a subject.
+ *
+ * @param client The JACK client making the request to remove some properties.
+ * @param subject The subject to remove all properties from.
+ *
+ * @return a count of the number of properties removed, or -1 on error.
+ */
+int jack_remove_properties (jack_client_t* client, jack_uuid_t subject);
+
+/**
+ * Remove all properties.
+ *
+ * WARNING!! This deletes all metadata managed by a running JACK server.
+ * Data lost cannot be recovered (though it can be recreated by new calls
+ * to jack_set_property()).
+ *
+ * @param client The JACK client making the request to remove all properties
+ *
+ * @return 0 on success, -1 otherwise
+ */
+int jack_remove_all_properties (jack_client_t* client);
+
+typedef enum {
+ PropertyCreated,
+ PropertyChanged,
+ PropertyDeleted
+} jack_property_change_t;
+
+/**
+ * Prototype for the client supplied function that is called by the
+ * engine anytime a property or properties have been modified.
+ *
+ * Note that when the key is empty, it means all properties have been
+ * modified. This is often used to indicate that the removal of all keys.
+ *
+ * @param subject The subject the change relates to, this can be either a client or port
+ * @param key The key of the modified property (URI string)
+ * @param change Wherever the key has been created, changed or deleted
+ * @param arg pointer to a client supplied structure
+ */
+typedef void (*JackPropertyChangeCallback)(jack_uuid_t subject,
+ const char* key,
+ jack_property_change_t change,
+ void* arg);
+
+/**
+ * Arrange for @p client to call @p callback whenever a property is created,
+ * changed or deleted.
+ *
+ * @param client the JACK client making the request
+ * @param callback the function to be invoked when a property change occurs
+ * @param arg the argument to be passed to @param callback when it is invoked
+ *
+ * @return 0 success, -1 otherwise.
+ */
+int jack_set_property_change_callback (jack_client_t* client,
+ JackPropertyChangeCallback callback,
+ void* arg);
+
+/**
+ * A value that identifies what the hardware port is connected to (an external
+ * device of some kind). Possible values might be "E-Piano" or "Master 2 Track".
+ */
+extern const char* JACK_METADATA_CONNECTED;
+
+/**
+ * The supported event types of an event port.
+ *
+ * This is a kludge around Jack only supporting MIDI, particularly for OSC.
+ * This property is a comma-separated list of event types, currently "MIDI" or
+ * "OSC". If this contains "OSC", the port may carry OSC bundles (first byte
+ * '#') or OSC messages (first byte '/'). Note that the "status byte" of both
+ * OSC events is not a valid MIDI status byte, so MIDI clients that check the
+ * status byte will gracefully ignore OSC messages if the user makes an
+ * inappropriate connection.
+ */
+extern const char* JACK_METADATA_EVENT_TYPES;
+
+/**
+ * A value that should be shown when attempting to identify the
+ * specific hardware outputs of a client. Typical values might be
+ * "ADAT1", "S/PDIF L" or "MADI 43".
+ */
+extern const char* JACK_METADATA_HARDWARE;
+
+/**
+ * A value with a MIME type of "image/png;base64" that is an encoding of an
+ * NxN (with 32 < N <= 128) image to be used when displaying a visual
+ * representation of that client or port.
+ */
+extern const char* JACK_METADATA_ICON_LARGE;
+
+/**
+ * The name of the icon for the subject (typically client).
+ *
+ * This is used for looking up icons on the system, possibly with many sizes or
+ * themes. Icons should be searched for according to the freedesktop Icon
+ *
+ * Theme Specification:
+ * https://specifications.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html
+ */
+extern const char* JACK_METADATA_ICON_NAME;
+
+/**
+ * A value with a MIME type of "image/png;base64" that is an encoding of an
+ * NxN (with N <=32) image to be used when displaying a visual representation
+ * of that client or port.
+ */
+extern const char* JACK_METADATA_ICON_SMALL;
+
+/**
+ * Order for a port.
+ *
+ * This is used to specify the best order to show ports in user interfaces.
+ * The value MUST be an integer. There are no other requirements, so there may
+ * be gaps in the orders for several ports. Applications should compare the
+ * orders of ports to determine their relative order, but must not assign any
+ * other relevance to order values.
+ *
+ * It is encouraged to use http://www.w3.org/2001/XMLSchema#int as the type.
+ */
+extern const char* JACK_METADATA_ORDER;
+
+/**
+ * A value that should be shown to the user when displaying a port to the user,
+ * unless the user has explicitly overridden that a request to show the port
+ * name, or some other key value.
+ */
+extern const char* JACK_METADATA_PRETTY_NAME;
+
+/**
+ */
+extern const char* JACK_METADATA_PORT_GROUP;
+
+/**
+ * The type of an audio signal.
+ *
+ * This property allows audio ports to be tagged with a "meaning". The value
+ * is a simple string. Currently, the only type is "CV", for "control voltage"
+ * ports. Hosts SHOULD be take care to not treat CV ports as audible and send
+ * their output directly to speakers. In particular, CV ports are not
+ * necessarily periodic at all and may have very high DC.
+ */
+extern const char* JACK_METADATA_SIGNAL_TYPE;
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+} /* namespace */
+#endif
+
+#endif /* __jack_metadata_h__ */
diff --git a/pipewire-jack/jack/midiport.h b/pipewire-jack/jack/midiport.h
new file mode 100644
index 0000000..0ae5e79
--- /dev/null
+++ b/pipewire-jack/jack/midiport.h
@@ -0,0 +1,197 @@
+/*
+ Copyright (C) 2004 Ian Esten
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+
+
+#ifndef __JACK_MIDIPORT_H
+#define __JACK_MIDIPORT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <jack/weakmacros.h>
+#include <jack/types.h>
+#include <stdlib.h>
+
+
+/** Type for raw event data contained in @ref jack_midi_event_t. */
+typedef unsigned char jack_midi_data_t;
+
+
+/** A Jack MIDI event. */
+typedef struct _jack_midi_event
+{
+ jack_nframes_t time; /**< Sample index at which event is valid */
+ size_t size; /**< Number of bytes of data in \a buffer */
+ jack_midi_data_t *buffer; /**< Raw MIDI data */
+} jack_midi_event_t;
+
+
+/**
+ * @defgroup MIDIAPI Reading and writing MIDI data
+ * @{
+ */
+
+/** Get number of events in a port buffer.
+ *
+ * @param port_buffer Port buffer from which to retrieve event.
+ * @return number of events inside @a port_buffer
+ */
+uint32_t
+jack_midi_get_event_count(void* port_buffer) JACK_OPTIONAL_WEAK_EXPORT;
+
+
+/** Get a MIDI event from an event port buffer.
+ *
+ * Jack MIDI is normalised, the MIDI event returned by this function is
+ * guaranteed to be a complete MIDI event (the status byte will always be
+ * present, and no realtime events will interspersed with the event).
+ *
+ * This rule does not apply to System Exclusive MIDI messages
+ * since they can be of arbitrary length.
+ * To maintain smooth realtime operation such events CAN be delivered
+ * as multiple, non-normalised events.
+ * The maximum size of one event "chunk" depends on the MIDI backend in use.
+ * For example the midiseq driver will create chunks of 256 bytes.
+ * The first SysEx "chunked" event starts with 0xF0 and the last
+ * delivered chunk ends with 0xF7.
+ * To receive the full SysEx message, a caller of jack_midi_event_get()
+ * must concatenate chunks until a chunk ends with 0xF7.
+ *
+ * @param event Event structure to store retrieved event in.
+ * @param port_buffer Port buffer from which to retrieve event.
+ * @param event_index Index of event to retrieve.
+ * @return 0 on success, ENODATA if buffer is empty.
+ */
+int
+jack_midi_event_get(jack_midi_event_t *event,
+ void *port_buffer,
+ uint32_t event_index) JACK_OPTIONAL_WEAK_EXPORT;
+
+
+/** Clear an event buffer.
+ *
+ * This should be called at the beginning of each process cycle before calling
+ * @ref jack_midi_event_reserve or @ref jack_midi_event_write. This
+ * function may not be called on an input port's buffer.
+ *
+ * @param port_buffer Port buffer to clear (must be an output port buffer).
+ */
+void
+jack_midi_clear_buffer(void *port_buffer) JACK_OPTIONAL_WEAK_EXPORT;
+
+/** Reset an event buffer (from data allocated outside of JACK).
+ *
+ * This should be called at the beginning of each process cycle before calling
+ * @ref jack_midi_event_reserve or @ref jack_midi_event_write. This
+ * function may not be called on an input port's buffer.
+ *
+ * @deprecated Please use jack_midi_clear_buffer().
+ *
+ * @param port_buffer Port buffer to reset.
+ */
+void
+jack_midi_reset_buffer(void *port_buffer) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
+
+
+/** Get the size of the largest event that can be stored by the port.
+ *
+ * This function returns the current space available, taking into account
+ * events already stored in the port.
+ *
+ * @param port_buffer Port buffer to check size of.
+ */
+size_t
+jack_midi_max_event_size(void* port_buffer) JACK_OPTIONAL_WEAK_EXPORT;
+
+
+/** Allocate space for an event to be written to an event port buffer.
+ *
+ * Clients are to write the actual event data to be written starting at the
+ * pointer returned by this function. Clients must not write more than
+ * @a data_size bytes into this buffer. Clients must write normalised
+ * MIDI data to the port - no running status and no (1-byte) realtime
+ * messages interspersed with other messages (realtime messages are fine
+ * when they occur on their own, like other messages).
+ *
+ * Events must be written in order, sorted by their sample offsets.
+ * JACK will not sort the events for you, and will refuse to store
+ * out-of-order events.
+ *
+ * @param port_buffer Buffer to write event to.
+ * @param time Sample offset of event.
+ * @param data_size Length of event's raw data in bytes.
+ * @return Pointer to the beginning of the reserved event's data buffer, or
+ * NULL on error (ie not enough space).
+ */
+jack_midi_data_t*
+jack_midi_event_reserve(void *port_buffer,
+ jack_nframes_t time,
+ size_t data_size) JACK_OPTIONAL_WEAK_EXPORT;
+
+
+/** Write an event into an event port buffer.
+ *
+ * This function is simply a wrapper for @ref jack_midi_event_reserve
+ * which writes the event data into the space reserved in the buffer.
+ *
+ * Clients must not write more than
+ * @a data_size bytes into this buffer. Clients must write normalised
+ * MIDI data to the port - no running status and no (1-byte) realtime
+ * messages interspersed with other messages (realtime messages are fine
+ * when they occur on their own, like other messages).
+ *
+ * Events must be written in order, sorted by their sample offsets.
+ * JACK will not sort the events for you, and will refuse to store
+ * out-of-order events.
+ *
+ * @param port_buffer Buffer to write event to.
+ * @param time Sample offset of event.
+ * @param data Message data to be written.
+ * @param data_size Length of @a data in bytes.
+ * @return 0 on success, ENOBUFS if there's not enough space in buffer for event.
+ */
+int
+jack_midi_event_write(void *port_buffer,
+ jack_nframes_t time,
+ const jack_midi_data_t *data,
+ size_t data_size) JACK_OPTIONAL_WEAK_EXPORT;
+
+
+/** Get the number of events that could not be written to @a port_buffer.
+ *
+ * This function returning a non-zero value implies @a port_buffer is full.
+ * Currently the only way this can happen is if events are lost on port mixdown.
+ *
+ * @param port_buffer Port to receive count for.
+ * @returns Number of events that could not be written to @a port_buffer.
+ */
+uint32_t
+jack_midi_get_lost_event_count(void *port_buffer) JACK_OPTIONAL_WEAK_EXPORT;
+
+/*@}*/
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __JACK_MIDIPORT_H */
+
+
diff --git a/pipewire-jack/jack/net.h b/pipewire-jack/jack/net.h
new file mode 100644
index 0000000..3f214be
--- /dev/null
+++ b/pipewire-jack/jack/net.h
@@ -0,0 +1,429 @@
+/*
+ Copyright (C) 2009-2010 Grame
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+
+#ifndef __net_h__
+#define __net_h__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <jack/systemdeps.h>
+#include <jack/types.h>
+#include <jack/weakmacros.h>
+
+#define DEFAULT_MULTICAST_IP "225.3.19.154"
+#define DEFAULT_PORT 19000
+#define DEFAULT_MTU 1500
+#define MASTER_NAME_SIZE 256
+
+// Possible error codes
+
+#define NO_ERROR 0
+#define SOCKET_ERROR -1
+#define SYNC_PACKET_ERROR -2
+#define DATA_PACKET_ERROR -3
+
+#define RESTART_CB_API 1
+
+enum JackNetEncoder {
+
+ JackFloatEncoder = 0, // samples are transmitted as float
+ JackIntEncoder = 1, // samples are transmitted as 16 bits integer
+ JackCeltEncoder = 2, // samples are transmitted using CELT codec (http://www.celt-codec.org/)
+ JackOpusEncoder = 3, // samples are transmitted using OPUS codec (http://www.opus-codec.org/)
+};
+
+typedef struct {
+
+ int audio_input; // from master or to slave (-1 to take master audio physical inputs)
+ int audio_output; // to master or from slave (-1 to take master audio physical outputs)
+ int midi_input; // from master or to slave (-1 to take master MIDI physical inputs)
+ int midi_output; // to master or from slave (-1 to take master MIDI physical outputs)
+ int mtu; // network Maximum Transmission Unit
+ int time_out; // in second, -1 means infinite
+ int encoder; // encoder type (one of JackNetEncoder)
+ int kbps; // KB per second for CELT or OPUS codec
+ int latency; // network latency in number of buffers
+
+} jack_slave_t;
+
+typedef struct {
+
+ int audio_input; // master audio physical outputs (-1 to take slave wanted audio inputs)
+ int audio_output; // master audio physical inputs (-1 to take slave wanted audio outputs)
+ int midi_input; // master MIDI physical outputs (-1 to take slave wanted MIDI inputs)
+ int midi_output; // master MIDI physical inputs (-1 to take slave wanted MIDI outputs)
+ jack_nframes_t buffer_size; // master buffer size
+ jack_nframes_t sample_rate; // master sample rate
+ char master_name[MASTER_NAME_SIZE]; // master machine name
+ int time_out; // in second, -1 means infinite
+ int partial_cycle; // if 'true', partial buffers will be used
+
+} jack_master_t;
+
+/**
+ * jack_net_slave_t is an opaque type. You may only access it using the
+ * API provided.
+ */
+typedef struct _jack_net_slave jack_net_slave_t;
+
+ /**
+ * Open a network connection with the master machine.
+ *
+ * @param ip the multicast address of the master
+ * @param port the connection port
+ * @param name the JACK client name
+ * @param request a connection request structure
+ * @param result a connection result structure
+ *
+ * @return Opaque net handle if successful or NULL in case of error.
+ */
+jack_net_slave_t* jack_net_slave_open(const char* ip, int port, const char* name, jack_slave_t* request, jack_master_t* result);
+
+/**
+ * Close the network connection with the master machine.
+ *
+ * @param net the network connection to be closed
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+int jack_net_slave_close(jack_net_slave_t* net);
+
+/**
+ * Prototype for Process callback.
+ *
+ * @param nframes buffer size
+ * @param audio_input number of audio inputs
+ * @param audio_input_buffer an array of audio input buffers (from master)
+ * @param midi_input number of MIDI inputs
+ * @param midi_input_buffer an array of MIDI input buffers (from master)
+ * @param audio_output number of audio outputs
+ * @param audio_output_buffer an array of audio output buffers (to master)
+ * @param midi_output number of MIDI outputs
+ * @param midi_output_buffer an array of MIDI output buffers (to master)
+ * @param arg pointer to a client supplied structure supplied by jack_set_net_process_callback()
+ *
+ * @return zero on success, non-zero on error
+ */
+typedef int (* JackNetSlaveProcessCallback) (jack_nframes_t buffer_size,
+ int audio_input,
+ float** audio_input_buffer,
+ int midi_input,
+ void** midi_input_buffer,
+ int audio_output,
+ float** audio_output_buffer,
+ int midi_output,
+ void** midi_output_buffer,
+ void* data);
+
+/**
+ * Set network process callback.
+ *
+ * @param net the network connection
+ * @param net_callback the process callback
+ * @param arg pointer to a client supplied structure
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+int jack_set_net_slave_process_callback(jack_net_slave_t * net, JackNetSlaveProcessCallback net_callback, void *arg);
+
+/**
+ * Start processing thread, the net_callback will start to be called.
+ *
+ * @param net the network connection
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+int jack_net_slave_activate(jack_net_slave_t* net);
+
+/**
+ * Stop processing thread.
+ *
+ * @param net the network connection
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+int jack_net_slave_deactivate(jack_net_slave_t* net);
+
+/**
+ * Test if slave is still active.
+ *
+ * @param net the network connection
+ *
+ * @return a boolean
+ */
+int jack_net_slave_is_active(jack_net_slave_t* net);
+
+/**
+ * Prototype for BufferSize callback.
+ *
+ * @param nframes buffer size
+ * @param arg pointer to a client supplied structure supplied by jack_set_net_buffer_size_callback()
+ *
+ * @return zero on success, non-zero on error
+ */
+typedef int (*JackNetSlaveBufferSizeCallback)(jack_nframes_t nframes, void *arg);
+
+/**
+ * Set network buffer size callback.
+ *
+ * @param net the network connection
+ * @param bufsize_callback the buffer size callback
+ * @param arg pointer to a client supplied structure
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+int jack_set_net_slave_buffer_size_callback(jack_net_slave_t *net, JackNetSlaveBufferSizeCallback bufsize_callback, void *arg);
+
+/**
+ * Prototype for SampleRate callback.
+ *
+ * @param nframes sample rate
+ * @param arg pointer to a client supplied structure supplied by jack_set_net_sample_rate_callback()
+ *
+ * @return zero on success, non-zero on error
+ */
+typedef int (*JackNetSlaveSampleRateCallback)(jack_nframes_t nframes, void *arg);
+
+/**
+ * Set network sample rate callback.
+ *
+ * @param net the network connection
+ * @param samplerate_callback the sample rate callback
+ * @param arg pointer to a client supplied structure
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+int jack_set_net_slave_sample_rate_callback(jack_net_slave_t *net, JackNetSlaveSampleRateCallback samplerate_callback, void *arg);
+
+/**
+ * Prototype for server Shutdown callback (if not set, the client will just restart, waiting for an available master again).
+ *
+ * @param arg pointer to a client supplied structure supplied by jack_set_net_shutdown_callback()
+ */
+typedef void (*JackNetSlaveShutdownCallback)(void* arg);
+
+/**
+ * Set network shutdown callback.
+ *
+ * @param net the network connection
+ * @param shutdown_callback the shutdown callback
+ * @param arg pointer to a client supplied structure
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+int jack_set_net_slave_shutdown_callback(jack_net_slave_t *net, JackNetSlaveShutdownCallback shutdown_callback, void *arg) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
+
+/**
+ * Prototype for server Restart callback : this is the new preferable way to be notified when the master has disappeared.
+ * The client may want to retry connecting a certain number of time (which will be done using the time_out value given in jack_net_slave_open)
+ * by returning 0. Otherwise returning a non-zero error code will definitively close the connection
+ * (and jack_net_slave_is_active will later on return false).
+ * If both Shutdown and Restart are supplied, Restart callback will be used.
+ *
+ * @param arg pointer to a client supplied structure supplied by jack_set_net_restart_callback()
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+typedef int (*JackNetSlaveRestartCallback)(void* arg);
+
+/**
+ * Set network restart callback.
+ *
+ * @param net the network connection
+ * @param restart_callback the shutdown callback
+ * @param arg pointer to a client supplied structure
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+int jack_set_net_slave_restart_callback(jack_net_slave_t *net, JackNetSlaveRestartCallback restart_callback, void *arg) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Prototype for server Error callback.
+ *
+ * @param error_code an error code (see "Possible error codes")
+ * @param arg pointer to a client supplied structure supplied by jack_set_net_error_callback()
+ */
+typedef void (*JackNetSlaveErrorCallback) (int error_code, void* arg);
+
+/**
+ * Set error restart callback.
+ *
+ * @param net the network connection
+ * @param error_callback the error callback
+ * @param arg pointer to a client supplied structure
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+int jack_set_net_slave_error_callback(jack_net_slave_t *net, JackNetSlaveErrorCallback error_callback, void *arg) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * jack_net_master_t is an opaque type, you may only access it using the API provided.
+ */
+typedef struct _jack_net_master jack_net_master_t;
+
+ /**
+ * Open a network connection with the slave machine.
+ *
+ * @param ip the multicast address of the master
+ * @param port the connection port
+ * @param request a connection request structure
+ * @param result a connection result structure
+ *
+ * @return Opaque net handle if successful or NULL in case of error.
+ */
+jack_net_master_t* jack_net_master_open(const char* ip, int port, jack_master_t* request, jack_slave_t* result);
+
+/**
+ * Close the network connection with the slave machine.
+ *
+ * @param net the network connection to be closed
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+int jack_net_master_close(jack_net_master_t* net);
+
+/**
+ * Receive sync and data from the network (complete buffer).
+ *
+ * @param net the network connection
+ * @param audio_input number of audio inputs
+ * @param audio_input_buffer an array of audio input buffers
+ * @param midi_input number of MIDI inputs
+ * @param midi_input_buffer an array of MIDI input buffers
+ *
+ * @return zero on success, non-zero on error
+ */
+int jack_net_master_recv(jack_net_master_t* net, int audio_input, float** audio_input_buffer, int midi_input, void** midi_input_buffer);
+
+/**
+ * Receive sync and data from the network (incomplete buffer).
+ *
+ * @param net the network connection
+ * @param audio_input number of audio inputs
+ * @param audio_input_buffer an array of audio input buffers
+ * @param midi_input number of MIDI inputs
+ * @param midi_input_buffer an array of MIDI input buffers
+ * @param frames the number of frames to receive
+ *
+ * @return zero on success, non-zero on error
+ */
+int jack_net_master_recv_slice(jack_net_master_t* net, int audio_input, float** audio_input_buffer, int midi_input, void** midi_input_buffer, int frames);
+
+/**
+ * Send sync and data to the network (complete buffer).
+ *
+ * @param net the network connection
+ * @param audio_output number of audio outputs
+ * @param audio_output_buffer an array of audio output buffers
+ * @param midi_output number of MIDI outputs
+ * @param midi_output_buffer an array of MIDI output buffers
+ *
+ * @return zero on success, non-zero on error
+ */
+int jack_net_master_send(jack_net_master_t* net, int audio_output, float** audio_output_buffer, int midi_output, void** midi_output_buffer);
+
+/**
+ * Send sync and data to the network (incomplete buffer).
+ *
+ * @param net the network connection
+ * @param audio_output number of audio outputs
+ * @param audio_output_buffer an array of audio output buffers
+ * @param midi_output number of MIDI outputs
+ * @param midi_output_buffer an array of MIDI output buffers
+ * @param frames the number of frames to send
+ *
+ * @return zero on success, non-zero on error
+ */
+int jack_net_master_send_slice(jack_net_master_t* net, int audio_output, float** audio_output_buffer, int midi_output, void** midi_output_buffer, int frames);
+
+// Experimental Adapter API
+
+/**
+ * jack_adapter_t is an opaque type, you may only access it using the API provided.
+ */
+typedef struct _jack_adapter jack_adapter_t;
+
+/**
+ * Create an adapter.
+ *
+ * @param input number of audio inputs
+ * @param output of audio outputs
+ * @param host_buffer_size the host buffer size in frames
+ * @param host_sample_rate the host buffer sample rate
+ * @param adapted_buffer_size the adapted buffer size in frames
+ * @param adapted_sample_rate the adapted buffer sample rate
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+jack_adapter_t* jack_create_adapter(int input, int output,
+ jack_nframes_t host_buffer_size,
+ jack_nframes_t host_sample_rate,
+ jack_nframes_t adapted_buffer_size,
+ jack_nframes_t adapted_sample_rate);
+
+/**
+ * Destroy an adapter.
+ *
+ * @param adapter the adapter to be destroyed
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+int jack_destroy_adapter(jack_adapter_t* adapter);
+
+/**
+ * Flush internal state of an adapter.
+ *
+ * @param adapter the adapter to be flushed
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+void jack_flush_adapter(jack_adapter_t* adapter);
+
+/**
+ * Push input to and pull output from adapter ringbuffer.
+ *
+ * @param adapter the adapter
+ * @param input an array of audio input buffers
+ * @param output an array of audio output buffers
+ * @param frames number of frames
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+int jack_adapter_push_and_pull(jack_adapter_t* adapter, float** input, float** output, unsigned int frames);
+
+/**
+ * Pull input from and push output to adapter ringbuffer.
+ *
+ * @param adapter the adapter
+ * @param input an array of audio input buffers
+ * @param output an array of audio output buffers
+ * @param frames number of frames
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+int jack_adapter_pull_and_push(jack_adapter_t* adapter, float** input, float** output, unsigned int frames);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __net_h__ */
diff --git a/pipewire-jack/jack/ringbuffer.h b/pipewire-jack/jack/ringbuffer.h
new file mode 100644
index 0000000..5204383
--- /dev/null
+++ b/pipewire-jack/jack/ringbuffer.h
@@ -0,0 +1,243 @@
+/*
+ Copyright (C) 2000 Paul Davis
+ Copyright (C) 2003 Rohan Drape
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+
+#ifndef _RINGBUFFER_H
+#define _RINGBUFFER_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <sys/types.h>
+
+/** @file ringbuffer.h
+ *
+ * A set of library functions to make lock-free ringbuffers available
+ * to JACK clients. The `capture_client.c' (in the example_clients
+ * directory) is a fully functioning user of this API.
+ *
+ * The key attribute of a ringbuffer is that it can be safely accessed
+ * by two threads simultaneously -- one reading from the buffer and
+ * the other writing to it -- without using any synchronization or
+ * mutual exclusion primitives. For this to work correctly, there can
+ * only be a single reader and a single writer thread. Their
+ * identities cannot be interchanged.
+ */
+
+typedef struct {
+ char *buf;
+ size_t len;
+}
+jack_ringbuffer_data_t ;
+
+typedef struct {
+ char *buf;
+ volatile size_t write_ptr;
+ volatile size_t read_ptr;
+ size_t size;
+ size_t size_mask;
+ int mlocked;
+}
+jack_ringbuffer_t ;
+
+/**
+ * Allocates a ringbuffer data structure of a specified size. The
+ * caller must arrange for a call to jack_ringbuffer_free() to release
+ * the memory associated with the ringbuffer.
+ *
+ * @param sz the ringbuffer size in bytes.
+ *
+ * @return a pointer to a new jack_ringbuffer_t, if successful; NULL
+ * otherwise.
+ */
+jack_ringbuffer_t *jack_ringbuffer_create(size_t sz);
+
+/**
+ * Frees the ringbuffer data structure allocated by an earlier call to
+ * jack_ringbuffer_create().
+ *
+ * @param rb a pointer to the ringbuffer structure.
+ */
+void jack_ringbuffer_free(jack_ringbuffer_t *rb);
+
+/**
+ * Fill a data structure with a description of the current readable
+ * data held in the ringbuffer. This description is returned in a two
+ * element array of jack_ringbuffer_data_t. Two elements are needed
+ * because the data to be read may be split across the end of the
+ * ringbuffer.
+ *
+ * The first element will always contain a valid @a len field, which
+ * may be zero or greater. If the @a len field is non-zero, then data
+ * can be read in a contiguous fashion using the address given in the
+ * corresponding @a buf field.
+ *
+ * If the second element has a non-zero @a len field, then a second
+ * contiguous stretch of data can be read from the address given in
+ * its corresponding @a buf field.
+ *
+ * @param rb a pointer to the ringbuffer structure.
+ * @param vec a pointer to a 2 element array of jack_ringbuffer_data_t.
+ *
+ */
+void jack_ringbuffer_get_read_vector(const jack_ringbuffer_t *rb,
+ jack_ringbuffer_data_t *vec);
+
+/**
+ * Fill a data structure with a description of the current writable
+ * space in the ringbuffer. The description is returned in a two
+ * element array of jack_ringbuffer_data_t. Two elements are needed
+ * because the space available for writing may be split across the end
+ * of the ringbuffer.
+ *
+ * The first element will always contain a valid @a len field, which
+ * may be zero or greater. If the @a len field is non-zero, then data
+ * can be written in a contiguous fashion using the address given in
+ * the corresponding @a buf field.
+ *
+ * If the second element has a non-zero @a len field, then a second
+ * contiguous stretch of data can be written to the address given in
+ * the corresponding @a buf field.
+ *
+ * @param rb a pointer to the ringbuffer structure.
+ * @param vec a pointer to a 2 element array of jack_ringbuffer_data_t.
+ */
+void jack_ringbuffer_get_write_vector(const jack_ringbuffer_t *rb,
+ jack_ringbuffer_data_t *vec);
+
+/**
+ * Read data from the ringbuffer.
+ *
+ * @param rb a pointer to the ringbuffer structure.
+ * @param dest a pointer to a buffer where data read from the
+ * ringbuffer will go.
+ * @param cnt the number of bytes to read.
+ *
+ * @return the number of bytes read, which may range from 0 to cnt.
+ */
+size_t jack_ringbuffer_read(jack_ringbuffer_t *rb, char *dest, size_t cnt);
+
+/**
+ * Read data from the ringbuffer. Opposed to jack_ringbuffer_read()
+ * this function does not move the read pointer. Thus it's
+ * a convenient way to inspect data in the ringbuffer in a
+ * continuous fashion. The price is that the data is copied
+ * into a user provided buffer. For "raw" non-copy inspection
+ * of the data in the ringbuffer use jack_ringbuffer_get_read_vector().
+ *
+ * @param rb a pointer to the ringbuffer structure.
+ * @param dest a pointer to a buffer where data read from the
+ * ringbuffer will go.
+ * @param cnt the number of bytes to read.
+ *
+ * @return the number of bytes read, which may range from 0 to cnt.
+ */
+size_t jack_ringbuffer_peek(jack_ringbuffer_t *rb, char *dest, size_t cnt);
+
+/**
+ * Advance the read pointer.
+ *
+ * After data have been read from the ringbuffer using the pointers
+ * returned by jack_ringbuffer_get_read_vector(), use this function to
+ * advance the buffer pointers, making that space available for future
+ * write operations.
+ *
+ * @param rb a pointer to the ringbuffer structure.
+ * @param cnt the number of bytes read.
+ */
+void jack_ringbuffer_read_advance(jack_ringbuffer_t *rb, size_t cnt);
+
+/**
+ * Return the number of bytes available for reading.
+ *
+ * @param rb a pointer to the ringbuffer structure.
+ *
+ * @return the number of bytes available to read.
+ */
+size_t jack_ringbuffer_read_space(const jack_ringbuffer_t *rb);
+
+/**
+ * Lock a ringbuffer data block into memory.
+ *
+ * Uses the mlock() system call. This is not a realtime operation.
+ *
+ * @param rb a pointer to the ringbuffer structure.
+ */
+int jack_ringbuffer_mlock(jack_ringbuffer_t *rb);
+
+/**
+ * Reset the read and write pointers, making an empty buffer.
+ *
+ * This is not thread safe.
+ *
+ * @param rb a pointer to the ringbuffer structure.
+ */
+void jack_ringbuffer_reset(jack_ringbuffer_t *rb);
+
+/**
+ * Reset the internal "available" size, and read and write pointers, making an empty buffer.
+ *
+ * This is not thread safe.
+ *
+ * @param rb a pointer to the ringbuffer structure.
+ * @param sz the new size, that must be less than allocated size.
+ */
+void jack_ringbuffer_reset_size (jack_ringbuffer_t * rb, size_t sz);
+
+/**
+ * Write data into the ringbuffer.
+ *
+ * @param rb a pointer to the ringbuffer structure.
+ * @param src a pointer to the data to be written to the ringbuffer.
+ * @param cnt the number of bytes to write.
+ *
+ * @return the number of bytes write, which may range from 0 to cnt
+ */
+size_t jack_ringbuffer_write(jack_ringbuffer_t *rb, const char *src,
+ size_t cnt);
+
+/**
+ * Advance the write pointer.
+ *
+ * After data have been written the ringbuffer using the pointers
+ * returned by jack_ringbuffer_get_write_vector(), use this function
+ * to advance the buffer pointer, making the data available for future
+ * read operations.
+ *
+ * @param rb a pointer to the ringbuffer structure.
+ * @param cnt the number of bytes written.
+ */
+void jack_ringbuffer_write_advance(jack_ringbuffer_t *rb, size_t cnt);
+
+/**
+ * Return the number of bytes available for writing.
+ *
+ * @param rb a pointer to the ringbuffer structure.
+ *
+ * @return the amount of free space (in bytes) available for writing.
+ */
+size_t jack_ringbuffer_write_space(const jack_ringbuffer_t *rb);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/pipewire-jack/jack/session.h b/pipewire-jack/jack/session.h
new file mode 100644
index 0000000..1198a09
--- /dev/null
+++ b/pipewire-jack/jack/session.h
@@ -0,0 +1,302 @@
+/*
+ Copyright (C) 2001 Paul Davis
+ Copyright (C) 2004 Jack O'Quin
+ Copyright (C) 2010 Torben Hohn
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef __jack_session_h__
+#define __jack_session_h__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <jack/types.h>
+#include <jack/weakmacros.h>
+
+/**
+ * @defgroup SessionClientFunctions Session API for clients.
+ *
+ * @deprecated Use of JACK-Session is currently deprecated and unsupported.
+ * JACK developers recommend the use of NSM instead.
+ * See https://github.com/linuxaudio/new-session-manager
+ * @{
+ */
+
+
+/**
+ * Session event type.
+ *
+ * If a client can't save templates, i might just do a normal save.
+ *
+ * There is no "quit without saving" event because a client might refuse to
+ * quit when it has unsaved data, but other clients may have already quit.
+ * This results in too much confusion, so it is unsupported.
+ */
+enum JackSessionEventType {
+ /**
+ * Save the session completely.
+ *
+ * The client may save references to data outside the provided directory,
+ * but it must do so by creating a link inside the provided directory and
+ * referring to that in any save files. The client must not refer to data
+ * files outside the provided directory directly in save files, because
+ * this makes it impossible for the session manager to create a session
+ * archive for distribution or archival.
+ */
+ JackSessionSave = 1,
+
+ /**
+ * Save the session completely, then quit.
+ *
+ * The rules for saving are exactly the same as for JackSessionSave.
+ */
+ JackSessionSaveAndQuit = 2,
+
+ /**
+ * Save a session template.
+ *
+ * A session template is a "skeleton" of the session, but without any data.
+ * Clients must save a session that, when restored, will create the same
+ * ports as a full save would have. However, the actual data contained in
+ * the session may not be saved (e.g. a DAW would create the necessary
+ * tracks, but not save the actual recorded data).
+ */
+ JackSessionSaveTemplate = 3
+};
+
+typedef enum JackSessionEventType jack_session_event_type_t;
+
+/**
+ * @ref jack_session_flags_t bits
+ */
+enum JackSessionFlags {
+ /**
+ * An error occurred while saving.
+ */
+ JackSessionSaveError = 0x01,
+
+ /**
+ * Client needs to be run in a terminal.
+ */
+ JackSessionNeedTerminal = 0x02
+};
+
+/**
+ * Session flags.
+ */
+typedef enum JackSessionFlags jack_session_flags_t;
+
+struct _jack_session_event {
+ /**
+ * The type of this session event.
+ */
+ jack_session_event_type_t type;
+
+ /**
+ * Session directory path, with trailing separator.
+ *
+ * This directory is exclusive to the client; when saving the client may
+ * create any files it likes in this directory.
+ */
+ const char *session_dir;
+
+ /**
+ * Client UUID which must be passed to jack_client_open on session load.
+ *
+ * The client can specify this in the returned command line, or save it
+ * in a state file within the session directory.
+ */
+ const char *client_uuid;
+
+ /**
+ * Reply (set by client): the command line needed to restore the client.
+ *
+ * This is a platform dependent command line. It must contain
+ * ${SESSION_DIR} instead of the actual session directory path. More
+ * generally, just as in session files, clients should not include any
+ * paths outside the session directory here as this makes
+ * archival/distribution impossible.
+ *
+ * This field is set to NULL by Jack when the event is delivered to the
+ * client. The client must set to allocated memory that is safe to
+ * free(). This memory will be freed by jack_session_event_free.
+ */
+ char *command_line;
+
+ /**
+ * Reply (set by client): Session flags.
+ */
+ jack_session_flags_t flags;
+
+ /**
+ * Future flags. Set to zero for now.
+ */
+ uint32_t future;
+};
+
+typedef struct _jack_session_event jack_session_event_t;
+
+/**
+ * Prototype for the client supplied function that is called
+ * whenever a session notification is sent via jack_session_notify().
+ *
+ * Ownership of the memory of @a event is passed to the application.
+ * It must be freed using jack_session_event_free when it's not used anymore.
+ *
+ * The client must promptly call jack_session_reply for this event.
+ *
+ * @deprecated Use of JACK-Session is currently deprecated and unsupported.
+ * JACK developers recommend the use of NSM instead.
+ * See https://github.com/linuxaudio/new-session-manager
+ *
+ * @param event The event structure.
+ * @param arg Pointer to a client supplied structure.
+ */
+typedef void (*JackSessionCallback)(jack_session_event_t *event,
+ void *arg);
+
+/**
+ * Tell the JACK server to call @a session_callback when a session event
+ * is to be delivered.
+ *
+ * setting more than one session_callback per process is probably a design
+ * error. if you have a multiclient application its more sensible to create
+ * a jack_client with only a session callback set.
+ *
+ * @deprecated Use of JACK-Session is currently deprecated and unsupported.
+ * JACK developers recommend the use of NSM instead.
+ * See https://github.com/linuxaudio/new-session-manager
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+int jack_set_session_callback (jack_client_t *client,
+ JackSessionCallback session_callback,
+ void *arg) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
+
+/**
+ * Reply to a session event.
+ *
+ * This can either be called directly from the callback, or later from a
+ * different thread. For example, it is possible to push the event through a
+ * queue and execute the save code from the GUI thread.
+ *
+ * @deprecated Use of JACK-Session is currently deprecated and unsupported.
+ * JACK developers recommend the use of NSM instead.
+ * See https://github.com/linuxaudio/new-session-manager
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+int jack_session_reply (jack_client_t *client,
+ jack_session_event_t *event) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
+
+
+/**
+ * Free memory used by a jack_session_event_t.
+ *
+ * This also frees the memory used by the command_line pointer, if its non NULL.
+ *
+ * @deprecated Use of JACK-Session is currently deprecated and unsupported.
+ * JACK developers recommend the use of NSM instead.
+ * See https://github.com/linuxaudio/new-session-manager
+ */
+void jack_session_event_free (jack_session_event_t *event) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
+
+
+/**
+ * Get the assigned uuid for client.
+ * Safe to call from callback and all other threads.
+ *
+ * The caller is responsible for calling jack_free(3) on any non-NULL
+ * returned value.
+ */
+char *jack_client_get_uuid (jack_client_t *client) JACK_WEAK_EXPORT;
+
+/**
+ * @}
+ */
+
+/**
+ * @defgroup JackSessionManagerAPI API for a session manager.
+ *
+ * @{
+ */
+
+typedef struct {
+ const char *uuid;
+ const char *client_name;
+ const char *command;
+ jack_session_flags_t flags;
+} jack_session_command_t;
+
+/**
+ * Send an event to all clients listening for session callbacks.
+ *
+ * The returned strings of the clients are accumulated and returned as an array
+ * of jack_session_command_t. its terminated by ret[i].uuid == NULL target ==
+ * NULL means send to all interested clients. otherwise a clientname
+ */
+jack_session_command_t *jack_session_notify (
+ jack_client_t* client,
+ const char *target,
+ jack_session_event_type_t type,
+ const char *path) JACK_WEAK_EXPORT;
+
+/**
+ * Free the memory allocated by a session command.
+ *
+ * @deprecated Use of JACK-Session is currently deprecated and unsupported.
+ * JACK developers recommend the use of NSM instead.
+ * See https://github.com/linuxaudio/new-session-manager
+ */
+void jack_session_commands_free (jack_session_command_t *cmds) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
+
+/**
+ * Reserve a client name and associate it with a UUID.
+ *
+ * When a client later calls jack_client_open() and specifies the UUID, jackd
+ * will assign the reserved name. This allows a session manager to know in
+ * advance under which client name its managed clients will appear.
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+int
+jack_reserve_client_name (jack_client_t *client,
+ const char *name,
+ const char *uuid) JACK_WEAK_EXPORT;
+
+/**
+ * Find out whether a client has set up a session callback.
+ *
+ * @deprecated Use of JACK-Session is currently deprecated and unsupported.
+ * JACK developers recommend the use of NSM instead.
+ * See https://github.com/linuxaudio/new-session-manager
+ *
+ * @return 0 when the client has no session callback, 1 when it has one.
+ * -1 on error.
+ */
+int
+jack_client_has_session_callback (jack_client_t *client, const char *client_name) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/pipewire-jack/jack/statistics.h b/pipewire-jack/jack/statistics.h
new file mode 100644
index 0000000..28c270d
--- /dev/null
+++ b/pipewire-jack/jack/statistics.h
@@ -0,0 +1,57 @@
+/*
+* Copyright (C) 2004 Rui Nuno Capela, Lee Revell
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public License
+* as published by the Free Software Foundation; either version 2.1
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this program; if not, write to the Free
+* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+* 02111-1307, USA.
+*
+*/
+
+#ifndef __statistics_h__
+#define __statistics_h__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <jack/types.h>
+
+/**
+ * @return the maximum delay reported by the backend since
+ * startup or reset. When compared to the period size in usecs, this
+ * can be used to estimate the ideal period size for a given setup.
+ */
+float jack_get_max_delayed_usecs (jack_client_t *client);
+
+/**
+ * @return the delay in microseconds due to the most recent XRUN
+ * occurrence. This probably only makes sense when called from a @ref
+ * JackXRunCallback defined using jack_set_xrun_callback().
+ */
+float jack_get_xrun_delayed_usecs (jack_client_t *client);
+
+/**
+ * Reset the maximum delay counter. This would be useful
+ * to estimate the effect that a change to the configuration of a running
+ * system (e.g. toggling kernel preemption) has on the delay
+ * experienced by JACK, without having to restart the JACK engine.
+ */
+void jack_reset_max_delayed_usecs (jack_client_t *client);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __statistics_h__ */
diff --git a/pipewire-jack/jack/systemdeps.h b/pipewire-jack/jack/systemdeps.h
new file mode 100644
index 0000000..84b4ce3
--- /dev/null
+++ b/pipewire-jack/jack/systemdeps.h
@@ -0,0 +1,141 @@
+/*
+Copyright (C) 2004-2012 Grame
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#ifndef __jack_systemdeps_h__
+#define __jack_systemdeps_h__
+
+#ifndef POST_PACKED_STRUCTURE
+
+ #ifdef __GNUC__
+ /* POST_PACKED_STRUCTURE needs to be a macro which
+ expands into a compiler directive. The directive must
+ tell the compiler to arrange the preceding structure
+ declaration so that it is packed on byte-boundaries rather
+ than use the natural alignment of the processor and/or
+ compiler.
+ */
+
+ #define PRE_PACKED_STRUCTURE
+ #define POST_PACKED_STRUCTURE __attribute__((__packed__))
+
+ #else
+
+ #ifdef _MSC_VER
+ #define PRE_PACKED_STRUCTURE1 __pragma(pack(push,1))
+ #define PRE_PACKED_STRUCTURE PRE_PACKED_STRUCTURE1
+ /* PRE_PACKED_STRUCTURE needs to be a macro which
+ expands into a compiler directive. The directive must
+ tell the compiler to arrange the following structure
+ declaration so that it is packed on byte-boundaries rather
+ than use the natural alignment of the processor and/or
+ compiler.
+ */
+ #define POST_PACKED_STRUCTURE ;__pragma(pack(pop))
+ /* and POST_PACKED_STRUCTURE needs to be a macro which
+ restores the packing to its previous setting */
+ #else
+ #define PRE_PACKED_STRUCTURE
+ #define POST_PACKED_STRUCTURE
+ #endif /* _MSC_VER */
+
+ #endif /* __GNUC__ */
+
+#endif
+
+#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(GNU_WIN32)
+
+ #ifdef __MINGW32__
+ # include <winsock2.h> // mingw gives warning if we include windows.h before winsock2.h
+ #endif
+
+ #include <windows.h>
+
+ #ifdef _MSC_VER /* Microsoft compiler */
+ #define __inline__ inline
+ #if (!defined(int8_t) && !defined(_STDINT_H))
+ #define __int8_t_defined
+ typedef INT8 int8_t;
+ typedef UINT8 uint8_t;
+ typedef INT16 int16_t;
+ typedef UINT16 uint16_t;
+ typedef INT32 int32_t;
+ typedef UINT32 uint32_t;
+ typedef INT64 int64_t;
+ typedef UINT64 uint64_t;
+ #endif
+ #elif __MINGW32__ /* MINGW */
+ #include <stdint.h>
+ #include <sys/types.h>
+ #else /* other compilers ...*/
+ #include <inttypes.h>
+ #include <pthread.h>
+ #include <sys/types.h>
+ #endif
+
+ #if !defined(_PTHREAD_H) && !defined(PTHREAD_WIN32)
+ /**
+ * to make jack API independent of different thread implementations,
+ * we define jack_native_thread_t to HANDLE here.
+ */
+ typedef HANDLE jack_native_thread_t;
+ #else
+ #ifdef PTHREAD_WIN32 // Added by JE - 10-10-2011
+ #include <ptw32/pthread.h> // Makes sure we #include the ptw32 version !
+ #endif
+ /**
+ * to make jack API independent of different thread implementations,
+ * we define jack_native_thread_t to pthread_t here.
+ */
+ typedef pthread_t jack_native_thread_t;
+ #endif
+
+#endif /* _WIN32 && !__CYGWIN__ && !GNU_WIN32 */
+
+#if defined(__APPLE__) || defined(__linux__) || defined(__sun__) || defined(sun) || defined(__unix__) || defined(__CYGWIN__) || defined(GNU_WIN32)
+
+ #if defined(__CYGWIN__) || defined(GNU_WIN32)
+ #include <stdint.h>
+ #endif
+ #include <inttypes.h>
+ #include <pthread.h>
+ #include <sys/types.h>
+
+ /**
+ * to make jack API independent of different thread implementations,
+ * we define jack_native_thread_t to pthread_t here.
+ */
+ typedef pthread_t jack_native_thread_t;
+
+#endif /* __APPLE__ || __linux__ || __sun__ || sun */
+
+#if (defined(__arm__) || defined(__aarch64__) || defined(__mips__) || defined(__ppc__) || defined(__powerpc__)) && !defined(__APPLE__)
+ #undef POST_PACKED_STRUCTURE
+ #define POST_PACKED_STRUCTURE
+#endif /* __arm__ || __aarch64__ || __mips__ || __ppc__ || __powerpc__ */
+
+/** define JACK_LIB_EXPORT, useful for internal clients */
+#if defined(_WIN32)
+ #define JACK_LIB_EXPORT __declspec(dllexport)
+#elif defined(__GNUC__)
+ #define JACK_LIB_EXPORT __attribute__((visibility("default")))
+#else
+ #define JACK_LIB_EXPORT
+#endif
+
+#endif /* __jack_systemdeps_h__ */
diff --git a/pipewire-jack/jack/thread.h b/pipewire-jack/jack/thread.h
new file mode 100644
index 0000000..776c520
--- /dev/null
+++ b/pipewire-jack/jack/thread.h
@@ -0,0 +1,160 @@
+/*
+ Copyright (C) 2004 Paul Davis
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+
+#ifndef __jack_thread_h__
+#define __jack_thread_h__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <jack/systemdeps.h>
+#include <jack/weakmacros.h>
+
+/* use 512KB stack per thread - the default is way too high to be feasible
+ * with mlockall() on many systems */
+#define THREAD_STACK 524288
+
+/** @file thread.h
+ *
+ * Library functions to standardize thread creation for JACK and its
+ * clients. These interfaces hide some system variations in the
+ * handling of realtime scheduling and associated privileges.
+ */
+
+/**
+ * @defgroup ClientThreads Creating and managing client threads
+ * @{
+ */
+
+ /**
+ * @returns if JACK is running with realtime scheduling, this returns
+ * the priority that any JACK-created client threads will run at.
+ * Otherwise returns -1.
+ */
+
+int jack_client_real_time_priority (jack_client_t*) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * @returns if JACK is running with realtime scheduling, this returns
+ * the maximum priority that a JACK client thread should use if the thread
+ * is subject to realtime scheduling. Otherwise returns -1.
+ */
+
+int jack_client_max_real_time_priority (jack_client_t*) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Attempt to enable realtime scheduling for a thread. On some
+ * systems that may require special privileges.
+ *
+ * @param thread POSIX thread ID.
+ * @param priority requested thread priority.
+ *
+ * @returns 0, if successful; EPERM, if the calling process lacks
+ * required realtime privileges; otherwise some other error number.
+ */
+int jack_acquire_real_time_scheduling (jack_native_thread_t thread, int priority) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Create a thread for JACK or one of its clients. The thread is
+ * created executing @a start_routine with @a arg as its sole
+ * argument.
+ *
+ * @param client the JACK client for whom the thread is being created. May be
+ * NULL if the client is being created within the JACK server.
+ * @param thread place to return POSIX thread ID.
+ * @param priority thread priority, if realtime.
+ * @param realtime true for the thread to use realtime scheduling. On
+ * some systems that may require special privileges.
+ * @param start_routine function the thread calls when it starts.
+ * @param arg parameter passed to the @a start_routine.
+ *
+ * @returns 0, if successful; otherwise some error number.
+ */
+int jack_client_create_thread (jack_client_t* client,
+ jack_native_thread_t *thread,
+ int priority,
+ int realtime, /* boolean */
+ void *(*start_routine)(void*),
+ void *arg) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Drop realtime scheduling for a thread.
+ *
+ * @param thread POSIX thread ID.
+ *
+ * @returns 0, if successful; otherwise an error number.
+ */
+int jack_drop_real_time_scheduling (jack_native_thread_t thread) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Stop the thread, waiting for the thread handler to terminate.
+ *
+ * @param thread POSIX thread ID.
+ *
+ * @returns 0, if successful; otherwise an error number.
+ */
+int jack_client_stop_thread(jack_client_t* client, jack_native_thread_t thread) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Kill the thread.
+ *
+ * @param thread POSIX thread ID.
+ *
+ * @returns 0, if successful; otherwise an error number.
+ */
+ int jack_client_kill_thread(jack_client_t* client, jack_native_thread_t thread) JACK_OPTIONAL_WEAK_EXPORT;
+
+#ifndef _WIN32
+
+ typedef int (*jack_thread_creator_t)(pthread_t*,
+ const pthread_attr_t*,
+ void* (*function)(void*),
+ void* arg);
+/**
+ * This function can be used in very very specialized cases
+ * where it is necessary that client threads created by JACK
+ * are created by something other than pthread_create(). After
+ * it is used, any threads that JACK needs for the client will
+ * will be created by calling the function passed to this
+ * function.
+ *
+ * No normal application/client should consider calling this.
+ * The specific case for which it was created involves running
+ * win32/x86 plugins under Wine on Linux, where it is necessary
+ * that all threads that might call win32 functions are known
+ * to Wine.
+ *
+ * Set it to NULL to restore thread creation function.
+ *
+ * @param creator a function that creates a new thread
+ *
+ */
+void jack_set_thread_creator (jack_thread_creator_t creator) JACK_OPTIONAL_WEAK_EXPORT;
+
+#endif
+
+/* @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __jack_thread_h__ */
diff --git a/pipewire-jack/jack/transport.h b/pipewire-jack/jack/transport.h
new file mode 100644
index 0000000..4cec6e0
--- /dev/null
+++ b/pipewire-jack/jack/transport.h
@@ -0,0 +1,247 @@
+/*
+ Copyright (C) 2002 Paul Davis
+ Copyright (C) 2003 Jack O'Quin
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+
+#ifndef __jack_transport_h__
+#define __jack_transport_h__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <jack/types.h>
+#include <jack/weakmacros.h>
+
+/**
+ * @defgroup TransportControl Transport and Timebase control
+ * @{
+ */
+
+/**
+ * Called by the timebase master to release itself from that
+ * responsibility.
+ *
+ * If the timebase master releases the timebase or leaves the JACK
+ * graph for any reason, the JACK engine takes over at the start of
+ * the next process cycle. The transport state does not change. If
+ * rolling, it continues to play, with frame numbers as the only
+ * available position information.
+ *
+ * @see jack_set_timebase_callback
+ *
+ * @param client the JACK client structure.
+ *
+ * @return 0 on success, otherwise a non-zero error code.
+ */
+int jack_release_timebase (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Register (or unregister) as a slow-sync client, one that cannot
+ * respond immediately to transport position changes.
+ *
+ * The @a sync_callback will be invoked at the first available
+ * opportunity after its registration is complete. If the client is
+ * currently active this will be the following process cycle,
+ * otherwise it will be the first cycle after calling jack_activate().
+ * After that, it runs according to the ::JackSyncCallback rules.
+ * Clients that don't set a @a sync_callback are assumed to be ready
+ * immediately any time the transport wants to start.
+ *
+ * @param client the JACK client structure.
+ * @param sync_callback is a realtime function that returns TRUE when
+ * the client is ready. Setting @a sync_callback to NULL declares that
+ * this client no longer requires slow-sync processing.
+ * @param arg an argument for the @a sync_callback function.
+ *
+ * @return 0 on success, otherwise a non-zero error code.
+ */
+int jack_set_sync_callback (jack_client_t *client,
+ JackSyncCallback sync_callback,
+ void *arg) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Set the timeout value for slow-sync clients.
+ *
+ * This timeout prevents unresponsive slow-sync clients from
+ * completely halting the transport mechanism. The default is two
+ * seconds. When the timeout expires, the transport starts rolling,
+ * even if some slow-sync clients are still unready. The @a
+ * sync_callbacks of these clients continue being invoked, giving them
+ * a chance to catch up.
+ *
+ * @see jack_set_sync_callback
+ *
+ * @param client the JACK client structure.
+ * @param timeout is delay (in microseconds) before the timeout expires.
+ *
+ * @return 0 on success, otherwise a non-zero error code.
+ */
+int jack_set_sync_timeout (jack_client_t *client,
+ jack_time_t timeout) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Register as timebase master for the JACK subsystem.
+ *
+ * The timebase master registers a callback that updates extended
+ * position information such as beats or timecode whenever necessary.
+ * Without this extended information, there is no need for this
+ * function.
+ *
+ * There is never more than one master at a time. When a new client
+ * takes over, the former @a timebase_callback is no longer called.
+ * Taking over the timebase may be done conditionally, so it fails if
+ * there was a master already.
+ *
+ * @param client the JACK client structure.
+ * @param conditional non-zero for a conditional request.
+ * @param timebase_callback is a realtime function that returns
+ * position information.
+ * @param arg an argument for the @a timebase_callback function.
+ *
+ * @return
+ * - 0 on success;
+ * - EBUSY if a conditional request fails because there was already a
+ * timebase master;
+ * - other non-zero error code.
+ */
+int jack_set_timebase_callback (jack_client_t *client,
+ int conditional,
+ JackTimebaseCallback timebase_callback,
+ void *arg) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Reposition the transport to a new frame number.
+ *
+ * May be called at any time by any client. The new position takes
+ * effect in two process cycles. If there are slow-sync clients and
+ * the transport is already rolling, it will enter the
+ * ::JackTransportStarting state and begin invoking their @a
+ * sync_callbacks until ready. This function is realtime-safe.
+ *
+ * @see jack_transport_reposition, jack_set_sync_callback
+ *
+ * @param client the JACK client structure.
+ * @param frame frame number of new transport position.
+ *
+ * @return 0 if valid request, non-zero otherwise.
+ */
+int jack_transport_locate (jack_client_t *client,
+ jack_nframes_t frame) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Query the current transport state and position.
+ *
+ * This function is realtime-safe, and can be called from any thread.
+ * If called from the process thread, @a pos corresponds to the first
+ * frame of the current cycle and the state returned is valid for the
+ * entire cycle.
+ *
+ * @param client the JACK client structure.
+ * @param pos pointer to structure for returning current transport
+ * position; @a pos->valid will show which fields contain valid data.
+ * If @a pos is NULL, do not return position information.
+ *
+ * @return Current transport state.
+ */
+jack_transport_state_t jack_transport_query (const jack_client_t *client,
+ jack_position_t *pos) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Return an estimate of the current transport frame,
+ * including any time elapsed since the last transport
+ * positional update.
+ *
+ * @param client the JACK client structure
+ */
+jack_nframes_t jack_get_current_transport_frame (const jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Request a new transport position.
+ *
+ * May be called at any time by any client. The new position takes
+ * effect in two process cycles. If there are slow-sync clients and
+ * the transport is already rolling, it will enter the
+ * ::JackTransportStarting state and begin invoking their @a
+ * sync_callbacks until ready. This function is realtime-safe.
+ *
+ * @see jack_transport_locate, jack_set_sync_callback
+ *
+ * @param client the JACK client structure.
+ * @param pos requested new transport position.
+ *
+ * @return 0 if valid request, EINVAL if position structure rejected.
+ */
+int jack_transport_reposition (jack_client_t *client,
+ const jack_position_t *pos) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Start the JACK transport rolling.
+ *
+ * Any client can make this request at any time. It takes effect no
+ * sooner than the next process cycle, perhaps later if there are
+ * slow-sync clients. This function is realtime-safe.
+ *
+ * @see jack_set_sync_callback
+ *
+ * @param client the JACK client structure.
+ */
+void jack_transport_start (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Stop the JACK transport.
+ *
+ * Any client can make this request at any time. It takes effect on
+ * the next process cycle. This function is realtime-safe.
+ *
+ * @param client the JACK client structure.
+ */
+void jack_transport_stop (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Gets the current transport info structure (deprecated).
+ *
+ * @param client the JACK client structure.
+ * @param tinfo current transport info structure. The "valid" field
+ * describes which fields contain valid data.
+ *
+ * @deprecated This is for compatibility with the earlier transport
+ * interface. Use jack_transport_query(), instead.
+ *
+ * @pre Must be called from the process thread.
+ */
+void jack_get_transport_info (jack_client_t *client,
+ jack_transport_info_t *tinfo) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Set the transport info structure (deprecated).
+ *
+ * @deprecated This function still exists for compatibility with the
+ * earlier transport interface, but it does nothing. Instead, define
+ * a ::JackTimebaseCallback.
+ */
+void jack_set_transport_info (jack_client_t *client,
+ jack_transport_info_t *tinfo) JACK_OPTIONAL_WEAK_EXPORT;
+
+/*@}*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __jack_transport_h__ */
diff --git a/pipewire-jack/jack/types.h b/pipewire-jack/jack/types.h
new file mode 100644
index 0000000..b62af96
--- /dev/null
+++ b/pipewire-jack/jack/types.h
@@ -0,0 +1,740 @@
+/*
+ Copyright (C) 2001 Paul Davis
+ Copyright (C) 2004 Jack O'Quin
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+
+#ifndef __jack_types_h__
+#define __jack_types_h__
+
+#include <jack/systemdeps.h>
+
+typedef uint64_t jack_uuid_t;
+
+typedef int32_t jack_shmsize_t;
+
+/**
+ * Type used to represent sample frame counts.
+ */
+typedef uint32_t jack_nframes_t;
+
+/**
+ * Maximum value that can be stored in jack_nframes_t
+ */
+#define JACK_MAX_FRAMES (4294967295U) /* This should be UINT32_MAX, but C++ has a problem with that. */
+
+/**
+ * Type used to represent the value of free running
+ * monotonic clock with units of microseconds.
+ */
+typedef uint64_t jack_time_t;
+
+/**
+ * Maximum size of @a load_init string passed to an internal client
+ * jack_initialize() function via jack_internal_client_load().
+ */
+#define JACK_LOAD_INIT_LIMIT 1024
+
+/**
+ * jack_intclient_t is an opaque type representing a loaded internal
+ * client. You may only access it using the API provided in @ref
+ * intclient.h "<jack/intclient.h>".
+ */
+typedef uint64_t jack_intclient_t;
+
+/**
+ * jack_port_t is an opaque type. You may only access it using the
+ * API provided.
+ */
+typedef struct _jack_port jack_port_t;
+
+/**
+ * jack_client_t is an opaque type. You may only access it using the
+ * API provided.
+ */
+typedef struct _jack_client jack_client_t;
+
+/**
+ * Ports have unique ids. A port registration callback is the only
+ * place you ever need to know their value.
+ */
+typedef uint32_t jack_port_id_t;
+
+typedef uint32_t jack_port_type_id_t;
+
+/**
+ * @ref jack_options_t bits
+ */
+enum JackOptions {
+
+ /**
+ * Null value to use when no option bits are needed.
+ */
+ JackNullOption = 0x00,
+
+ /**
+ * Do not automatically start the JACK server when it is not
+ * already running. This option is always selected if
+ * \$JACK_NO_START_SERVER is defined in the calling process
+ * environment.
+ */
+ JackNoStartServer = 0x01,
+
+ /**
+ * Use the exact client name requested. Otherwise, JACK
+ * automatically generates a unique one, if needed.
+ */
+ JackUseExactName = 0x02,
+
+ /**
+ * Open with optional <em>(char *) server_name</em> parameter.
+ */
+ JackServerName = 0x04,
+
+ /**
+ * Load internal client from optional <em>(char *)
+ * load_name</em>. Otherwise use the @a client_name.
+ */
+ JackLoadName = 0x08,
+
+ /**
+ * Pass optional <em>(char *) load_init</em> string to the
+ * jack_initialize() entry point of an internal client.
+ */
+ JackLoadInit = 0x10,
+
+ /**
+ * pass a SessionID Token this allows the sessionmanager to identify the client again.
+ */
+ JackSessionID = 0x20
+};
+
+/** Valid options for opening an external client. */
+#define JackOpenOptions (JackSessionID|JackServerName|JackNoStartServer|JackUseExactName)
+
+/** Valid options for loading an internal client. */
+#define JackLoadOptions (JackLoadInit|JackLoadName|JackUseExactName)
+
+/**
+ * Options for several JACK operations, formed by OR-ing together the
+ * relevant @ref JackOptions bits.
+ */
+typedef enum JackOptions jack_options_t;
+
+/**
+ * @ref jack_status_t bits
+ */
+enum JackStatus {
+
+ /**
+ * Overall operation failed.
+ */
+ JackFailure = 0x01,
+
+ /**
+ * The operation contained an invalid or unsupported option.
+ */
+ JackInvalidOption = 0x02,
+
+ /**
+ * The desired client name was not unique. With the @ref
+ * JackUseExactName option this situation is fatal. Otherwise,
+ * the name was modified by appending a dash and a two-digit
+ * number in the range "-01" to "-99". The
+ * jack_get_client_name() function will return the exact string
+ * that was used. If the specified @a client_name plus these
+ * extra characters would be too long, the open fails instead.
+ */
+ JackNameNotUnique = 0x04,
+
+ /**
+ * The JACK server was started as a result of this operation.
+ * Otherwise, it was running already. In either case the caller
+ * is now connected to jackd, so there is no race condition.
+ * When the server shuts down, the client will find out.
+ */
+ JackServerStarted = 0x08,
+
+ /**
+ * Unable to connect to the JACK server.
+ */
+ JackServerFailed = 0x10,
+
+ /**
+ * Communication error with the JACK server.
+ */
+ JackServerError = 0x20,
+
+ /**
+ * Requested client does not exist.
+ */
+ JackNoSuchClient = 0x40,
+
+ /**
+ * Unable to load internal client
+ */
+ JackLoadFailure = 0x80,
+
+ /**
+ * Unable to initialize client
+ */
+ JackInitFailure = 0x100,
+
+ /**
+ * Unable to access shared memory
+ */
+ JackShmFailure = 0x200,
+
+ /**
+ * Client's protocol version does not match
+ */
+ JackVersionError = 0x400,
+
+ /**
+ * Backend error
+ */
+ JackBackendError = 0x800,
+
+ /**
+ * Client zombified failure
+ */
+ JackClientZombie = 0x1000
+};
+
+/**
+ * Status word returned from several JACK operations, formed by
+ * OR-ing together the relevant @ref JackStatus bits.
+ */
+typedef enum JackStatus jack_status_t;
+
+/**
+ * @ref jack_latency_callback_mode_t
+ */
+enum JackLatencyCallbackMode {
+
+ /**
+ * Latency Callback for Capture Latency.
+ * Input Ports have their latency value setup.
+ * In the Callback the client needs to set the latency of the output ports
+ */
+ JackCaptureLatency,
+
+ /**
+ * Latency Callback for Playback Latency.
+ * Output Ports have their latency value setup.
+ * In the Callback the client needs to set the latency of the input ports
+ */
+ JackPlaybackLatency
+
+};
+
+/**
+ * Type of Latency Callback (Capture or Playback)
+ */
+typedef enum JackLatencyCallbackMode jack_latency_callback_mode_t;
+
+/**
+ * Prototype for the client supplied function that is called
+ * by the engine when port latencies need to be recalculated
+ *
+ * @param mode playback or capture latency
+ * @param arg pointer to a client supplied data
+ *
+ * @return zero on success, non-zero on error
+ */
+typedef void (*JackLatencyCallback)(jack_latency_callback_mode_t mode, void *arg);
+
+/**
+ * the new latency API operates on Ranges.
+ */
+PRE_PACKED_STRUCTURE
+struct _jack_latency_range
+{
+ /**
+ * minimum latency
+ */
+ jack_nframes_t min;
+ /**
+ * maximum latency
+ */
+ jack_nframes_t max;
+} POST_PACKED_STRUCTURE;
+
+typedef struct _jack_latency_range jack_latency_range_t;
+
+/**
+ * Prototype for the client supplied function that is called
+ * by the engine anytime there is work to be done.
+ *
+ * @pre nframes == jack_get_buffer_size()
+ * @pre nframes == pow(2,x)
+ *
+ * @param nframes number of frames to process
+ * @param arg pointer to a client supplied structure
+ *
+ * @return zero on success, non-zero on error
+ */
+typedef int (*JackProcessCallback)(jack_nframes_t nframes, void *arg);
+
+/**
+ * Prototype for the client thread routine called
+ * by the engine when the client is inserted in the graph.
+ *
+ * @param arg pointer to a client supplied structure
+ *
+ */
+typedef void *(*JackThreadCallback)(void* arg);
+
+/**
+ * Prototype for the client supplied function that is called
+ * once after the creation of the thread in which other
+ * callbacks will be made. Special thread characteristics
+ * can be set from this callback, for example. This is a
+ * highly specialized callback and most clients will not
+ * and should not use it.
+ *
+ * @param arg pointer to a client supplied structure
+ *
+ * @return void
+ */
+typedef void (*JackThreadInitCallback)(void *arg);
+
+/**
+ * Prototype for the client supplied function that is called
+ * whenever the processing graph is reordered.
+ *
+ * @param arg pointer to a client supplied structure
+ *
+ * @return zero on success, non-zero on error
+ */
+typedef int (*JackGraphOrderCallback)(void *arg);
+
+/**
+ * Prototype for the client-supplied function that is called whenever
+ * an xrun has occurred.
+ *
+ * @see jack_get_xrun_delayed_usecs()
+ *
+ * @param arg pointer to a client supplied structure
+ *
+ * @return zero on success, non-zero on error
+ */
+typedef int (*JackXRunCallback)(void *arg);
+
+/**
+ * Prototype for the @a bufsize_callback that is invoked whenever the
+ * JACK engine buffer size changes. Although this function is called
+ * in the JACK process thread, the normal process cycle is suspended
+ * during its operation, causing a gap in the audio flow. So, the @a
+ * bufsize_callback can allocate storage, touch memory not previously
+ * referenced, and perform other operations that are not realtime
+ * safe.
+ *
+ * @param nframes buffer size
+ * @param arg pointer supplied by jack_set_buffer_size_callback().
+ *
+ * @return zero on success, non-zero on error
+ */
+typedef int (*JackBufferSizeCallback)(jack_nframes_t nframes, void *arg);
+
+/**
+ * Prototype for the client supplied function that is called
+ * when the engine sample rate changes.
+ *
+ * @param nframes new engine sample rate
+ * @param arg pointer to a client supplied structure
+ *
+ * @return zero on success, non-zero on error
+ */
+typedef int (*JackSampleRateCallback)(jack_nframes_t nframes, void *arg);
+
+/**
+ * Prototype for the client supplied function that is called
+ * whenever a port is registered or unregistered.
+ *
+ * @param port the ID of the port
+ * @param arg pointer to a client supplied data
+ * @param register non-zero if the port is being registered,
+ * zero if the port is being unregistered
+ */
+typedef void (*JackPortRegistrationCallback)(jack_port_id_t port, int /* register */, void *arg);
+
+/**
+ * Prototype for the client supplied function that is called
+ * whenever a client is registered or unregistered.
+ *
+ * @param name a null-terminated string containing the client name
+ * @param register non-zero if the client is being registered,
+ * zero if the client is being unregistered
+ * @param arg pointer to a client supplied structure
+ */
+typedef void (*JackClientRegistrationCallback)(const char* name, int /* register */, void *arg);
+
+/**
+ * Prototype for the client supplied function that is called
+ * whenever a port is connected or disconnected.
+ *
+ * @param a one of two ports connected or disconnected
+ * @param b one of two ports connected or disconnected
+ * @param connect non-zero if ports were connected
+ * zero if ports were disconnected
+ * @param arg pointer to a client supplied data
+ */
+typedef void (*JackPortConnectCallback)(jack_port_id_t a, jack_port_id_t b, int connect, void* arg);
+
+/**
+ * Prototype for the client supplied function that is called
+ * whenever the port name has been changed.
+ *
+ * @param port the port that has been renamed
+ * @param new_name the new name
+ * @param arg pointer to a client supplied structure
+ */
+typedef void (*JackPortRenameCallback)(jack_port_id_t port, const char* old_name, const char* new_name, void *arg);
+
+/**
+ * Prototype for the client supplied function that is called
+ * whenever jackd starts or stops freewheeling.
+ *
+ * @param starting non-zero if we start starting to freewheel, zero otherwise
+ * @param arg pointer to a client supplied structure
+ */
+typedef void (*JackFreewheelCallback)(int starting, void *arg);
+
+/**
+ * Prototype for the client supplied function that is called
+ * whenever jackd is shutdown. Note that after server shutdown,
+ * the client pointer is *not* deallocated by libjack,
+ * the application is responsible to properly use jack_client_close()
+ * to release client resources. Warning: jack_client_close() cannot be
+ * safely used inside the shutdown callback and has to be called outside of
+ * the callback context.
+ *
+ * @param arg pointer to a client supplied structure
+ */
+typedef void (*JackShutdownCallback)(void *arg);
+
+/**
+ * Prototype for the client supplied function that is called
+ * whenever jackd is shutdown. Note that after server shutdown,
+ * the client pointer is *not* deallocated by libjack,
+ * the application is responsible to properly use jack_client_close()
+ * to release client resources. Warning: jack_client_close() cannot be
+ * safely used inside the shutdown callback and has to be called outside of
+ * the callback context.
+
+ * @param code a status word, formed by OR-ing together the relevant @ref JackStatus bits.
+ * @param reason a string describing the shutdown reason (backend failure, server crash... etc...).
+ * Note that this string will not be available anymore after the callback returns, so possibly copy it.
+ * @param arg pointer to a client supplied structure
+ */
+typedef void (*JackInfoShutdownCallback)(jack_status_t code, const char* reason, void *arg);
+
+/**
+ * Used for the type argument of jack_port_register() for default
+ * audio ports and midi ports.
+ */
+#define JACK_DEFAULT_AUDIO_TYPE "32 bit float mono audio"
+#define JACK_DEFAULT_MIDI_TYPE "8 bit raw midi"
+
+/**
+ * For convenience, use this typedef if you want to be able to change
+ * between float and double. You may want to typedef sample_t to
+ * jack_default_audio_sample_t in your application.
+ */
+typedef float jack_default_audio_sample_t;
+
+/**
+ * A port has a set of flags that are formed by AND-ing together the
+ * desired values from the list below. The flags "JackPortIsInput" and
+ * "JackPortIsOutput" are mutually exclusive and it is an error to use
+ * them both.
+ */
+enum JackPortFlags {
+
+ /**
+ * if JackPortIsInput is set, then the port can receive
+ * data.
+ */
+ JackPortIsInput = 0x1,
+
+ /**
+ * if JackPortIsOutput is set, then data can be read from
+ * the port.
+ */
+ JackPortIsOutput = 0x2,
+
+ /**
+ * if JackPortIsPhysical is set, then the port corresponds
+ * to some kind of physical I/O connector.
+ */
+ JackPortIsPhysical = 0x4,
+
+ /**
+ * if JackPortCanMonitor is set, then a call to
+ * jack_port_request_monitor() makes sense.
+ *
+ * Precisely what this means is dependent on the client. A typical
+ * result of it being called with TRUE as the second argument is
+ * that data that would be available from an output port (with
+ * JackPortIsPhysical set) is sent to a physical output connector
+ * as well, so that it can be heard/seen/whatever.
+ *
+ * Clients that do not control physical interfaces
+ * should never create ports with this bit set.
+ */
+ JackPortCanMonitor = 0x8,
+
+ /**
+ * JackPortIsTerminal means:
+ *
+ * for an input port: the data received by the port
+ * will not be passed on or made
+ * available at any other port
+ *
+ * for an output port: the data available at the port
+ * does not originate from any other port
+ *
+ * Audio synthesizers, I/O hardware interface clients, HDR
+ * systems are examples of clients that would set this flag for
+ * their ports.
+ */
+ JackPortIsTerminal = 0x10,
+
+};
+
+/**
+ * Transport states.
+ */
+typedef enum {
+
+ /* the order matters for binary compatibility */
+ JackTransportStopped = 0, /**< Transport halted */
+ JackTransportRolling = 1, /**< Transport playing */
+ JackTransportLooping = 2, /**< For OLD_TRANSPORT, now ignored */
+ JackTransportStarting = 3, /**< Waiting for sync ready */
+ JackTransportNetStarting = 4, /**< Waiting for sync ready on the network*/
+
+} jack_transport_state_t;
+
+typedef uint64_t jack_unique_t; /**< Unique ID (opaque) */
+
+/**
+ * Optional struct jack_position_t fields.
+ */
+typedef enum {
+
+ JackPositionBBT = 0x10, /**< Bar, Beat, Tick */
+ JackPositionTimecode = 0x20, /**< External timecode */
+ JackBBTFrameOffset = 0x40, /**< Frame offset of BBT information */
+ JackAudioVideoRatio = 0x80, /**< audio frames per video frame */
+ JackVideoFrameOffset = 0x100 /**< frame offset of first video frame */
+
+} jack_position_bits_t;
+
+/** all valid position bits */
+#define JACK_POSITION_MASK (JackPositionBBT|JackPositionTimecode)
+#define EXTENDED_TIME_INFO
+
+PRE_PACKED_STRUCTURE
+struct _jack_position {
+
+ /* these four cannot be set from clients: the server sets them */
+ jack_unique_t unique_1; /**< unique ID */
+ jack_time_t usecs; /**< monotonic, free-rolling */
+ jack_nframes_t frame_rate; /**< current frame rate (per second) */
+ jack_nframes_t frame; /**< frame number, always present */
+
+ jack_position_bits_t valid; /**< which other fields are valid */
+
+ /* JackPositionBBT fields: */
+ int32_t bar; /**< current bar */
+ int32_t beat; /**< current beat-within-bar */
+ int32_t tick; /**< current tick-within-beat */
+ double bar_start_tick;
+
+ float beats_per_bar; /**< time signature "numerator" */
+ float beat_type; /**< time signature "denominator" */
+ double ticks_per_beat;
+ double beats_per_minute;
+
+ /* JackPositionTimecode fields: (EXPERIMENTAL: could change) */
+ double frame_time; /**< current time in seconds */
+ double next_time; /**< next sequential frame_time
+ (unless repositioned) */
+
+ /* JackBBTFrameOffset fields: */
+ jack_nframes_t bbt_offset; /**< frame offset for the BBT fields
+ (the given bar, beat, and tick
+ values actually refer to a time
+ frame_offset frames before the
+ start of the cycle), should
+ be assumed to be 0 if
+ JackBBTFrameOffset is not
+ set. If JackBBTFrameOffset is
+ set and this value is zero, the BBT
+ time refers to the first frame of this
+ cycle. If the value is positive,
+ the BBT time refers to a frame that
+ many frames before the start of the
+ cycle. */
+
+ /* JACK video positional data (experimental) */
+
+ float audio_frames_per_video_frame; /**< number of audio frames
+ per video frame. Should be assumed
+ zero if JackAudioVideoRatio is not
+ set. If JackAudioVideoRatio is set
+ and the value is zero, no video
+ data exists within the JACK graph */
+
+ jack_nframes_t video_offset; /**< audio frame at which the first video
+ frame in this cycle occurs. Should
+ be assumed to be 0 if JackVideoFrameOffset
+ is not set. If JackVideoFrameOffset is
+ set, but the value is zero, there is
+ no video frame within this cycle. */
+
+ /* For binary compatibility, new fields should be allocated from
+ * this padding area with new valid bits controlling access, so
+ * the existing structure size and offsets are preserved. */
+ int32_t padding[7];
+
+ /* When (unique_1 == unique_2) the contents are consistent. */
+ jack_unique_t unique_2; /**< unique ID */
+
+} POST_PACKED_STRUCTURE;
+
+typedef struct _jack_position jack_position_t;
+
+/**
+ * Prototype for the @a sync_callback defined by slow-sync clients.
+ * When the client is active, this callback is invoked just before
+ * process() in the same thread. This occurs once after registration,
+ * then subsequently whenever some client requests a new position, or
+ * the transport enters the ::JackTransportStarting state. This
+ * realtime function must not wait.
+ *
+ * The transport @a state will be:
+ *
+ * - ::JackTransportStopped when a new position is requested;
+ * - ::JackTransportStarting when the transport is waiting to start;
+ * - ::JackTransportRolling when the timeout has expired, and the
+ * position is now a moving target.
+ *
+ * @param state current transport state.
+ * @param pos new transport position.
+ * @param arg the argument supplied by jack_set_sync_callback().
+ *
+ * @return TRUE (non-zero) when ready to roll.
+ */
+typedef int (*JackSyncCallback)(jack_transport_state_t state,
+ jack_position_t *pos,
+ void *arg);
+
+
+/**
+ * Prototype for the @a timebase_callback used to provide extended
+ * position information. Its output affects all of the following
+ * process cycle. This realtime function must not wait.
+ *
+ * This function is called immediately after process() in the same
+ * thread whenever the transport is rolling, or when any client has
+ * requested a new position in the previous cycle. The first cycle
+ * after jack_set_timebase_callback() is also treated as a new
+ * position, or the first cycle after jack_activate() if the client
+ * had been inactive.
+ *
+ * The timebase master may not use its @a pos argument to set @a
+ * pos->frame. To change position, use jack_transport_reposition() or
+ * jack_transport_locate(). These functions are realtime-safe, the @a
+ * timebase_callback can call them directly.
+ *
+ * @param state current transport state.
+ * @param nframes number of frames in current period.
+ * @param pos address of the position structure for the next cycle; @a
+ * pos->frame will be its frame number. If @a new_pos is FALSE, this
+ * structure contains extended position information from the current
+ * cycle. If TRUE, it contains whatever was set by the requester.
+ * The @a timebase_callback's task is to update the extended
+ * information here.
+ * @param new_pos TRUE (non-zero) for a newly requested @a pos, or for
+ * the first cycle after the @a timebase_callback is defined.
+ * @param arg the argument supplied by jack_set_timebase_callback().
+ */
+typedef void (*JackTimebaseCallback)(jack_transport_state_t state,
+ jack_nframes_t nframes,
+ jack_position_t *pos,
+ int new_pos,
+ void *arg);
+
+/*********************************************************************
+ * The following interfaces are DEPRECATED. They are only provided
+ * for compatibility with the earlier JACK transport implementation.
+ *********************************************************************/
+
+/**
+ * Optional struct jack_transport_info_t fields.
+ *
+ * @see jack_position_bits_t.
+ */
+typedef enum {
+
+ JackTransportState = 0x1, /**< Transport state */
+ JackTransportPosition = 0x2, /**< Frame number */
+ JackTransportLoop = 0x4, /**< Loop boundaries (ignored) */
+ JackTransportSMPTE = 0x8, /**< SMPTE (ignored) */
+ JackTransportBBT = 0x10 /**< Bar, Beat, Tick */
+
+} jack_transport_bits_t;
+
+/**
+ * Deprecated struct for transport position information.
+ *
+ * @deprecated This is for compatibility with the earlier transport
+ * interface. Use the jack_position_t struct, instead.
+ */
+typedef struct {
+
+ /* these two cannot be set from clients: the server sets them */
+
+ jack_nframes_t frame_rate; /**< current frame rate (per second) */
+ jack_time_t usecs; /**< monotonic, free-rolling */
+
+ jack_transport_bits_t valid; /**< which fields are legal to read */
+ jack_transport_state_t transport_state;
+ jack_nframes_t frame;
+ jack_nframes_t loop_start;
+ jack_nframes_t loop_end;
+
+ long smpte_offset; /**< SMPTE offset (from frame 0) */
+ float smpte_frame_rate; /**< 29.97, 30, 24 etc. */
+
+ int bar;
+ int beat;
+ int tick;
+ double bar_start_tick;
+
+ float beats_per_bar;
+ float beat_type;
+ double ticks_per_beat;
+ double beats_per_minute;
+
+} jack_transport_info_t;
+
+
+#endif /* __jack_types_h__ */
diff --git a/pipewire-jack/jack/uuid.h b/pipewire-jack/jack/uuid.h
new file mode 100644
index 0000000..406c119
--- /dev/null
+++ b/pipewire-jack/jack/uuid.h
@@ -0,0 +1,50 @@
+/*
+ Copyright (C) 2013 Paul Davis
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+
+#ifndef __jack_uuid_h__
+#define __jack_uuid_h__
+
+#include <jack/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define JACK_UUID_SIZE 36
+#define JACK_UUID_STRING_SIZE (JACK_UUID_SIZE+1) /* includes trailing null */
+#define JACK_UUID_EMPTY_INITIALIZER 0
+
+extern jack_uuid_t jack_client_uuid_generate (void);
+extern jack_uuid_t jack_port_uuid_generate (uint32_t port_id);
+
+extern uint32_t jack_uuid_to_index (jack_uuid_t);
+
+extern int jack_uuid_compare (jack_uuid_t, jack_uuid_t);
+extern void jack_uuid_copy (jack_uuid_t* dst, jack_uuid_t src);
+extern void jack_uuid_clear (jack_uuid_t*);
+extern int jack_uuid_parse (const char *buf, jack_uuid_t*);
+extern void jack_uuid_unparse (jack_uuid_t, char buf[JACK_UUID_STRING_SIZE]);
+extern int jack_uuid_empty (jack_uuid_t);
+
+#ifdef __cplusplus
+} /* namespace */
+#endif
+
+#endif /* __jack_uuid_h__ */
+
diff --git a/pipewire-jack/jack/weakjack.h b/pipewire-jack/jack/weakjack.h
new file mode 100644
index 0000000..c253c63
--- /dev/null
+++ b/pipewire-jack/jack/weakjack.h
@@ -0,0 +1,125 @@
+/*
+ Copyright (C) 2010 Paul Davis
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+
+#ifndef __weakjack_h__
+#define __weakjack_h__
+
+/**
+ * @defgroup WeakLinkage Managing support for newer/older versions of JACK
+ * @{ One challenge faced by developers is that of taking
+ * advantage of new features introduced in new versions
+ * of [ JACK ] while still supporting older versions of
+ * the system. Normally, if an application uses a new
+ * feature in a library/API, it is unable to run on
+ * earlier versions of the library/API that do not
+ * support that feature. Such applications would either
+ * fail to launch or crash when an attempt to use the
+ * feature was made. This problem cane be solved using
+ * weakly-linked symbols.
+ *
+ * When a symbol in a framework is defined as weakly
+ * linked, the symbol does not have to be present at
+ * runtime for a process to continue running. The static
+ * linker identifies a weakly linked symbol as such in
+ * any code module that references the symbol. The
+ * dynamic linker uses this same information at runtime
+ * to determine whether a process can continue
+ * running. If a weakly linked symbol is not present in
+ * the framework, the code module can continue to run as
+ * long as it does not reference the symbol. However, if
+ * the symbol is present, the code can use it normally.
+ *
+ * (adapted from: http://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html)
+ *
+ * A concrete example will help. Suppose that someone uses a version
+ * of a JACK client we'll call "Jill". Jill was linked against a version
+ * of JACK that contains a newer part of the API (say, jack_set_latency_callback())
+ * and would like to use it if it is available.
+ *
+ * When Jill is run on a system that has a suitably "new" version of
+ * JACK, this function will be available entirely normally. But if Jill
+ * is run on a system with an old version of JACK, the function isn't
+ * available.
+ *
+ * With normal symbol linkage, this would create a startup error whenever
+ * someone tries to run Jill with the "old" version of JACK. However, functions
+ * added to JACK after version 0.116.2 are all declared to have "weak" linkage
+ * which means that their absence doesn't cause an error during program
+ * startup. Instead, Jill can test whether or not the symbol jack_set_latency_callback
+ * is null or not. If its null, it means that the JACK installed on this machine
+ * is too old to support this function. If it's not null, then Jill can use it
+ * just like any other function in the API. For example:
+ *
+ * \code
+ * if (jack_set_latency_callback) {
+ * jack_set_latency_callback (jill_client, jill_latency_callback, arg);
+ * }
+ * \endcode
+ *
+ * However, there are clients that may want to use this approach to parts of the
+ * the JACK API that predate 0.116.2. For example, they might want to see if even
+ * really old basic parts of the API like jack_client_open() exist at runtime.
+ *
+ * Such clients should include <jack/weakjack.h> before any other JACK header.
+ * This will make the \b entire JACK API be subject to weak linkage, so that any
+ * and all functions can be checked for existence at runtime. It is important
+ * to understand that very few clients need to do this - if you use this
+ * feature you should have a clear reason to do so.
+ *
+ *
+ */
+
+#ifdef __APPLE__
+#define WEAK_ATTRIBUTE weak_import
+#else
+#define WEAK_ATTRIBUTE __weak__
+#endif
+
+#ifndef JACK_OPTIONAL_WEAK_EXPORT
+/* JACK_OPTIONAL_WEAK_EXPORT needs to be a macro which
+ expands into a compiler directive. If non-null, the directive
+ must tell the compiler to arrange for weak linkage of
+ the symbol it used with. For this to work fully may
+ require linker arguments for the client as well.
+*/
+#ifdef __GNUC__
+#define JACK_OPTIONAL_WEAK_EXPORT __attribute__((WEAK_ATTRIBUTE))
+#else
+/* Add other things here for non-gcc platforms */
+#endif
+#endif
+
+#ifndef JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT
+/* JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT needs to be a macro
+ which expands into a compiler directive. If non-null, the directive
+ must tell the compiler to arrange for weak linkage of the
+ symbol it is used with AND optionally to mark the symbol
+ as deprecated. For this to work fully may require
+ linker arguments for the client as well.
+*/
+#ifdef __GNUC__
+#define JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT __attribute__((WEAK_ATTRIBUTE,__deprecated__))
+#else
+/* Add other things here for non-gcc platforms */
+#endif
+#endif
+
+/*@}*/
+
+#endif /* weakjack */
diff --git a/pipewire-jack/jack/weakmacros.h b/pipewire-jack/jack/weakmacros.h
new file mode 100644
index 0000000..944fddb
--- /dev/null
+++ b/pipewire-jack/jack/weakmacros.h
@@ -0,0 +1,97 @@
+/*
+ Copyright (C) 2010 Paul Davis
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+
+#ifndef __weakmacros_h__
+#define __weakmacros_h__
+
+/*************************************************************
+ * NOTE: JACK_WEAK_EXPORT ***MUST*** be used on every function
+ * added to the JACK API after the 0.116.2 release.
+ *
+ * Functions that predate this release are marked with
+ * JACK_WEAK_OPTIONAL_EXPORT which can be defined at compile
+ * time in a variety of ways. The default definition is empty,
+ * so that these symbols get normal linkage. If you wish to
+ * use all JACK symbols with weak linkage, include
+ * <jack/weakjack.h> before jack.h.
+ *************************************************************/
+
+#ifdef __APPLE__
+#define WEAK_ATTRIBUTE weak_import
+#else
+#define WEAK_ATTRIBUTE __weak__
+#endif
+
+#ifndef JACK_WEAK_EXPORT
+#ifdef __GNUC__
+/* JACK_WEAK_EXPORT needs to be a macro which
+ expands into a compiler directive. If non-null, the directive
+ must tell the compiler to arrange for weak linkage of
+ the symbol it used with. For this to work full may
+ require linker arguments in the client as well.
+*/
+
+#ifdef _WIN32
+ /*
+ Not working with __declspec(dllexport) so normal linking
+ Linking with JackWeakAPI.cpp will be the preferred way.
+ */
+ #define JACK_WEAK_EXPORT
+#else
+ #define JACK_WEAK_EXPORT __attribute__((WEAK_ATTRIBUTE))
+#endif
+
+#else
+/* Add other things here for non-gcc platforms */
+
+#ifdef _WIN32
+#define JACK_WEAK_EXPORT
+#endif
+
+#endif
+#endif
+
+#ifndef JACK_WEAK_EXPORT
+#define JACK_WEAK_EXPORT
+#endif
+
+#ifndef JACK_OPTIONAL_WEAK_EXPORT
+#define JACK_OPTIONAL_WEAK_EXPORT
+#endif
+
+#ifndef JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT
+#ifdef __GNUC__
+#define JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT __attribute__((__deprecated__))
+#else
+/* Add other things here for non-gcc platforms */
+
+#ifdef _WIN32
+#define JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT
+#endif
+
+#endif /* __GNUC__ */
+
+#ifndef JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT
+#define JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT
+#endif
+
+#endif
+
+#endif /* __weakmacros_h__ */
+