diff options
Diffstat (limited to 'src/lib/nojack.h')
-rwxr-xr-x | src/lib/nojack.h | 467 |
1 files changed, 467 insertions, 0 deletions
diff --git a/src/lib/nojack.h b/src/lib/nojack.h new file mode 100755 index 0000000..6a8ab9b --- /dev/null +++ b/src/lib/nojack.h | |||
@@ -0,0 +1,467 @@ | |||
1 | /* | ||
2 | Copyright (C) 2001 Paul Davis | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU Lesser General Public License as published by | ||
6 | the Free Software Foundation; either version 2.1 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU Lesser General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Lesser General Public License | ||
15 | along with this program; if not, write to the Free Software | ||
16 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
17 | |||
18 | $Id: jack.h,v 1.64 2004/07/15 03:07:28 trutkin Exp $ | ||
19 | */ | ||
20 | |||
21 | #ifndef __jack_h__ | ||
22 | #define __jack_h__ | ||
23 | |||
24 | #include "config.h" | ||
25 | #define __int64 long long | ||
26 | #ifdef __cplusplus | ||
27 | extern "C" { | ||
28 | #endif | ||
29 | #define jack_client_t void | ||
30 | #define jack_nframes_t __uint64 | ||
31 | #define jack_position_t __uint64 | ||
32 | #define jack_default_audio_sample_t int | ||
33 | #define jack_port_t void* | ||
34 | #define JackPortIsOutput 0 | ||
35 | #define JackPortIsInput 0 | ||
36 | typedef int(*JackProcessCallback)(__uint64, int,void*); | ||
37 | #define JackThreadInitCallback void* | ||
38 | #define JackPortRegistrationCallback void* | ||
39 | #define JackGraphOrderCallback void* | ||
40 | #define JackXRunCallback void* | ||
41 | #define JackFreewheelCallback void* | ||
42 | #define JackBufferSizeCallback void* | ||
43 | #define JackSampleRateCallback void* | ||
44 | #define jack_port_id_t void* | ||
45 | #define jack_transport_state_t int | ||
46 | #define JackTransportStopped 0 | ||
47 | #define pthread_t void* | ||
48 | jack_client_t *jack_client_new (const char *client_name); | ||
49 | int jack_client_close (jack_client_t *client); | ||
50 | int jack_client_name_size(void); | ||
51 | int jack_internal_client_new (const char *client_name, const char *so_name, | ||
52 | const char *so_data); | ||
53 | void jack_internal_client_close (const char *client_name); | ||
54 | int jack_is_realtime (jack_client_t *client); | ||
55 | void jack_on_shutdown (jack_client_t *client, void (*function)(void *arg), void *arg) ; | ||
56 | int jack_set_process_callback (jack_client_t *client, | ||
57 | JackProcessCallback process_callback, | ||
58 | void *arg) ; | ||
59 | int jack_set_thread_init_callback (jack_client_t *client, | ||
60 | JackThreadInitCallback thread_init_callback, | ||
61 | void *arg) ; | ||
62 | int jack_set_freewheel_callback (jack_client_t *client, | ||
63 | JackFreewheelCallback freewheel_callback, | ||
64 | void *arg) ; | ||
65 | int jack_set_freewheel(jack_client_t* client, int onoff) ; | ||
66 | |||
67 | int jack_set_buffer_size (jack_client_t *client, jack_nframes_t nframes) ; | ||
68 | int jack_set_buffer_size_callback (jack_client_t *client, | ||
69 | JackBufferSizeCallback bufsize_callback, | ||
70 | void *arg); | ||
71 | int jack_set_sample_rate_callback (jack_client_t *client, | ||
72 | JackSampleRateCallback srate_callback, | ||
73 | void *arg); | ||
74 | int jack_transport_query(jack_client_t *x,__uint64* y); | ||
75 | int jack_set_port_registration_callback (jack_client_t *, | ||
76 | JackPortRegistrationCallback | ||
77 | registration_callback, void *arg) ; | ||
78 | int jack_set_graph_order_callback (jack_client_t *, JackGraphOrderCallback graph_callback, void *) ; | ||
79 | |||
80 | int jack_set_xrun_callback (jack_client_t *, JackXRunCallback xrun_callback, void *arg) ; | ||
81 | int jack_activate (jack_client_t *client) ; | ||
82 | int jack_deactivate (jack_client_t *client) ; | ||
83 | jack_port_t *jack_port_register (jack_client_t *client, | ||
84 | const char *port_name, | ||
85 | const char *port_type, | ||
86 | unsigned long flags, | ||
87 | unsigned long buffer_size) ; | ||
88 | int jack_port_unregister (jack_client_t *, jack_port_t *) ; | ||
89 | void *jack_port_get_buffer (jack_port_t *, jack_nframes_t) ; | ||
90 | const char *jack_port_name (const jack_port_t *port) ; | ||
91 | const char *jack_port_short_name (const jack_port_t *port) ; | ||
92 | int jack_port_flags (const jack_port_t *port) ; | ||
93 | const char *jack_port_type (const jack_port_t *port) ; | ||
94 | |||
95 | int jack_port_is_mine (const jack_client_t *, const jack_port_t *port) ; | ||
96 | |||
97 | /** | ||
98 | * @return number of connections to or from @a port. | ||
99 | * | ||
100 | * @pre The calling client must own @a port. | ||
101 | */ | ||
102 | int jack_port_connected (const jack_port_t *port); | ||
103 | |||
104 | /** | ||
105 | * @return TRUE if the locally-owned @a port is @b directly connected | ||
106 | * to the @a port_name. | ||
107 | * | ||
108 | * @see jack_port_name_size() | ||
109 | */ | ||
110 | int jack_port_connected_to (const jack_port_t *port, | ||
111 | const char *port_name); | ||
112 | |||
113 | /** | ||
114 | * @return a null-terminated array of full port names to which the @a | ||
115 | * port is connected. If none, returns NULL. | ||
116 | * | ||
117 | * The caller is responsible for calling free(3) on any non-NULL | ||
118 | * returned value. | ||
119 | * | ||
120 | * @param port locally owned jack_port_t pointer. | ||
121 | * | ||
122 | * @see jack_port_name_size(), jack_port_get_all_connections() | ||
123 | */ | ||
124 | const char **jack_port_get_connections (const jack_port_t *port); | ||
125 | |||
126 | /** | ||
127 | * @return a null-terminated array of full port names to which the @a | ||
128 | * port is connected. If none, returns NULL. | ||
129 | * | ||
130 | * The caller is responsible for calling free(3) on any non-NULL | ||
131 | * returned value. | ||
132 | * | ||
133 | * This differs from jack_port_get_connections() in two important | ||
134 | * respects: | ||
135 | * | ||
136 | * 1) You may not call this function from code that is | ||
137 | * executed in response to a JACK event. For example, | ||
138 | * you cannot use it in a GraphReordered handler. | ||
139 | * | ||
140 | * 2) You need not be the owner of the port to get information | ||
141 | * about its connections. | ||
142 | * | ||
143 | * @see jack_port_name_size() | ||
144 | */ | ||
145 | const char **jack_port_get_all_connections (const jack_client_t *client, | ||
146 | const jack_port_t *port); | ||
147 | |||
148 | /** | ||
149 | * A client may call this on a pair of its own ports to | ||
150 | * semi-permanently wire them together. This means that | ||
151 | * a client that wants to direct-wire an input port to | ||
152 | * an output port can call this and then no longer | ||
153 | * have to worry about moving data between them. Any data | ||
154 | * arriving at the input port will appear automatically | ||
155 | * at the output port. | ||
156 | * | ||
157 | * The 'destination' port must be an output port. The 'source' | ||
158 | * port must be an input port. Both ports must belong to | ||
159 | * the same client. You cannot use this to tie ports between | ||
160 | * clients. That is what a connection is for. | ||
161 | * | ||
162 | * @return 0 on success, otherwise a non-zero error code | ||
163 | */ | ||
164 | int jack_port_tie (jack_port_t *src, jack_port_t *dst); | ||
165 | |||
166 | /** | ||
167 | * This undoes the effect of jack_port_tie(). The port | ||
168 | * should be same as the 'destination' port passed to | ||
169 | * jack_port_tie(). | ||
170 | * | ||
171 | * @return 0 on success, otherwise a non-zero error code | ||
172 | */ | ||
173 | int jack_port_untie (jack_port_t *port); | ||
174 | |||
175 | /** | ||
176 | * A client may call this function to prevent other objects | ||
177 | * from changing the connection status of a port. The port | ||
178 | * must be owned by the calling client. | ||
179 | * | ||
180 | * @return 0 on success, otherwise a non-zero error code | ||
181 | */ | ||
182 | int jack_port_lock (jack_client_t *, jack_port_t *); | ||
183 | |||
184 | /** | ||
185 | * This allows other objects to change the connection status of a port. | ||
186 | * | ||
187 | * @return 0 on success, otherwise a non-zero error code | ||
188 | */ | ||
189 | int jack_port_unlock (jack_client_t *, jack_port_t *); | ||
190 | |||
191 | /** | ||
192 | * @return the time (in frames) between data being available or | ||
193 | * delivered at/to a port, and the time at which it arrived at or is | ||
194 | * delivered to the "other side" of the port. E.g. for a physical | ||
195 | * audio output port, this is the time between writing to the port and | ||
196 | * when the signal will leave the connector. For a physical audio | ||
197 | * input port, this is the time between the sound arriving at the | ||
198 | * connector and the corresponding frames being readable from the | ||
199 | * port. | ||
200 | */ | ||
201 | jack_nframes_t jack_port_get_latency (jack_port_t *port); | ||
202 | |||
203 | /** | ||
204 | * The maximum of the sum of the latencies in every | ||
205 | * connection path that can be drawn between the port and other | ||
206 | * ports with the @ref JackPortIsTerminal flag set. | ||
207 | */ | ||
208 | jack_nframes_t jack_port_get_total_latency (jack_client_t *, | ||
209 | jack_port_t *port); | ||
210 | |||
211 | /** | ||
212 | * The port latency is zero by default. Clients that control | ||
213 | * physical hardware with non-zero latency should call this | ||
214 | * to set the latency to its correct value. Note that the value | ||
215 | * should include any systemic latency present "outside" the | ||
216 | * physical hardware controlled by the client. For example, | ||
217 | * for a client controlling a digital audio interface connected | ||
218 | * to an external digital converter, the latency setting should | ||
219 | * include both buffering by the audio interface *and* the converter. | ||
220 | */ | ||
221 | void jack_port_set_latency (jack_port_t *, jack_nframes_t); | ||
222 | |||
223 | /** | ||
224 | * Modify a port's short name. May be called at any time. If the | ||
225 | * resulting full name (including the @a "client_name:" prefix) is | ||
226 | * longer than jack_port_name_size(), it will be truncated. | ||
227 | * | ||
228 | * @return 0 on success, otherwise a non-zero error code. | ||
229 | */ | ||
230 | int jack_port_set_name (jack_port_t *port, const char *port_name); | ||
231 | |||
232 | /** | ||
233 | * If @ref JackPortCanMonitor is set for this @a port, turn input | ||
234 | * monitoring on or off. Otherwise, do nothing. | ||
235 | */ | ||
236 | int jack_port_request_monitor (jack_port_t *port, int onoff); | ||
237 | |||
238 | /** | ||
239 | * If @ref JackPortCanMonitor is set for this @a port_name, turn input | ||
240 | * monitoring on or off. Otherwise, do nothing. | ||
241 | * | ||
242 | * @return 0 on success, otherwise a non-zero error code. | ||
243 | * | ||
244 | * @see jack_port_name_size() | ||
245 | */ | ||
246 | int jack_port_request_monitor_by_name (jack_client_t *client, | ||
247 | const char *port_name, int onoff); | ||
248 | |||
249 | /** | ||
250 | * If @ref JackPortCanMonitor is set for a port, this function turns | ||
251 | * on input monitoring if it was off, and turns it off if only one | ||
252 | * request has been made to turn it on. Otherwise it does nothing. | ||
253 | * | ||
254 | * @return 0 on success, otherwise a non-zero error code | ||
255 | */ | ||
256 | int jack_port_ensure_monitor (jack_port_t *port, int onoff); | ||
257 | |||
258 | /** | ||
259 | * @return TRUE if input monitoring has been requested for @a port. | ||
260 | */ | ||
261 | int jack_port_monitoring_input (jack_port_t *port); | ||
262 | |||
263 | /** | ||
264 | * Establish a connection between two ports. | ||
265 | * | ||
266 | * When a connection exists, data written to the source port will | ||
267 | * be available to be read at the destination port. | ||
268 | * | ||
269 | * @pre The port types must be identical. | ||
270 | * | ||
271 | * @pre The @ref JackPortFlags of the @a source_port must include @ref | ||
272 | * JackPortIsOutput. | ||
273 | * | ||
274 | * @pre The @ref JackPortFlags of the @a destination_port must include | ||
275 | * @ref JackPortIsInput. | ||
276 | * | ||
277 | * @return 0 on success, EEXIST if the connection is already made, | ||
278 | * otherwise a non-zero error code | ||
279 | */ | ||
280 | int jack_connect (jack_client_t *, | ||
281 | const char *source_port, | ||
282 | const char *destination_port); | ||
283 | |||
284 | /** | ||
285 | * Remove a connection between two ports. | ||
286 | * | ||
287 | * @pre The port types must be identical. | ||
288 | * | ||
289 | * @pre The @ref JackPortFlags of the @a source_port must include @ref | ||
290 | * JackPortIsOutput. | ||
291 | * | ||
292 | * @pre The @ref JackPortFlags of the @a destination_port must include | ||
293 | * @ref JackPortIsInput. | ||
294 | * | ||
295 | * @return 0 on success, otherwise a non-zero error code | ||
296 | */ | ||
297 | int jack_disconnect (jack_client_t *, | ||
298 | const char *source_port, | ||
299 | const char *destination_port); | ||
300 | |||
301 | /** | ||
302 | * Perform the same function as jack_disconnect() using port handles | ||
303 | * rather than names. This avoids the name lookup inherent in the | ||
304 | * name-based version. | ||
305 | * | ||
306 | * Clients connecting their own ports are likely to use this function, | ||
307 | * while generic connection clients (e.g. patchbays) would use | ||
308 | * jack_disconnect(). | ||
309 | */ | ||
310 | int jack_port_disconnect (jack_client_t *, jack_port_t *); | ||
311 | |||
312 | /** | ||
313 | * @return the maximum number of characters in a full JACK port name | ||
314 | * including the final NULL character. This value is a constant. | ||
315 | * | ||
316 | * A port's full name contains the owning client name concatenated | ||
317 | * with a colon (:) followed by its short name and a NULL | ||
318 | * character. | ||
319 | */ | ||
320 | int jack_port_name_size(void); | ||
321 | |||
322 | /** | ||
323 | * @return the maximum number of characters in a JACK port type name | ||
324 | * including the final NULL character. This value is a constant. | ||
325 | */ | ||
326 | int jack_port_type_size(void); | ||
327 | |||
328 | /** | ||
329 | * @return the sample rate of the jack system, as set by the user when | ||
330 | * jackd was started. | ||
331 | */ | ||
332 | jack_nframes_t jack_get_sample_rate (jack_client_t *); | ||
333 | |||
334 | /** | ||
335 | * @return the current maximum size that will ever be passed to the @a | ||
336 | * process_callback. It should only be used *before* the client has | ||
337 | * been activated. This size may change, clients that depend on it | ||
338 | * must register a @a bufsize_callback so they will be notified if it | ||
339 | * does. | ||
340 | * | ||
341 | * @see jack_set_buffer_size_callback() | ||
342 | */ | ||
343 | jack_nframes_t jack_get_buffer_size (jack_client_t *); | ||
344 | |||
345 | /** | ||
346 | * @param port_name_pattern A regular expression used to select | ||
347 | * ports by name. If NULL or of zero length, no selection based | ||
348 | * on name will be carried out. | ||
349 | * @param type_name_pattern A regular expression used to select | ||
350 | * ports by type. If NULL or of zero length, no selection based | ||
351 | * on type will be carried out. | ||
352 | * @param flags A value used to select ports by their flags. | ||
353 | * If zero, no selection based on flags will be carried out. | ||
354 | * | ||
355 | * @return a NULL-terminated array of ports that match the specified | ||
356 | * arguments. The caller is responsible for calling free(3) any | ||
357 | * non-NULL returned value. | ||
358 | * | ||
359 | * @see jack_port_name_size(), jack_port_type_size() | ||
360 | */ | ||
361 | const char **jack_get_ports (jack_client_t *, | ||
362 | const char *port_name_pattern, | ||
363 | const char *type_name_pattern, | ||
364 | unsigned long flags); | ||
365 | |||
366 | /** | ||
367 | * @return address of the jack_port_t named @a port_name. | ||
368 | * | ||
369 | * @see jack_port_name_size() | ||
370 | */ | ||
371 | jack_port_t *jack_port_by_name (jack_client_t *, const char *port_name); | ||
372 | |||
373 | /** | ||
374 | * @return address of the jack_port_t of a @a port_id. | ||
375 | */ | ||
376 | jack_port_t *jack_port_by_id (const jack_client_t *client, | ||
377 | jack_port_id_t port_id); | ||
378 | |||
379 | /** | ||
380 | * Old-style interface to become the timebase for the entire JACK | ||
381 | * subsystem. | ||
382 | * | ||
383 | * @deprecated This function still exists for compatibility with the | ||
384 | * earlier transport interface, but it does nothing. Instead, see | ||
385 | * transport.h and use jack_set_timebase_callback(). | ||
386 | * | ||
387 | * @return ENOSYS, function not implemented. | ||
388 | */ | ||
389 | int jack_engine_takeover_timebase (jack_client_t *); | ||
390 | |||
391 | /** | ||
392 | * @return the time in frames that has passed since the JACK server | ||
393 | * began the current process cycle. | ||
394 | */ | ||
395 | jack_nframes_t jack_frames_since_cycle_start (const jack_client_t *); | ||
396 | |||
397 | /** | ||
398 | * @return an estimate of the current time in frames. This is a | ||
399 | * running counter, no significance should be attached to its value, | ||
400 | * but it can be compared to a previously returned value. | ||
401 | */ | ||
402 | jack_nframes_t jack_frame_time (const jack_client_t *); | ||
403 | |||
404 | /** | ||
405 | * @return the frame_time after the last processing of the graph | ||
406 | * this is only to be used from the process callback. | ||
407 | * | ||
408 | * This function can be used to put timestamps generated by | ||
409 | * jack_frame_time() in correlation to the current process cycle. | ||
410 | */ | ||
411 | jack_nframes_t jack_last_frame_time (const jack_client_t *client); | ||
412 | |||
413 | |||
414 | /** | ||
415 | * @return the current CPU load estimated by JACK. This is a running | ||
416 | * average of the time it takes to execute a full process cycle for | ||
417 | * all clients as a percentage of the real time available per cycle | ||
418 | * determined by the buffer size and sample rate. | ||
419 | */ | ||
420 | float jack_cpu_load (jack_client_t *client); | ||
421 | |||
422 | /** | ||
423 | * Set the directory in which the server is expected | ||
424 | * to have put its communication FIFOs. A client | ||
425 | * will need to call this before calling | ||
426 | * jack_client_new() if the server was started | ||
427 | * with arguments telling it to use a non-standard | ||
428 | * directory. | ||
429 | * | ||
430 | * @deprecated This function is deprecated. Don't use in new programs | ||
431 | * and remove it in old programs. | ||
432 | */ | ||
433 | void jack_set_server_dir (const char *path); | ||
434 | |||
435 | /** | ||
436 | * @return the pthread ID of the thread running the JACK client side | ||
437 | * code. | ||
438 | */ | ||
439 | pthread_t jack_client_thread_id (jack_client_t *); | ||
440 | |||
441 | /** | ||
442 | * Display JACK error message. | ||
443 | * | ||
444 | * Set via jack_set_error_function(), otherwise a JACK-provided | ||
445 | * default will print @a msg (plus a newline) to stderr. | ||
446 | * | ||
447 | * @param msg error message text (no newline at end). | ||
448 | */ | ||
449 | extern void (*jack_error_callback)(const char *msg); | ||
450 | |||
451 | /** | ||
452 | * Set the @ref jack_error_callback for error message display. | ||
453 | * | ||
454 | * The JACK library provides two built-in callbacks for this purpose: | ||
455 | * default_jack_error_callback() and silent_jack_error_callback(). | ||
456 | */ | ||
457 | void jack_set_error_function (void (*func)(const char *)); | ||
458 | __uint64 jack_get_current_transport_frame(void* client) ; | ||
459 | void jack_transport_stop (void * dummy) ; | ||
460 | void jack_transport_start (void * dummy) ; | ||
461 | void jack_transport_locate (void * dummy,int x) ; | ||
462 | #define JACK_DEFAULT_AUDIO_TYPE 0 | ||
463 | #ifdef __cplusplus | ||
464 | } | ||
465 | #endif | ||
466 | |||
467 | #endif /* __jack_h__ */ | ||