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

247 lines
8.6KB

  1. /*
  2. Copyright (C) 2001 Paul Davis
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU Lesser General Public License as published by
  5. the Free Software Foundation; either version 2.1 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. $Id$
  15. */
  16. #ifndef __jack_h__
  17. #define __jack_h__
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. #include <jack/types.h>
  22. #include <jack/error.h>
  23. jack_client_t *jack_client_new (const char *client_name);
  24. int jack_client_close (jack_client_t *client);
  25. /* register a function (and argument) to be called if and when the
  26. JACK server shuts down the client thread. the function must
  27. be written as if it were an asynchonrous POSIX signal
  28. handler - use only async functions, and remember that it
  29. is executed from another thread. a typical function might
  30. set a flag or write to a pipe so that the rest of the
  31. application knows that the JACK client thread has shut
  32. down.
  33. NOTE: clients do not need to call this. it exists only
  34. to help more complex clients understand what is going
  35. on. if called, it must be called before jack_client_activate().
  36. */
  37. void jack_on_shutdown (jack_client_t *, void (*function)(void *arg), void *arg);
  38. int jack_set_process_callback (jack_client_t *, JackProcessCallback, void *arg);
  39. int jack_set_buffer_size_callback (jack_client_t *, JackBufferSizeCallback, void *arg);
  40. int jack_set_sample_rate_callback (jack_client_t *, JackSampleRateCallback, void *arg);
  41. int jack_set_port_registration_callback (jack_client_t *, JackPortRegistrationCallback, void *);
  42. int jack_set_port_monitor_callback (jack_client_t *, JackPortMonitorCallback, void *);
  43. int jack_get_process_start_fd (jack_client_t *);
  44. int jack_get_process_done_fd (jack_client_t *);
  45. int jack_activate (jack_client_t *client);
  46. int jack_deactivate (jack_client_t *client);
  47. /* this creates a new port for the client.
  48. a port is an object used for moving data in or out of the client.
  49. the data may be of any type. ports may be connected to each other
  50. in various ways.
  51. a port has a short name, which may be any non-NULL and non-zero
  52. length string, and is passed as the first argument. a port's full
  53. name is the name of the client concatenated with a colon (:) and
  54. then its short name.
  55. a port has a type, which may be any non-NULL and non-zero length
  56. string, and is passed as the second argument. for types that are
  57. not built into the jack API (currently just
  58. JACK_DEFAULT_AUDIO_TYPE) the client MUST supply a non-zero size
  59. for the buffer as the fourth argument. for builtin types, the
  60. fourth argument is ignored.
  61. a port has a set of flags, enumerated below and passed as the third
  62. argument in the form of a bitmask created by AND-ing together the
  63. desired flags. the flags "IsInput" and "IsOutput" are mutually
  64. exclusive and it is an error to use them both.
  65. */
  66. enum JackPortFlags {
  67. JackPortIsInput = 0x1,
  68. JackPortIsOutput = 0x2,
  69. JackPortIsPhysical = 0x4, /* refers to a physical connection */
  70. /* if JackPortCanMonitor is set, then a call to
  71. jack_port_request_monitor() makes sense.
  72. Precisely what this means is dependent on the client. A typical
  73. result of it being called with TRUE as the second argument is
  74. that data that would be available from an output port (with
  75. JackPortIsPhysical set) is sent to a physical output connector
  76. as well, so that it can be heard/seen/whatever.
  77. Clients that do not control physical interfaces
  78. should never create ports with this bit set.
  79. Clients that do set this bit must have provided a
  80. port_monitor callback before creating any ports with
  81. this bit set.
  82. */
  83. JackPortCanMonitor = 0x8
  84. };
  85. #define JACK_DEFAULT_AUDIO_TYPE "32 bit float mono audio"
  86. jack_port_t *
  87. jack_port_register (jack_client_t *,
  88. const char *port_name,
  89. const char *port_type,
  90. unsigned long flags,
  91. unsigned long buffer_size);
  92. /* this removes the port from the client */
  93. int jack_port_unregister (jack_client_t *, jack_port_t *);
  94. /* a port is an opaque type, and its name is not inferable */
  95. const char * jack_port_name (const jack_port_t *port);
  96. /* This returns a pointer to the memory area associated with the
  97. specified port. It can only be called from within the client's
  98. "process" callback. For an output port, it will be a memory area
  99. that can be written to; for an input port, it will be an area
  100. containing the data from the port's connection(s), or
  101. zero-filled. if there are multiple inbound connections, the data
  102. will be mixed appropriately.
  103. */
  104. void *jack_port_get_buffer (jack_port_t *, nframes_t);
  105. /* these two functions establish and disestablish a connection
  106. between two ports. when a connection exists, data written
  107. to the source port will be available to be read at the destination
  108. port.
  109. the types of both ports must be identical to establish a connection.
  110. the flags of the source port must include PortIsOutput.
  111. the flags of the destination port must include PortIsInput.
  112. */
  113. int jack_port_connect (jack_client_t *,
  114. const char *source_port,
  115. const char *destination_port);
  116. int jack_port_disconnect (jack_client_t *,
  117. const char *source_port,
  118. const char *destination_port);
  119. /* A client may call this on a pair of its own ports to
  120. semi-permanently wire them together. This means that
  121. a client that wants to direct-wire an input port to
  122. an output port can call this and then no longer
  123. have to worry about moving data between them. Any data
  124. arriving at the input port will appear automatically
  125. at the output port.
  126. The `destination' port must be an output port. The `source'
  127. port must be an input port. Both ports must belong to
  128. the same client. You cannot use this to tie ports between
  129. clients. Thats what a connection is for.
  130. */
  131. int jack_port_tie (jack_port_t *dst, jack_port_t *src);
  132. /* This undoes the effect of jack_port_tie(). The port
  133. should be same as the `destination' port passed to
  134. jack_port_tie().
  135. */
  136. int jack_port_untie (jack_port_t *port);
  137. /* a client may call this function to prevent other objects
  138. from changing the connection status of the named port.
  139. */
  140. int jack_port_lock (jack_client_t *, jack_port_t *);
  141. int jack_port_unlock (jack_client_t *, jack_port_t *);
  142. /* if JackPortCanMonitor is set for a port, then this function will
  143. turn on/off input monitoring for the port. if JackPortCanMonitor
  144. is not set, then this function will do nothing.
  145. */
  146. int jack_port_request_monitor (jack_client_t *, const char *port_name, int onoff);
  147. /* this returns the sample rate of the jack */
  148. unsigned long jack_get_sample_rate (jack_client_t *);
  149. /* this returns the current maximum size that will
  150. ever be passed to the "process" callback. it should only
  151. be used *before* the client has been activated.
  152. */
  153. nframes_t jack_get_buffer_size (jack_client_t *);
  154. /* This function returns a NULL-terminated array of ports that match the
  155. specified arguments.
  156. port_name_pattern: a regular expression used to select ports by name.
  157. if NULL or of zero length, no selection based on
  158. name will be carried out.
  159. type_name_pattern: a regular expression used to select ports by type.
  160. if NULL or of zero length, no selection based on
  161. type will be carried out.
  162. flags: a value used to select ports by their flags. if
  163. zero, no selection based on flags will be carried out.
  164. */
  165. jack_port_t **jack_get_ports (jack_client_t *,
  166. const char *port_name_pattern,
  167. const char *type_name_pattern,
  168. unsigned long flags);
  169. /* If a client is told to become the timebase for the entire system,
  170. it calls this function. If it returns zero, then the client has
  171. the responsibility to call jack_update_time() at the end
  172. of its process() callback. Whatever time it provides (in frames
  173. since its reference zero time) becomes the current timebase
  174. for the entire system.
  175. */
  176. int jack_engine_takeover_timebase (jack_client_t *);
  177. void jack_update_time (jack_client_t *, nframes_t);
  178. #ifdef __cplusplus
  179. }
  180. #endif
  181. #endif /* __jack_h__ */