2 Copyright (C) 2001-2003 Paul Davis
3 Copyright (C) 2004-2008 Grame
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 #include "JackClient.h"
22 #include "JackError.h"
23 #include "JackGraphManager.h"
24 #include "JackEngineControl.h"
25 #include "JackClientControl.h"
26 #include "JackGlobals.h"
28 #include "JackCompilerDeps.h"
29 #include "JackPortType.h"
30 #include "JackPlatformPlug.h"
33 #ifdef __CLIENTDEBUG__
34 #include "JackLibGlobals.h"
44 typedef void (*print_function
)(const char *);
45 typedef void *(*thread_routine
)(void*);
57 jack_get_version_string();
59 EXPORT jack_client_t
* jack_client_open_aux (const char *client_name
,
60 jack_options_t options
,
61 jack_status_t
*status
, va_list ap
);
62 EXPORT jack_client_t
* jack_client_open (const char *client_name
,
63 jack_options_t options
,
64 jack_status_t
*status
, ...);
65 EXPORT jack_client_t
* jack_client_new (const char *client_name
);
66 EXPORT
int jack_client_name_size (void);
67 EXPORT
char* jack_get_client_name (jack_client_t
*client
);
68 EXPORT
int jack_internal_client_new (const char *client_name
,
69 const char *load_name
,
70 const char *load_init
);
71 EXPORT
void jack_internal_client_close (const char *client_name
);
72 EXPORT
int jack_is_realtime (jack_client_t
*client
);
73 EXPORT
void jack_on_shutdown (jack_client_t
*client
,
74 JackShutdownCallback shutdown_callback
, void *arg
);
75 EXPORT
void jack_on_info_shutdown (jack_client_t
*client
,
76 JackInfoShutdownCallback shutdown_callback
, void *arg
);
77 EXPORT
int jack_set_process_callback (jack_client_t
*client
,
78 JackProcessCallback process_callback
,
80 EXPORT jack_nframes_t
jack_thread_wait(jack_client_t
*client
, int status
);
83 EXPORT jack_nframes_t
jack_cycle_wait (jack_client_t
*);
84 EXPORT
void jack_cycle_signal (jack_client_t
*, int status
);
85 EXPORT
int jack_set_process_thread(jack_client_t
* client
, JackThreadCallback fun
, void *arg
);
87 EXPORT
int jack_set_thread_init_callback (jack_client_t
*client
,
88 JackThreadInitCallback thread_init_callback
,
90 EXPORT
int jack_set_freewheel_callback (jack_client_t
*client
,
91 JackFreewheelCallback freewheel_callback
,
93 EXPORT
int jack_set_freewheel(jack_client_t
* client
, int onoff
);
94 EXPORT
int jack_set_buffer_size (jack_client_t
*client
, jack_nframes_t nframes
);
95 EXPORT
int jack_set_buffer_size_callback (jack_client_t
*client
,
96 JackBufferSizeCallback bufsize_callback
,
98 EXPORT
int jack_set_sample_rate_callback (jack_client_t
*client
,
99 JackSampleRateCallback srate_callback
,
101 EXPORT
int jack_set_client_registration_callback (jack_client_t
*,
102 JackClientRegistrationCallback
103 registration_callback
, void *arg
);
104 EXPORT
int jack_set_port_registration_callback (jack_client_t
*,
105 JackPortRegistrationCallback
106 registration_callback
, void *arg
);
107 EXPORT
int jack_set_port_connect_callback (jack_client_t
*,
108 JackPortConnectCallback
109 connect_callback
, void *arg
);
110 EXPORT
int jack_set_port_rename_callback (jack_client_t
*,
111 JackPortRenameCallback
112 rename_callback
, void *arg
);
113 EXPORT
int jack_set_graph_order_callback (jack_client_t
*,
114 JackGraphOrderCallback graph_callback
,
116 EXPORT
int jack_set_xrun_callback (jack_client_t
*,
117 JackXRunCallback xrun_callback
, void *arg
);
118 EXPORT
int jack_activate (jack_client_t
*client
);
119 EXPORT
int jack_deactivate (jack_client_t
*client
);
120 EXPORT jack_port_t
* jack_port_register (jack_client_t
*client
,
121 const char *port_name
,
122 const char *port_type
,
124 unsigned long buffer_size
);
125 EXPORT
int jack_port_unregister (jack_client_t
*, jack_port_t
*);
126 EXPORT
void * jack_port_get_buffer (jack_port_t
*, jack_nframes_t
);
127 EXPORT
const char * jack_port_name (const jack_port_t
*port
);
128 EXPORT
const char * jack_port_short_name (const jack_port_t
*port
);
129 EXPORT
int jack_port_flags (const jack_port_t
*port
);
130 EXPORT
const char * jack_port_type (const jack_port_t
*port
);
131 EXPORT jack_port_type_id_t
jack_port_type_id (const jack_port_t
*port
);
132 EXPORT
int jack_port_is_mine (const jack_client_t
*, const jack_port_t
*port
);
133 EXPORT
int jack_port_connected (const jack_port_t
*port
);
134 EXPORT
int jack_port_connected_to (const jack_port_t
*port
,
135 const char *port_name
);
136 EXPORT
const char ** jack_port_get_connections (const jack_port_t
*port
);
137 EXPORT
const char ** jack_port_get_all_connections (const jack_client_t
*client
,
138 const jack_port_t
*port
);
139 EXPORT
int jack_port_tie (jack_port_t
*src
, jack_port_t
*dst
);
140 EXPORT
int jack_port_untie (jack_port_t
*port
);
141 EXPORT jack_nframes_t
jack_port_get_latency (jack_port_t
*port
);
142 EXPORT jack_nframes_t
jack_port_get_total_latency (jack_client_t
*,
144 EXPORT
void jack_port_set_latency (jack_port_t
*, jack_nframes_t
);
145 EXPORT
int jack_recompute_total_latency (jack_client_t
*, jack_port_t
* port
);
146 EXPORT
int jack_recompute_total_latencies (jack_client_t
*);
147 EXPORT
int jack_port_set_name (jack_port_t
*port
, const char *port_name
);
148 EXPORT
int jack_port_set_alias (jack_port_t
*port
, const char *alias
);
149 EXPORT
int jack_port_unset_alias (jack_port_t
*port
, const char *alias
);
150 EXPORT
int jack_port_get_aliases (const jack_port_t
*port
, char* const aliases
[2]);
151 EXPORT
int jack_port_request_monitor (jack_port_t
*port
, int onoff
);
152 EXPORT
int jack_port_request_monitor_by_name (jack_client_t
*client
,
153 const char *port_name
, int onoff
);
154 EXPORT
int jack_port_ensure_monitor (jack_port_t
*port
, int onoff
);
155 EXPORT
int jack_port_monitoring_input (jack_port_t
*port
);
156 EXPORT
int jack_connect (jack_client_t
*,
157 const char *source_port
,
158 const char *destination_port
);
159 EXPORT
int jack_disconnect (jack_client_t
*,
160 const char *source_port
,
161 const char *destination_port
);
162 EXPORT
int jack_port_disconnect (jack_client_t
*, jack_port_t
*);
163 EXPORT
int jack_port_name_size(void);
164 EXPORT
int jack_port_type_size(void);
165 EXPORT jack_nframes_t
jack_get_sample_rate (jack_client_t
*);
166 EXPORT jack_nframes_t
jack_get_buffer_size (jack_client_t
*);
167 EXPORT
const char ** jack_get_ports (jack_client_t
*,
168 const char *port_name_pattern
,
169 const char *type_name_pattern
,
170 unsigned long flags
);
171 EXPORT jack_port_t
* jack_port_by_name (jack_client_t
*, const char *port_name
);
172 EXPORT jack_port_t
* jack_port_by_id (jack_client_t
*client
,
173 jack_port_id_t port_id
);
174 EXPORT
int jack_engine_takeover_timebase (jack_client_t
*);
175 EXPORT jack_nframes_t
jack_frames_since_cycle_start (const jack_client_t
*);
176 EXPORT jack_time_t
jack_get_time();
177 EXPORT jack_nframes_t
jack_time_to_frames(const jack_client_t
*client
, jack_time_t time
);
178 EXPORT jack_time_t
jack_frames_to_time(const jack_client_t
*client
, jack_nframes_t frames
);
179 EXPORT jack_nframes_t
jack_frame_time (const jack_client_t
*);
180 EXPORT jack_nframes_t
jack_last_frame_time (const jack_client_t
*client
);
181 EXPORT
float jack_cpu_load (jack_client_t
*client
);
182 EXPORT pthread_t
jack_client_thread_id (jack_client_t
*);
183 EXPORT
void jack_set_error_function (print_function
);
184 EXPORT
void jack_set_info_function (print_function
);
186 EXPORT
float jack_get_max_delayed_usecs (jack_client_t
*client
);
187 EXPORT
float jack_get_xrun_delayed_usecs (jack_client_t
*client
);
188 EXPORT
void jack_reset_max_delayed_usecs (jack_client_t
*client
);
190 EXPORT
int jack_release_timebase (jack_client_t
*client
);
191 EXPORT
int jack_set_sync_callback (jack_client_t
*client
,
192 JackSyncCallback sync_callback
,
194 EXPORT
int jack_set_sync_timeout (jack_client_t
*client
,
195 jack_time_t timeout
);
196 EXPORT
int jack_set_timebase_callback (jack_client_t
*client
,
198 JackTimebaseCallback timebase_callback
,
200 EXPORT
int jack_transport_locate (jack_client_t
*client
,
201 jack_nframes_t frame
);
202 EXPORT jack_transport_state_t
jack_transport_query (const jack_client_t
*client
,
203 jack_position_t
*pos
);
204 EXPORT jack_nframes_t
jack_get_current_transport_frame (const jack_client_t
*client
);
205 EXPORT
int jack_transport_reposition (jack_client_t
*client
,
206 jack_position_t
*pos
);
207 EXPORT
void jack_transport_start (jack_client_t
*client
);
208 EXPORT
void jack_transport_stop (jack_client_t
*client
);
209 EXPORT
void jack_get_transport_info (jack_client_t
*client
,
210 jack_transport_info_t
*tinfo
);
211 EXPORT
void jack_set_transport_info (jack_client_t
*client
,
212 jack_transport_info_t
*tinfo
);
214 EXPORT
int jack_client_real_time_priority (jack_client_t
*);
215 EXPORT
int jack_client_max_real_time_priority (jack_client_t
*);
216 EXPORT
int jack_acquire_real_time_scheduling (pthread_t thread
, int priority
);
217 EXPORT
int jack_client_create_thread (jack_client_t
* client
,
220 int realtime
, // boolean
221 thread_routine routine
,
223 EXPORT
int jack_drop_real_time_scheduling (pthread_t thread
);
225 EXPORT
int jack_client_stop_thread (jack_client_t
* client
, pthread_t thread
);
226 EXPORT
int jack_client_kill_thread (jack_client_t
* client
, pthread_t thread
);
228 EXPORT
void jack_set_thread_creator (jack_thread_creator_t jtc
);
230 EXPORT
char * jack_get_internal_client_name (jack_client_t
*client
,
231 jack_intclient_t intclient
);
232 EXPORT jack_intclient_t
jack_internal_client_handle (jack_client_t
*client
,
233 const char *client_name
,
234 jack_status_t
*status
);
235 EXPORT jack_intclient_t
jack_internal_client_load (jack_client_t
*client
,
236 const char *client_name
,
237 jack_options_t options
,
238 jack_status_t
*status
, ...);
239 EXPORT jack_intclient_t
jack_internal_client_load_aux (jack_client_t
*client
,
240 const char *client_name
,
241 jack_options_t options
,
242 jack_status_t
*status
, va_list ap
);
244 EXPORT jack_status_t
jack_internal_client_unload (jack_client_t
*client
,
245 jack_intclient_t intclient
);
246 EXPORT
void jack_free(void* ptr
);
252 static inline bool CheckPort(jack_port_id_t port_index
)
254 return (port_index
> 0 && port_index
< PORT_NUM
);
257 static inline bool CheckBufferSize(jack_nframes_t buffer_size
)
259 return (buffer_size
<= BUFFER_SIZE_MAX
);
262 static inline void WaitGraphChange()
265 TLS key that is set only in RT thread, so never waits for pending
266 graph change in RT context (just read the current graph state).
269 if (jack_tls_get(JackGlobals::fRealTime
) == NULL
) {
270 JackGraphManager
* manager
= GetGraphManager();
271 JackEngineControl
* control
= GetEngineControl();
274 if (manager
->IsPendingChange()) {
275 jack_log("WaitGraphChange...");
276 JackSleep(int(control
->fPeriodUsecs
* 1.1f
));
281 EXPORT
void jack_set_error_function (print_function func
)
283 jack_error_callback
= (func
== NULL
) ? &default_jack_error_callback
: func
;
286 EXPORT
void jack_set_info_function (print_function func
)
288 jack_info_callback
= (func
== NULL
) ? &default_jack_info_callback
: func
;
291 EXPORT jack_client_t
* jack_client_new(const char* client_name
)
293 assert(JackGlobals::fOpenMutex
);
294 JackGlobals::fOpenMutex
->Lock();
295 jack_error("jack_client_new: deprecated");
296 int options
= JackUseExactName
;
297 if (getenv("JACK_START_SERVER") == NULL
)
298 options
|= JackNoStartServer
;
299 jack_client_t
* res
= jack_client_open_aux(client_name
, (jack_options_t
)options
, NULL
, NULL
);
300 JackGlobals::fOpenMutex
->Unlock();
304 EXPORT
void* jack_port_get_buffer(jack_port_t
* port
, jack_nframes_t frames
)
306 #ifdef __CLIENTDEBUG__
307 JackLibGlobals::CheckContext();
309 #if defined(__x86_64__) || defined(__ppc64__)
310 uint64_t port_aux
= (uint64_t)port
;
312 uint32_t port_aux
= (uint32_t)port
;
314 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
315 if (!CheckPort(myport
)) {
316 jack_error("jack_port_get_buffer called with an incorrect port %ld", myport
);
319 JackGraphManager
* manager
= GetGraphManager();
320 return (manager
? manager
->GetBuffer(myport
, frames
) : NULL
);
324 EXPORT
const char* jack_port_name(const jack_port_t
* port
)
326 #ifdef __CLIENTDEBUG__
327 JackLibGlobals::CheckContext();
329 #if defined(__x86_64__) || defined(__ppc64__)
330 uint64_t port_aux
= (uint64_t)port
;
332 uint32_t port_aux
= (uint32_t)port
;
334 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
335 if (!CheckPort(myport
)) {
336 jack_error("jack_port_name called with an incorrect port %ld", myport
);
339 JackGraphManager
* manager
= GetGraphManager();
340 return (manager
? manager
->GetPort(myport
)->GetName() : NULL
);
344 EXPORT
const char* jack_port_short_name(const jack_port_t
* port
)
346 #ifdef __CLIENTDEBUG__
347 JackLibGlobals::CheckContext();
349 #if defined(__x86_64__) || defined(__ppc64__)
350 uint64_t port_aux
= (uint64_t)port
;
352 uint32_t port_aux
= (uint32_t)port
;
354 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
355 if (!CheckPort(myport
)) {
356 jack_error("jack_port_short_name called with an incorrect port %ld", myport
);
359 JackGraphManager
* manager
= GetGraphManager();
360 return (manager
? manager
->GetPort(myport
)->GetShortName() : NULL
);
364 EXPORT
int jack_port_flags(const jack_port_t
* port
)
366 #ifdef __CLIENTDEBUG__
367 JackLibGlobals::CheckContext();
369 #if defined(__x86_64__) || defined(__ppc64__)
370 uint64_t port_aux
= (uint64_t)port
;
372 uint32_t port_aux
= (uint32_t)port
;
374 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
375 if (!CheckPort(myport
)) {
376 jack_error("jack_port_flags called with an incorrect port %ld", myport
);
379 JackGraphManager
* manager
= GetGraphManager();
380 return (manager
? manager
->GetPort(myport
)->GetFlags() : -1);
384 EXPORT
const char* jack_port_type(const jack_port_t
* port
)
386 #ifdef __CLIENTDEBUG__
387 JackLibGlobals::CheckContext();
389 #if defined(__x86_64__) || defined(__ppc64__)
390 uint64_t port_aux
= (uint64_t)port
;
392 uint32_t port_aux
= (uint32_t)port
;
394 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
395 if (!CheckPort(myport
)) {
396 jack_error("jack_port_flags called an incorrect port %ld", myport
);
399 JackGraphManager
* manager
= GetGraphManager();
400 return (manager
? manager
->GetPort(myport
)->GetType() : NULL
);
404 EXPORT jack_port_type_id_t
jack_port_type_id(const jack_port_t
*port
)
406 #ifdef __CLIENTDEBUG__
407 JackLibGlobals::CheckContext();
409 #if defined(__x86_64__) || defined(__ppc64__)
410 uint64_t port_aux
= (uint64_t)port
;
412 uint32_t port_aux
= (uint32_t)port
;
414 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
415 if (!CheckPort(myport
)) {
416 jack_error("jack_port_type_id called an incorrect port %ld", myport
);
419 JackGraphManager
* manager
= GetGraphManager();
420 return (manager
? GetPortTypeId(manager
->GetPort(myport
)->GetType()) : 0);
424 EXPORT
int jack_port_connected(const jack_port_t
* port
)
426 #ifdef __CLIENTDEBUG__
427 JackLibGlobals::CheckContext();
429 #if defined(__x86_64__) || defined(__ppc64__)
430 uint64_t port_aux
= (uint64_t)port
;
432 uint32_t port_aux
= (uint32_t)port
;
434 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
435 if (!CheckPort(myport
)) {
436 jack_error("jack_port_connected called with an incorrect port %ld", myport
);
440 JackGraphManager
* manager
= GetGraphManager();
441 return (manager
? manager
->GetConnectionsNum(myport
) : -1);
445 EXPORT
int jack_port_connected_to(const jack_port_t
* port
, const char* port_name
)
447 #ifdef __CLIENTDEBUG__
448 JackLibGlobals::CheckContext();
450 #if defined(__x86_64__) || defined(__ppc64__)
451 uint64_t port_aux
= (uint64_t)port
;
453 uint32_t port_aux
= (uint32_t)port
;
455 jack_port_id_t src
= (jack_port_id_t
)port_aux
;
456 if (!CheckPort(src
)) {
457 jack_error("jack_port_connected_to called with an incorrect port %ld", src
);
459 } else if (port_name
== NULL
) {
460 jack_error("jack_port_connected_to called with a NULL port name");
464 JackGraphManager
* manager
= GetGraphManager();
465 jack_port_id_t dst
= (manager
? manager
->GetPort(port_name
) : NO_PORT
);
466 if (dst
== NO_PORT
) {
467 jack_error("Unknown destination port port_name = %s", port_name
);
470 return manager
->IsConnected(src
, dst
);
475 EXPORT
int jack_port_tie(jack_port_t
* src
, jack_port_t
* dst
)
477 #ifdef __CLIENTDEBUG__
478 JackLibGlobals::CheckContext();
480 #if defined(__x86_64__) || defined(__ppc64__)
481 uint64_t src_aux
= (uint64_t)src
;
483 uint32_t src_aux
= (uint32_t)src
;
485 jack_port_id_t mysrc
= (jack_port_id_t
)src_aux
;
486 if (!CheckPort(mysrc
)) {
487 jack_error("jack_port_tie called with a NULL src port");
490 #if defined(__x86_64__) || defined(__ppc64__)
491 uint64_t dst_aux
= (uint64_t)dst
;
493 uint32_t dst_aux
= (uint32_t)dst
;
495 jack_port_id_t mydst
= (jack_port_id_t
)dst_aux
;
496 if (!CheckPort(mydst
)) {
497 jack_error("jack_port_tie called with a NULL dst port");
500 JackGraphManager
* manager
= GetGraphManager();
501 if (manager
&& manager
->GetPort(mysrc
)->GetRefNum() != manager
->GetPort(mydst
)->GetRefNum()) {
502 jack_error("jack_port_tie called with ports not belonging to the same client");
505 return manager
->GetPort(mydst
)->Tie(mysrc
);
509 EXPORT
int jack_port_untie(jack_port_t
* port
)
511 #ifdef __CLIENTDEBUG__
512 JackLibGlobals::CheckContext();
514 #if defined(__x86_64__) || defined(__ppc64__)
515 uint64_t port_aux
= (uint64_t)port
;
517 uint32_t port_aux
= (uint32_t)port
;
519 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
520 if (!CheckPort(myport
)) {
521 jack_error("jack_port_untie called with an incorrect port %ld", myport
);
524 JackGraphManager
* manager
= GetGraphManager();
525 return (manager
? manager
->GetPort(myport
)->UnTie() : -1);
529 EXPORT jack_nframes_t
jack_port_get_latency(jack_port_t
* port
)
531 #ifdef __CLIENTDEBUG__
532 JackLibGlobals::CheckContext();
534 #if defined(__x86_64__) || defined(__ppc64__)
535 uint64_t port_aux
= (uint64_t)port
;
537 uint32_t port_aux
= (uint32_t)port
;
539 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
540 if (!CheckPort(myport
)) {
541 jack_error("jack_port_get_latency called with an incorrect port %ld", myport
);
545 JackGraphManager
* manager
= GetGraphManager();
546 return (manager
? manager
->GetPort(myport
)->GetLatency() : 0);
550 EXPORT
void jack_port_set_latency(jack_port_t
* port
, jack_nframes_t frames
)
552 #ifdef __CLIENTDEBUG__
553 JackLibGlobals::CheckContext();
555 #if defined(__x86_64__) || defined(__ppc64__)
556 uint64_t port_aux
= (uint64_t)port
;
558 uint32_t port_aux
= (uint32_t)port
;
560 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
561 if (!CheckPort(myport
)) {
562 jack_error("jack_port_set_latency called with an incorrect port %ld", myport
);
564 JackGraphManager
* manager
= GetGraphManager();
566 manager
->GetPort(myport
)->SetLatency(frames
);
570 EXPORT
int jack_recompute_total_latency(jack_client_t
* ext_client
, jack_port_t
* port
)
572 #ifdef __CLIENTDEBUG__
573 JackLibGlobals::CheckContext();
576 JackClient
* client
= (JackClient
*)ext_client
;
577 #if defined(__x86_64__) || defined(__ppc64__)
578 uint64_t port_aux
= (uint64_t)port
;
580 uint32_t port_aux
= (uint32_t)port
;
582 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
583 if (client
== NULL
) {
584 jack_error("jack_recompute_total_latencies called with a NULL client");
586 } else if (!CheckPort(myport
)) {
587 jack_error("jack_recompute_total_latencies called with a NULL port");
591 JackGraphManager
* manager
= GetGraphManager();
592 return (manager
? manager
->ComputeTotalLatency(myport
) : -1);
596 EXPORT
int jack_recompute_total_latencies(jack_client_t
* ext_client
)
598 #ifdef __CLIENTDEBUG__
599 JackLibGlobals::CheckContext();
602 JackClient
* client
= (JackClient
*)ext_client
;
603 if (client
== NULL
) {
604 jack_error("jack_recompute_total_latencies called with a NULL client");
608 JackGraphManager
* manager
= GetGraphManager();
609 return (manager
? manager
->ComputeTotalLatencies() : -1);
614 This is unsafe if case of concurrent access, and should be "serialized" doing a server call.
617 EXPORT
int jack_port_set_name(jack_port_t
* port
, const char* name
)
619 #ifdef __CLIENTDEBUG__
620 JackLibGlobals::CheckContext();
622 #if defined(__x86_64__) || defined(__ppc64__)
623 uint64_t port_aux
= (uint64_t)port
;
625 uint32_t port_aux
= (uint32_t)port
;
627 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
628 if (!CheckPort(myport
)) {
629 jack_error("jack_port_set_name called with an incorrect port %ld", myport
);
631 } else if (name
== NULL
) {
632 jack_error("jack_port_set_name called with a NULL port name");
635 JackGraphManager
* manager
= GetGraphManager();
637 if (manager
&& ((refnum
= manager
->GetPort(myport
)->GetRefNum()) > 0)) {
638 JackClient
* client
= JackGlobals::fClientTable
[refnum
];
640 return client
->PortRename(myport
, name
);
647 EXPORT
int jack_port_set_alias(jack_port_t
* port
, const char* name
)
649 #ifdef __CLIENTDEBUG__
650 JackLibGlobals::CheckContext();
652 #if defined(__x86_64__) || defined(__ppc64__)
653 uint64_t port_aux
= (uint64_t)port
;
655 uint32_t port_aux
= (uint32_t)port
;
657 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
658 if (!CheckPort(myport
)) {
659 jack_error("jack_port_set_alias called with an incorrect port %ld", myport
);
661 } else if (name
== NULL
) {
662 jack_error("jack_port_set_alias called with a NULL port name");
665 JackGraphManager
* manager
= GetGraphManager();
666 return (manager
? manager
->GetPort(myport
)->SetAlias(name
) : -1);
670 EXPORT
int jack_port_unset_alias(jack_port_t
* port
, const char* name
)
672 #ifdef __CLIENTDEBUG__
673 JackLibGlobals::CheckContext();
675 #if defined(__x86_64__) || defined(__ppc64__)
676 uint64_t port_aux
= (uint64_t)port
;
678 uint32_t port_aux
= (uint32_t)port
;
680 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
681 if (!CheckPort(myport
)) {
682 jack_error("jack_port_unset_alias called with an incorrect port %ld", myport
);
684 } else if (name
== NULL
) {
685 jack_error("jack_port_unset_alias called with a NULL port name");
688 JackGraphManager
* manager
= GetGraphManager();
689 return (manager
? manager
->GetPort(myport
)->UnsetAlias(name
) : -1);
693 EXPORT
int jack_port_get_aliases(const jack_port_t
* port
, char* const aliases
[2])
695 #ifdef __CLIENTDEBUG__
696 JackLibGlobals::CheckContext();
698 #if defined(__x86_64__) || defined(__ppc64__)
699 uint64_t port_aux
= (uint64_t)port
;
701 uint32_t port_aux
= (uint32_t)port
;
703 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
704 if (!CheckPort(myport
)) {
705 jack_error("jack_port_get_aliases called with an incorrect port %ld", myport
);
708 JackGraphManager
* manager
= GetGraphManager();
709 return (manager
? manager
->GetPort(myport
)->GetAliases(aliases
) : -1);
713 EXPORT
int jack_port_request_monitor(jack_port_t
* port
, int onoff
)
715 #ifdef __CLIENTDEBUG__
716 JackLibGlobals::CheckContext();
718 #if defined(__x86_64__) || defined(__ppc64__)
719 uint64_t port_aux
= (uint64_t)port
;
721 uint32_t port_aux
= (uint32_t)port
;
723 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
724 if (!CheckPort(myport
)) {
725 jack_error("jack_port_request_monitor called with an incorrect port %ld", myport
);
728 JackGraphManager
* manager
= GetGraphManager();
729 return (manager
? manager
->RequestMonitor(myport
, onoff
) : -1);
733 EXPORT
int jack_port_request_monitor_by_name(jack_client_t
* ext_client
, const char* port_name
, int onoff
)
735 #ifdef __CLIENTDEBUG__
736 JackLibGlobals::CheckContext();
738 JackClient
* client
= (JackClient
*)ext_client
;
739 if (client
== NULL
) {
740 jack_error("jack_port_request_monitor_by_name called with a NULL client");
743 JackGraphManager
* manager
= GetGraphManager();
746 jack_port_id_t myport
= manager
->GetPort(port_name
);
747 if (!CheckPort(myport
)) {
748 jack_error("jack_port_request_monitor_by_name called with an incorrect port %s", port_name
);
751 return manager
->RequestMonitor(myport
, onoff
);
756 EXPORT
int jack_port_ensure_monitor(jack_port_t
* port
, int onoff
)
758 #ifdef __CLIENTDEBUG__
759 JackLibGlobals::CheckContext();
761 #if defined(__x86_64__) || defined(__ppc64__)
762 uint64_t port_aux
= (uint64_t)port
;
764 uint32_t port_aux
= (uint32_t)port
;
766 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
767 if (!CheckPort(myport
)) {
768 jack_error("jack_port_ensure_monitor called with an incorrect port %ld", myport
);
771 JackGraphManager
* manager
= GetGraphManager();
772 return (manager
? manager
->GetPort(myport
)->EnsureMonitor(onoff
) : -1);
776 EXPORT
int jack_port_monitoring_input(jack_port_t
* port
)
778 #ifdef __CLIENTDEBUG__
779 JackLibGlobals::CheckContext();
781 #if defined(__x86_64__) || defined(__ppc64__)
782 uint64_t port_aux
= (uint64_t)port
;
784 uint32_t port_aux
= (uint32_t)port
;
786 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
787 if (!CheckPort(myport
)) {
788 jack_error("jack_port_monitoring_input called with an incorrect port %ld", myport
);
791 JackGraphManager
* manager
= GetGraphManager();
792 return (manager
? manager
->GetPort(myport
)->MonitoringInput() : -1);
796 EXPORT
int jack_is_realtime(jack_client_t
* ext_client
)
798 #ifdef __CLIENTDEBUG__
799 JackLibGlobals::CheckContext();
801 JackClient
* client
= (JackClient
*)ext_client
;
802 if (client
== NULL
) {
803 jack_error("jack_is_realtime called with a NULL client");
806 JackEngineControl
* control
= GetEngineControl();
807 return (control
? control
->fRealTime
: -1);
811 EXPORT
void jack_on_shutdown(jack_client_t
* ext_client
, JackShutdownCallback callback
, void* arg
)
813 #ifdef __CLIENTDEBUG__
814 JackLibGlobals::CheckContext();
816 JackClient
* client
= (JackClient
*)ext_client
;
817 jack_error("jack_on_shutdown: deprecated, use jack_on_info_shutdown");
818 if (client
== NULL
) {
819 jack_error("jack_on_shutdown called with a NULL client");
821 client
->OnShutdown(callback
, arg
);
825 EXPORT
void jack_on_info_shutdown(jack_client_t
* ext_client
, JackInfoShutdownCallback callback
, void* arg
)
827 #ifdef __CLIENTDEBUG__
828 JackLibGlobals::CheckContext();
830 JackClient
* client
= (JackClient
*)ext_client
;
831 if (client
== NULL
) {
832 jack_error("jack_on_info_shutdown called with a NULL client");
834 client
->OnInfoShutdown(callback
, arg
);
838 EXPORT
int jack_set_process_callback(jack_client_t
* ext_client
, JackProcessCallback callback
, void* arg
)
840 #ifdef __CLIENTDEBUG__
841 JackLibGlobals::CheckContext();
843 JackClient
* client
= (JackClient
*)ext_client
;
844 if (client
== NULL
) {
845 jack_error("jack_set_process_callback called with a NULL client");
848 return client
->SetProcessCallback(callback
, arg
);
852 EXPORT jack_nframes_t
jack_thread_wait(jack_client_t
* ext_client
, int status
)
854 #ifdef __CLIENTDEBUG__
855 JackLibGlobals::CheckContext();
857 JackClient
* client
= (JackClient
*)ext_client
;
858 if (client
== NULL
) {
859 jack_error("jack_thread_wait called with a NULL client");
862 jack_error("jack_thread_wait: deprecated, use jack_cycle_wait/jack_cycle_signal");
867 EXPORT jack_nframes_t
jack_cycle_wait(jack_client_t
* ext_client
)
869 #ifdef __CLIENTDEBUG__
870 JackLibGlobals::CheckContext();
872 JackClient
* client
= (JackClient
*)ext_client
;
873 if (client
== NULL
) {
874 jack_error("jack_cycle_wait called with a NULL client");
877 return client
->CycleWait();
881 EXPORT
void jack_cycle_signal(jack_client_t
* ext_client
, int status
)
883 #ifdef __CLIENTDEBUG__
884 JackLibGlobals::CheckContext();
886 JackClient
* client
= (JackClient
*)ext_client
;
887 if (client
== NULL
) {
888 jack_error("jack_cycle_signal called with a NULL client");
890 client
->CycleSignal(status
);
894 EXPORT
int jack_set_process_thread(jack_client_t
* ext_client
, JackThreadCallback fun
, void *arg
)
896 #ifdef __CLIENTDEBUG__
897 JackLibGlobals::CheckContext();
899 JackClient
* client
= (JackClient
*)ext_client
;
900 if (client
== NULL
) {
901 jack_error("jack_set_process_thread called with a NULL client");
904 return client
->SetProcessThread(fun
, arg
);
908 EXPORT
int jack_set_freewheel_callback(jack_client_t
* ext_client
, JackFreewheelCallback freewheel_callback
, void* arg
)
910 #ifdef __CLIENTDEBUG__
911 JackLibGlobals::CheckContext();
913 JackClient
* client
= (JackClient
*)ext_client
;
914 if (client
== NULL
) {
915 jack_error("jack_set_freewheel_callback called with a NULL client");
918 return client
->SetFreewheelCallback(freewheel_callback
, arg
);
922 EXPORT
int jack_set_freewheel(jack_client_t
* ext_client
, int onoff
)
924 #ifdef __CLIENTDEBUG__
925 JackLibGlobals::CheckContext();
927 JackClient
* client
= (JackClient
*)ext_client
;
928 if (client
== NULL
) {
929 jack_error("jack_set_freewheel called with a NULL client");
932 return client
->SetFreeWheel(onoff
);
936 EXPORT
int jack_set_buffer_size(jack_client_t
* ext_client
, jack_nframes_t buffer_size
)
938 #ifdef __CLIENTDEBUG__
939 JackLibGlobals::CheckContext();
941 JackClient
* client
= (JackClient
*)ext_client
;
942 if (client
== NULL
) {
943 jack_error("jack_set_buffer_size called with a NULL client");
945 } else if (!CheckBufferSize(buffer_size
)) {
948 return client
->SetBufferSize(buffer_size
);
952 EXPORT
int jack_set_buffer_size_callback(jack_client_t
* ext_client
, JackBufferSizeCallback bufsize_callback
, void* arg
)
954 #ifdef __CLIENTDEBUG__
955 JackLibGlobals::CheckContext();
957 JackClient
* client
= (JackClient
*)ext_client
;
958 if (client
== NULL
) {
959 jack_error("jack_set_buffer_size_callback called with a NULL client");
962 return client
->SetBufferSizeCallback(bufsize_callback
, arg
);
966 EXPORT
int jack_set_sample_rate_callback(jack_client_t
* ext_client
, JackSampleRateCallback srate_callback
, void* arg
)
968 #ifdef __CLIENTDEBUG__
969 JackLibGlobals::CheckContext();
971 JackClient
* client
= (JackClient
*)ext_client
;
972 if (client
== NULL
) {
973 jack_error("jack_set_sample_rate_callback called with a NULL client");
976 return client
->SetSampleRateCallback(srate_callback
, arg
);
980 EXPORT
int jack_set_client_registration_callback(jack_client_t
* ext_client
, JackClientRegistrationCallback registration_callback
, void* arg
)
982 #ifdef __CLIENTDEBUG__
983 JackLibGlobals::CheckContext();
985 JackClient
* client
= (JackClient
*)ext_client
;
986 if (client
== NULL
) {
987 jack_error("jack_set_client_registration_callback called with a NULL client");
990 return client
->SetClientRegistrationCallback(registration_callback
, arg
);
994 EXPORT
int jack_set_port_registration_callback(jack_client_t
* ext_client
, JackPortRegistrationCallback registration_callback
, void* arg
)
996 #ifdef __CLIENTDEBUG__
997 JackLibGlobals::CheckContext();
999 JackClient
* client
= (JackClient
*)ext_client
;
1000 if (client
== NULL
) {
1001 jack_error("jack_set_port_registration_callback called with a NULL client");
1004 return client
->SetPortRegistrationCallback(registration_callback
, arg
);
1008 EXPORT
int jack_set_port_connect_callback(jack_client_t
* ext_client
, JackPortConnectCallback portconnect_callback
, void* arg
)
1010 #ifdef __CLIENTDEBUG__
1011 JackLibGlobals::CheckContext();
1013 JackClient
* client
= (JackClient
*)ext_client
;
1014 if (client
== NULL
) {
1015 jack_error("jack_set_port_connect_callback called with a NULL client");
1018 return client
->SetPortConnectCallback(portconnect_callback
, arg
);
1022 EXPORT
int jack_set_port_rename_callback(jack_client_t
* ext_client
, JackPortRenameCallback rename_callback
, void* arg
)
1024 #ifdef __CLIENTDEBUG__
1025 JackLibGlobals::CheckContext();
1027 JackClient
* client
= (JackClient
*)ext_client
;
1028 if (client
== NULL
) {
1029 jack_error("jack_set_port_rename_callback called with a NULL client");
1032 return client
->SetPortRenameCallback(rename_callback
, arg
);
1036 EXPORT
int jack_set_graph_order_callback(jack_client_t
* ext_client
, JackGraphOrderCallback graph_callback
, void* arg
)
1038 #ifdef __CLIENTDEBUG__
1039 JackLibGlobals::CheckContext();
1041 JackClient
* client
= (JackClient
*)ext_client
;
1042 jack_log("jack_set_graph_order_callback ext_client %x client %x ", ext_client
, client
);
1043 if (client
== NULL
) {
1044 jack_error("jack_set_graph_order_callback called with a NULL client");
1047 return client
->SetGraphOrderCallback(graph_callback
, arg
);
1051 EXPORT
int jack_set_xrun_callback(jack_client_t
* ext_client
, JackXRunCallback xrun_callback
, void* arg
)
1053 #ifdef __CLIENTDEBUG__
1054 JackLibGlobals::CheckContext();
1056 JackClient
* client
= (JackClient
*)ext_client
;
1057 if (client
== NULL
) {
1058 jack_error("jack_set_xrun_callback called with a NULL client");
1061 return client
->SetXRunCallback(xrun_callback
, arg
);
1065 EXPORT
int jack_set_thread_init_callback(jack_client_t
* ext_client
, JackThreadInitCallback init_callback
, void *arg
)
1067 #ifdef __CLIENTDEBUG__
1068 JackLibGlobals::CheckContext();
1070 JackClient
* client
= (JackClient
*)ext_client
;
1071 jack_log("jack_set_thread_init_callback ext_client %x client %x ", ext_client
, client
);
1072 if (client
== NULL
) {
1073 jack_error("jack_set_thread_init_callback called with a NULL client");
1076 return client
->SetInitCallback(init_callback
, arg
);
1080 EXPORT
int jack_activate(jack_client_t
* ext_client
)
1082 #ifdef __CLIENTDEBUG__
1083 JackLibGlobals::CheckContext();
1085 JackClient
* client
= (JackClient
*)ext_client
;
1086 if (client
== NULL
) {
1087 jack_error("jack_activate called with a NULL client");
1090 return client
->Activate();
1094 EXPORT
int jack_deactivate(jack_client_t
* ext_client
)
1096 #ifdef __CLIENTDEBUG__
1097 JackLibGlobals::CheckContext();
1099 JackClient
* client
= (JackClient
*)ext_client
;
1100 if (client
== NULL
) {
1101 jack_error("jack_deactivate called with a NULL client");
1104 return client
->Deactivate();
1108 EXPORT jack_port_t
* jack_port_register(jack_client_t
* ext_client
, const char* port_name
, const char* port_type
, unsigned long flags
, unsigned long buffer_size
)
1110 #ifdef __CLIENTDEBUG__
1111 JackLibGlobals::CheckContext();
1113 JackClient
* client
= (JackClient
*)ext_client
;
1114 if (client
== NULL
) {
1115 jack_error("jack_port_register called with a NULL client");
1117 } else if ((port_name
== NULL
) || (port_type
== NULL
)) {
1118 jack_error("jack_port_register called with a NULL port name or a NULL port_type");
1121 #if defined(__x86_64__) || defined(__ppc64__)
1122 return (jack_port_t
*)((uint64_t)client
->PortRegister(port_name
, port_type
, flags
, buffer_size
));
1124 return (jack_port_t
*)client
->PortRegister(port_name
, port_type
, flags
, buffer_size
);
1129 EXPORT
int jack_port_unregister(jack_client_t
* ext_client
, jack_port_t
* port
)
1131 #ifdef __CLIENTDEBUG__
1132 JackLibGlobals::CheckContext();
1134 JackClient
* client
= (JackClient
*)ext_client
;
1135 if (client
== NULL
) {
1136 jack_error("jack_port_unregister called with a NULL client");
1139 #if defined(__x86_64__) || defined(__ppc64__)
1140 uint64_t port_aux
= (uint64_t)port
;
1142 uint32_t port_aux
= (uint32_t)port
;
1144 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
1145 if (!CheckPort(myport
)) {
1146 jack_error("jack_port_unregister called with an incorrect port %ld", myport
);
1149 return client
->PortUnRegister(myport
);
1152 EXPORT
int jack_port_is_mine(const jack_client_t
* ext_client
, const jack_port_t
* port
)
1154 #ifdef __CLIENTDEBUG__
1155 JackLibGlobals::CheckContext();
1157 JackClient
* client
= (JackClient
*)ext_client
;
1158 if (client
== NULL
) {
1159 jack_error("jack_port_is_mine called with a NULL client");
1162 #if defined(__x86_64__) || defined(__ppc64__)
1163 uint64_t port_aux
= (uint64_t)port
;
1165 uint32_t port_aux
= (uint32_t)port
;
1167 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
1168 if (!CheckPort(myport
)) {
1169 jack_error("jack_port_is_mine called with an incorrect port %ld", myport
);
1172 return client
->PortIsMine(myport
);
1175 EXPORT
const char** jack_port_get_connections(const jack_port_t
* port
)
1177 #ifdef __CLIENTDEBUG__
1178 JackLibGlobals::CheckContext();
1180 #if defined(__x86_64__) || defined(__ppc64__)
1181 uint64_t port_aux
= (uint64_t)port
;
1183 uint32_t port_aux
= (uint32_t)port
;
1185 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
1186 if (!CheckPort(myport
)) {
1187 jack_error("jack_port_get_connections called with an incorrect port %ld", myport
);
1191 JackGraphManager
* manager
= GetGraphManager();
1192 return (manager
? manager
->GetConnections(myport
) : NULL
);
1196 // Calling client does not need to "own" the port
1197 EXPORT
const char** jack_port_get_all_connections(const jack_client_t
* ext_client
, const jack_port_t
* port
)
1199 #ifdef __CLIENTDEBUG__
1200 JackLibGlobals::CheckContext();
1202 JackClient
* client
= (JackClient
*)ext_client
;
1203 if (client
== NULL
) {
1204 jack_error("jack_port_get_all_connections called with a NULL client");
1208 #if defined(__x86_64__) || defined(__ppc64__)
1209 uint64_t port_aux
= (uint64_t)port
;
1211 uint32_t port_aux
= (uint32_t)port
;
1213 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
1214 if (!CheckPort(myport
)) {
1215 jack_error("jack_port_get_all_connections called with an incorrect port %ld", myport
);
1219 JackGraphManager
* manager
= GetGraphManager();
1220 return (manager
? manager
->GetConnections(myport
) : NULL
);
1224 EXPORT jack_nframes_t
jack_port_get_total_latency(jack_client_t
* ext_client
, jack_port_t
* port
)
1226 #ifdef __CLIENTDEBUG__
1227 JackLibGlobals::CheckContext();
1229 JackClient
* client
= (JackClient
*)ext_client
;
1230 if (client
== NULL
) {
1231 jack_error("jack_port_get_total_latency called with a NULL client");
1235 #if defined(__x86_64__) || defined(__ppc64__)
1236 uint64_t port_aux
= (uint64_t)port
;
1238 uint32_t port_aux
= (uint32_t)port
;
1240 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
1241 if (!CheckPort(myport
)) {
1242 jack_error("jack_port_get_total_latency called with an incorrect port %ld", myport
);
1246 JackGraphManager
* manager
= GetGraphManager();
1248 manager
->ComputeTotalLatency(myport
);
1249 return manager
->GetPort(myport
)->GetTotalLatency();
1256 EXPORT
int jack_connect(jack_client_t
* ext_client
, const char* src
, const char* dst
)
1258 #ifdef __CLIENTDEBUG__
1259 JackLibGlobals::CheckContext();
1261 JackClient
* client
= (JackClient
*)ext_client
;
1262 if (client
== NULL
) {
1263 jack_error("jack_connect called with a NULL client");
1265 } else if ((src
== NULL
) || (dst
== NULL
)) {
1266 jack_error("jack_connect called with a NULL port name");
1269 return client
->PortConnect(src
, dst
);
1273 EXPORT
int jack_disconnect(jack_client_t
* ext_client
, const char* src
, const char* dst
)
1275 #ifdef __CLIENTDEBUG__
1276 JackLibGlobals::CheckContext();
1278 JackClient
* client
= (JackClient
*)ext_client
;
1279 if (client
== NULL
) {
1280 jack_error("jack_disconnect called with a NULL client");
1282 } else if ((src
== NULL
) || (dst
== NULL
)) {
1283 jack_error("jack_connect called with a NULL port name");
1286 return client
->PortDisconnect(src
, dst
);
1290 EXPORT
int jack_port_disconnect(jack_client_t
* ext_client
, jack_port_t
* src
)
1292 #ifdef __CLIENTDEBUG__
1293 JackLibGlobals::CheckContext();
1295 JackClient
* client
= (JackClient
*)ext_client
;
1296 if (client
== NULL
) {
1297 jack_error("jack_port_disconnect called with a NULL client");
1300 #if defined(__x86_64__) || defined(__ppc64__)
1301 uint64_t port_aux
= (uint64_t)src
;
1303 uint32_t port_aux
= (uint32_t)src
;
1305 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
1306 if (!CheckPort(myport
)) {
1307 jack_error("jack_port_disconnect called with an incorrect port %ld", myport
);
1310 return client
->PortDisconnect(myport
);
1313 EXPORT jack_nframes_t
jack_get_sample_rate(jack_client_t
* ext_client
)
1315 #ifdef __CLIENTDEBUG__
1316 JackLibGlobals::CheckContext();
1318 JackClient
* client
= (JackClient
*)ext_client
;
1319 if (client
== NULL
) {
1320 jack_error("jack_get_sample_rate called with a NULL client");
1323 JackEngineControl
* control
= GetEngineControl();
1324 return (control
? control
->fSampleRate
: 0);
1328 EXPORT jack_nframes_t
jack_get_buffer_size(jack_client_t
* ext_client
)
1330 #ifdef __CLIENTDEBUG__
1331 JackLibGlobals::CheckContext();
1333 JackClient
* client
= (JackClient
*)ext_client
;
1334 if (client
== NULL
) {
1335 jack_error("jack_get_buffer_size called with a NULL client");
1338 JackEngineControl
* control
= GetEngineControl();
1339 return (control
? control
->fBufferSize
: 0);
1343 EXPORT
const char** jack_get_ports(jack_client_t
* ext_client
, const char* port_name_pattern
, const char* type_name_pattern
, unsigned long flags
)
1345 #ifdef __CLIENTDEBUG__
1346 JackLibGlobals::CheckContext();
1348 JackClient
* client
= (JackClient
*)ext_client
;
1349 if (client
== NULL
) {
1350 jack_error("jack_get_ports called with a NULL client");
1353 JackGraphManager
* manager
= GetGraphManager();
1354 return (manager
? manager
->GetPorts(port_name_pattern
, type_name_pattern
, flags
) : NULL
);
1357 EXPORT jack_port_t
* jack_port_by_name(jack_client_t
* ext_client
, const char* portname
)
1359 #ifdef __CLIENTDEBUG__
1360 JackLibGlobals::CheckContext();
1362 JackClient
* client
= (JackClient
*)ext_client
;
1363 if (client
== NULL
) {
1364 jack_error("jack_get_ports called with a NULL client");
1368 if (portname
== NULL
) {
1369 jack_error("jack_port_by_name called with a NULL port name");
1372 JackGraphManager
* manager
= GetGraphManager();
1375 int res
= manager
->GetPort(portname
); // returns a port index at least > 1
1376 #if defined(__x86_64__) || defined(__ppc64__)
1377 return (res
== NO_PORT
) ? NULL
: (jack_port_t
*)((uint64_t)res
);
1379 return (res
== NO_PORT
) ? NULL
: (jack_port_t
*)res
;
1384 EXPORT jack_port_t
* jack_port_by_id(jack_client_t
* ext_client
, jack_port_id_t id
)
1386 #ifdef __CLIENTDEBUG__
1387 JackLibGlobals::CheckContext();
1389 /* jack_port_t* type is actually the port index */
1390 #if defined(__x86_64__) || defined(__ppc64__)
1391 return (jack_port_t
*)((uint64_t)id
);
1393 return (jack_port_t
*)id
;
1397 EXPORT
int jack_engine_takeover_timebase(jack_client_t
* ext_client
)
1399 #ifdef __CLIENTDEBUG__
1400 JackLibGlobals::CheckContext();
1402 JackClient
* client
= (JackClient
*)ext_client
;
1403 if (client
== NULL
) {
1404 jack_error("jack_engine_takeover_timebase called with a NULL client");
1407 jack_error("jack_engine_takeover_timebase: deprecated\n");
1412 EXPORT jack_nframes_t
jack_frames_since_cycle_start(const jack_client_t
* ext_client
)
1414 #ifdef __CLIENTDEBUG__
1415 JackLibGlobals::CheckContext();
1418 JackEngineControl
* control
= GetEngineControl();
1420 control
->ReadFrameTime(&timer
);
1421 return timer
.FramesSinceCycleStart(GetMicroSeconds(), control
->fSampleRate
);
1427 EXPORT jack_time_t
jack_get_time()
1429 return GetMicroSeconds();
1432 EXPORT jack_time_t
jack_frames_to_time(const jack_client_t
* ext_client
, jack_nframes_t frames
)
1434 #ifdef __CLIENTDEBUG__
1435 JackLibGlobals::CheckContext();
1437 JackClient
* client
= (JackClient
*)ext_client
;
1438 if (client
== NULL
) {
1439 jack_error("jack_frames_to_time called with a NULL client");
1443 JackEngineControl
* control
= GetEngineControl();
1445 control
->ReadFrameTime(&timer
);
1446 return timer
.Frames2Time(frames
, control
->fBufferSize
);
1453 EXPORT jack_nframes_t
jack_time_to_frames(const jack_client_t
* ext_client
, jack_time_t time
)
1455 #ifdef __CLIENTDEBUG__
1456 JackLibGlobals::CheckContext();
1458 JackClient
* client
= (JackClient
*)ext_client
;
1459 if (client
== NULL
) {
1460 jack_error("jack_time_to_frames called with a NULL client");
1464 JackEngineControl
* control
= GetEngineControl();
1466 control
->ReadFrameTime(&timer
);
1467 return timer
.Time2Frames(time
, control
->fBufferSize
);
1474 EXPORT jack_nframes_t
jack_frame_time(const jack_client_t
* ext_client
)
1476 return jack_time_to_frames(ext_client
, GetMicroSeconds());
1479 EXPORT jack_nframes_t
jack_last_frame_time(const jack_client_t
* ext_client
)
1481 #ifdef __CLIENTDEBUG__
1482 JackLibGlobals::CheckContext();
1484 JackEngineControl
* control
= GetEngineControl();
1485 return (control
) ? control
->fFrameTimer
.ReadCurrentState()->CurFrame() : 0;
1488 EXPORT
float jack_cpu_load(jack_client_t
* ext_client
)
1490 #ifdef __CLIENTDEBUG__
1491 JackLibGlobals::CheckContext();
1493 JackClient
* client
= (JackClient
*)ext_client
;
1494 if (client
== NULL
) {
1495 jack_error("jack_cpu_load called with a NULL client");
1498 JackEngineControl
* control
= GetEngineControl();
1499 return (control
? control
->fCPULoad
: 0.0f
);
1503 EXPORT pthread_t
jack_client_thread_id(jack_client_t
* ext_client
)
1505 #ifdef __CLIENTDEBUG__
1506 JackLibGlobals::CheckContext();
1508 JackClient
* client
= (JackClient
*)ext_client
;
1509 if (client
== NULL
) {
1510 jack_error("jack_client_thread_id called with a NULL client");
1511 return (pthread_t
)NULL
;
1513 return client
->GetThreadID();
1517 EXPORT
char* jack_get_client_name(jack_client_t
* ext_client
)
1519 #ifdef __CLIENTDEBUG__
1520 JackLibGlobals::CheckContext();
1522 JackClient
* client
= (JackClient
*)ext_client
;
1523 if (client
== NULL
) {
1524 jack_error("jack_get_client_name called with a NULL client");
1527 return client
->GetClientControl()->fName
;
1531 EXPORT
int jack_client_name_size(void)
1533 return JACK_CLIENT_NAME_SIZE
;
1536 EXPORT
int jack_port_name_size(void)
1538 return JACK_PORT_NAME_SIZE
;
1541 EXPORT
int jack_port_type_size(void)
1543 return JACK_PORT_TYPE_SIZE
;
1547 EXPORT
int jack_release_timebase(jack_client_t
* ext_client
)
1549 #ifdef __CLIENTDEBUG__
1550 JackLibGlobals::CheckContext();
1552 JackClient
* client
= (JackClient
*)ext_client
;
1553 if (client
== NULL
) {
1554 jack_error("jack_release_timebase called with a NULL client");
1557 return client
->ReleaseTimebase();
1561 EXPORT
int jack_set_sync_callback(jack_client_t
* ext_client
, JackSyncCallback sync_callback
, void *arg
)
1563 #ifdef __CLIENTDEBUG__
1564 JackLibGlobals::CheckContext();
1566 JackClient
* client
= (JackClient
*)ext_client
;
1567 if (client
== NULL
) {
1568 jack_error("jack_set_sync_callback called with a NULL client");
1571 return client
->SetSyncCallback(sync_callback
, arg
);
1575 EXPORT
int jack_set_sync_timeout(jack_client_t
* ext_client
, jack_time_t timeout
)
1577 #ifdef __CLIENTDEBUG__
1578 JackLibGlobals::CheckContext();
1580 JackClient
* client
= (JackClient
*)ext_client
;
1581 if (client
== NULL
) {
1582 jack_error("jack_set_sync_timeout called with a NULL client");
1585 return client
->SetSyncTimeout(timeout
);
1589 EXPORT
int jack_set_timebase_callback(jack_client_t
* ext_client
, int conditional
, JackTimebaseCallback timebase_callback
, void* arg
)
1591 #ifdef __CLIENTDEBUG__
1592 JackLibGlobals::CheckContext();
1594 JackClient
* client
= (JackClient
*)ext_client
;
1595 if (client
== NULL
) {
1596 jack_error("jack_set_timebase_callback called with a NULL client");
1599 return client
->SetTimebaseCallback(conditional
, timebase_callback
, arg
);
1603 EXPORT
int jack_transport_locate(jack_client_t
* ext_client
, jack_nframes_t frame
)
1605 #ifdef __CLIENTDEBUG__
1606 JackLibGlobals::CheckContext();
1608 JackClient
* client
= (JackClient
*)ext_client
;
1609 if (client
== NULL
) {
1610 jack_error("jack_transport_locate called with a NULL client");
1613 client
->TransportLocate(frame
);
1618 EXPORT jack_transport_state_t
jack_transport_query(const jack_client_t
* ext_client
, jack_position_t
* pos
)
1620 #ifdef __CLIENTDEBUG__
1621 JackLibGlobals::CheckContext();
1623 JackClient
* client
= (JackClient
*)ext_client
;
1624 if (client
== NULL
) {
1625 jack_error("jack_transport_query called with a NULL client");
1626 return JackTransportStopped
;
1628 return client
->TransportQuery(pos
);
1632 EXPORT jack_nframes_t
jack_get_current_transport_frame(const jack_client_t
* ext_client
)
1634 #ifdef __CLIENTDEBUG__
1635 JackLibGlobals::CheckContext();
1637 JackClient
* client
= (JackClient
*)ext_client
;
1638 if (client
== NULL
) {
1639 jack_error("jack_get_current_transport_frame called with a NULL client");
1642 return client
->GetCurrentTransportFrame();
1646 EXPORT
int jack_transport_reposition(jack_client_t
* ext_client
, jack_position_t
* pos
)
1648 #ifdef __CLIENTDEBUG__
1649 JackLibGlobals::CheckContext();
1651 JackClient
* client
= (JackClient
*)ext_client
;
1652 if (client
== NULL
) {
1653 jack_error("jack_transport_reposition called with a NULL client");
1656 client
->TransportReposition(pos
);
1661 EXPORT
void jack_transport_start(jack_client_t
* ext_client
)
1663 #ifdef __CLIENTDEBUG__
1664 JackLibGlobals::CheckContext();
1666 JackClient
* client
= (JackClient
*)ext_client
;
1667 if (client
== NULL
) {
1668 jack_error("jack_transport_start called with a NULL client");
1670 client
->TransportStart();
1674 EXPORT
void jack_transport_stop(jack_client_t
* ext_client
)
1676 #ifdef __CLIENTDEBUG__
1677 JackLibGlobals::CheckContext();
1679 JackClient
* client
= (JackClient
*)ext_client
;
1680 if (client
== NULL
) {
1681 jack_error("jack_transport_stop called with a NULL client");
1683 client
->TransportStop();
1688 EXPORT
void jack_get_transport_info(jack_client_t
* ext_client
, jack_transport_info_t
* tinfo
)
1690 jack_error("jack_get_transport_info: deprecated");
1692 memset(tinfo
, 0, sizeof(jack_transport_info_t
));
1695 EXPORT
void jack_set_transport_info(jack_client_t
* ext_client
, jack_transport_info_t
* tinfo
)
1697 jack_error("jack_set_transport_info: deprecated");
1699 memset(tinfo
, 0, sizeof(jack_transport_info_t
));
1703 EXPORT
float jack_get_max_delayed_usecs(jack_client_t
* ext_client
)
1705 #ifdef __CLIENTDEBUG__
1706 JackLibGlobals::CheckContext();
1708 JackClient
* client
= (JackClient
*)ext_client
;
1709 if (client
== NULL
) {
1710 jack_error("jack_get_max_delayed_usecs called with a NULL client");
1713 JackEngineControl
* control
= GetEngineControl();
1714 return (control
? control
->fMaxDelayedUsecs
: 0.f
);
1718 EXPORT
float jack_get_xrun_delayed_usecs(jack_client_t
* ext_client
)
1720 #ifdef __CLIENTDEBUG__
1721 JackLibGlobals::CheckContext();
1723 JackClient
* client
= (JackClient
*)ext_client
;
1724 if (client
== NULL
) {
1725 jack_error("jack_get_xrun_delayed_usecs called with a NULL client");
1728 JackEngineControl
* control
= GetEngineControl();
1729 return (control
? control
->fXrunDelayedUsecs
: 0.f
);
1733 EXPORT
void jack_reset_max_delayed_usecs(jack_client_t
* ext_client
)
1735 #ifdef __CLIENTDEBUG__
1736 JackLibGlobals::CheckContext();
1738 JackClient
* client
= (JackClient
*)ext_client
;
1739 if (client
== NULL
) {
1740 jack_error("jack_reset_max_delayed_usecs called with a NULL client");
1742 JackEngineControl
* control
= GetEngineControl();
1743 control
->ResetXRun();
1748 EXPORT
int jack_client_real_time_priority(jack_client_t
* ext_client
)
1750 #ifdef __CLIENTDEBUG__
1751 JackLibGlobals::CheckContext();
1753 JackClient
* client
= (JackClient
*)ext_client
;
1754 if (client
== NULL
) {
1755 jack_error("jack_client_real_time_priority called with a NULL client");
1758 JackEngineControl
* control
= GetEngineControl();
1759 return (control
->fRealTime
) ? control
->fClientPriority
: -1;
1763 EXPORT
int jack_client_max_real_time_priority(jack_client_t
* ext_client
)
1765 #ifdef __CLIENTDEBUG__
1766 JackLibGlobals::CheckContext();
1768 JackClient
* client
= (JackClient
*)ext_client
;
1769 if (client
== NULL
) {
1770 jack_error("jack_client_max_real_time_priority called with a NULL client");
1773 JackEngineControl
* control
= GetEngineControl();
1774 return (control
->fRealTime
) ? control
->fMaxClientPriority
: -1;
1778 EXPORT
int jack_acquire_real_time_scheduling(pthread_t thread
, int priority
)
1780 JackEngineControl
* control
= GetEngineControl();
1781 return (control
? JackThread::AcquireRealTimeImp(thread
, priority
, GetEngineControl()->fPeriod
, GetEngineControl()->fComputation
, GetEngineControl()->fConstraint
) : -1);
1784 EXPORT
int jack_client_create_thread(jack_client_t
* client
,
1787 int realtime
, /* boolean */
1788 thread_routine routine
,
1791 return JackThread::StartImp(thread
, priority
, realtime
, routine
, arg
);
1794 EXPORT
int jack_drop_real_time_scheduling(pthread_t thread
)
1796 return JackThread::DropRealTimeImp(thread
);
1799 EXPORT
int jack_client_stop_thread(jack_client_t
* client
, pthread_t thread
)
1801 return JackThread::StopImp(thread
);
1804 EXPORT
int jack_client_kill_thread(jack_client_t
* client
, pthread_t thread
)
1806 return JackThread::KillImp(thread
);
1810 EXPORT
void jack_set_thread_creator (jack_thread_creator_t jtc
)
1812 JackGlobals::fJackThreadCreator
= (jtc
== NULL
) ? pthread_create
: jtc
;
1817 EXPORT
int jack_internal_client_new (const char *client_name
,
1818 const char *load_name
,
1819 const char *load_init
)
1821 jack_error("jack_internal_client_new: deprecated");
1825 EXPORT
void jack_internal_client_close (const char *client_name
)
1827 jack_error("jack_internal_client_close: deprecated");
1830 EXPORT
char* jack_get_internal_client_name(jack_client_t
* ext_client
, jack_intclient_t intclient
)
1832 #ifdef __CLIENTDEBUG__
1833 JackLibGlobals::CheckContext();
1835 JackClient
* client
= (JackClient
*)ext_client
;
1836 if (client
== NULL
) {
1837 jack_error("jack_get_internal_client_name called with a NULL client");
1839 } else if (intclient
>= CLIENT_NUM
) {
1840 jack_error("jack_get_internal_client_name: incorrect client");
1843 return client
->GetInternalClientName(intclient
);
1847 EXPORT jack_intclient_t
jack_internal_client_handle(jack_client_t
* ext_client
, const char* client_name
, jack_status_t
* status
)
1849 #ifdef __CLIENTDEBUG__
1850 JackLibGlobals::CheckContext();
1852 JackClient
* client
= (JackClient
*)ext_client
;
1853 if (client
== NULL
) {
1854 jack_error("jack_internal_client_handle called with a NULL client");
1857 jack_status_t my_status
;
1858 if (status
== NULL
) /* no status from caller? */
1859 status
= &my_status
; /* use local status word */
1860 *status
= (jack_status_t
)0;
1861 return client
->InternalClientHandle(client_name
, status
);
1865 EXPORT jack_intclient_t
jack_internal_client_load_aux(jack_client_t
* ext_client
, const char* client_name
, jack_options_t options
, jack_status_t
* status
, va_list ap
)
1867 #ifdef __CLIENTDEBUG__
1868 JackLibGlobals::CheckContext();
1870 JackClient
* client
= (JackClient
*)ext_client
;
1871 if (client
== NULL
) {
1872 jack_error("jack_internal_client_load called with a NULL client");
1876 jack_status_t my_status
;
1878 if (status
== NULL
) /* no status from caller? */
1879 status
= &my_status
; /* use local status word */
1880 *status
= (jack_status_t
)0;
1882 /* validate parameters */
1883 if ((options
& ~JackLoadOptions
)) {
1884 int my_status1
= *status
| (JackFailure
| JackInvalidOption
);
1885 *status
= (jack_status_t
)my_status1
;
1889 /* parse variable arguments */
1890 jack_varargs_parse(options
, ap
, &va
);
1891 return client
->InternalClientLoad(client_name
, options
, status
, &va
);
1895 EXPORT jack_intclient_t
jack_internal_client_load(jack_client_t
*client
, const char *client_name
, jack_options_t options
, jack_status_t
*status
, ...)
1898 va_start(ap
, status
);
1899 jack_intclient_t res
= jack_internal_client_load_aux(client
, client_name
, options
, status
, ap
);
1904 EXPORT jack_status_t
jack_internal_client_unload(jack_client_t
* ext_client
, jack_intclient_t intclient
)
1906 #ifdef __CLIENTDEBUG__
1907 JackLibGlobals::CheckContext();
1909 JackClient
* client
= (JackClient
*)ext_client
;
1910 if (client
== NULL
) {
1911 jack_error("jack_internal_client_unload called with a NULL client");
1912 return (jack_status_t
)(JackNoSuchClient
| JackFailure
);
1913 } else if (intclient
>= CLIENT_NUM
) {
1914 jack_error("jack_internal_client_unload: incorrect client");
1915 return (jack_status_t
)(JackNoSuchClient
| JackFailure
);
1917 jack_status_t my_status
;
1918 client
->InternalClientUnload(intclient
, &my_status
);
1931 // FIXME: We need these comming from build system
1940 jack_get_version_string()
1945 EXPORT
void jack_free(void* ptr
)