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 "JackPortType.h"
30 #define __STDC_FORMAT_MACROS 1
40 typedef void (*print_function
)(const char*);
41 typedef void *(*thread_routine
)(void*);
53 jack_get_version_string();
55 jack_client_t
* jack_client_new_aux(const char* client_name
,
56 jack_options_t options
,
57 jack_status_t
*status
);
59 LIB_EXPORT jack_client_t
* jack_client_open(const char* client_name
,
60 jack_options_t options
,
61 jack_status_t
*status
, ...);
62 LIB_EXPORT jack_client_t
* jack_client_new(const char* client_name
);
63 LIB_EXPORT
int jack_client_name_size(void);
64 LIB_EXPORT
char* jack_get_client_name(jack_client_t
*client
);
65 LIB_EXPORT
int jack_internal_client_new(const char* client_name
,
66 const char* load_name
,
67 const char* load_init
);
68 LIB_EXPORT
void jack_internal_client_close(const char* client_name
);
69 LIB_EXPORT
int jack_is_realtime(jack_client_t
*client
);
70 LIB_EXPORT
void jack_on_shutdown(jack_client_t
*client
,
71 JackShutdownCallback shutdown_callback
, void *arg
);
72 LIB_EXPORT
void jack_on_info_shutdown(jack_client_t
*client
,
73 JackInfoShutdownCallback shutdown_callback
, void *arg
);
74 LIB_EXPORT
int jack_set_process_callback(jack_client_t
*client
,
75 JackProcessCallback process_callback
,
77 LIB_EXPORT jack_nframes_t
jack_thread_wait(jack_client_t
*client
, int status
);
80 LIB_EXPORT jack_nframes_t
jack_cycle_wait(jack_client_t
*);
81 LIB_EXPORT
void jack_cycle_signal(jack_client_t
*, int status
);
82 LIB_EXPORT
int jack_set_process_thread(jack_client_t
* client
, JackThreadCallback fun
, void *arg
);
84 LIB_EXPORT
int jack_set_thread_init_callback(jack_client_t
*client
,
85 JackThreadInitCallback thread_init_callback
,
87 LIB_EXPORT
int jack_set_freewheel_callback(jack_client_t
*client
,
88 JackFreewheelCallback freewheel_callback
,
90 LIB_EXPORT
int jack_set_freewheel(jack_client_t
* client
, int onoff
);
91 LIB_EXPORT
int jack_set_buffer_size(jack_client_t
*client
, jack_nframes_t nframes
);
92 LIB_EXPORT
int jack_set_buffer_size_callback(jack_client_t
*client
,
93 JackBufferSizeCallback bufsize_callback
,
95 LIB_EXPORT
int jack_set_sample_rate_callback(jack_client_t
*client
,
96 JackSampleRateCallback srate_callback
,
98 LIB_EXPORT
int jack_set_client_registration_callback(jack_client_t
*,
99 JackClientRegistrationCallback
100 registration_callback
, void *arg
);
101 LIB_EXPORT
int jack_set_port_registration_callback(jack_client_t
*,
102 JackPortRegistrationCallback
103 registration_callback
, void *arg
);
104 LIB_EXPORT
int jack_set_port_connect_callback(jack_client_t
*,
105 JackPortConnectCallback
106 connect_callback
, void *arg
);
107 LIB_EXPORT
int jack_set_port_rename_callback(jack_client_t
*,
108 JackPortRenameCallback
109 rename_callback
, void *arg
);
110 LIB_EXPORT
int jack_set_graph_order_callback(jack_client_t
*,
111 JackGraphOrderCallback graph_callback
,
113 LIB_EXPORT
int jack_set_xrun_callback(jack_client_t
*,
114 JackXRunCallback xrun_callback
, void *arg
);
115 LIB_EXPORT
int jack_set_latency_callback(jack_client_t
*client
,
116 JackLatencyCallback latency_callback
, void *arg
);
118 LIB_EXPORT
int jack_activate(jack_client_t
*client
);
119 LIB_EXPORT
int jack_deactivate(jack_client_t
*client
);
120 LIB_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 LIB_EXPORT
int jack_port_unregister(jack_client_t
*, jack_port_t
*);
126 LIB_EXPORT
void * jack_port_get_buffer(jack_port_t
*, jack_nframes_t
);
127 LIB_EXPORT jack_uuid_t
jack_port_uuid(const jack_port_t
*);
128 LIB_EXPORT
const char* jack_port_name(const jack_port_t
*port
);
129 LIB_EXPORT
const char* jack_port_short_name(const jack_port_t
*port
);
130 LIB_EXPORT
int jack_port_flags(const jack_port_t
*port
);
131 LIB_EXPORT
const char* jack_port_type(const jack_port_t
*port
);
132 LIB_EXPORT jack_port_type_id_t
jack_port_type_id(const jack_port_t
*port
);
133 LIB_EXPORT
int jack_port_is_mine(const jack_client_t
*, const jack_port_t
*port
);
134 LIB_EXPORT
int jack_port_connected(const jack_port_t
*port
);
135 LIB_EXPORT
int jack_port_connected_to(const jack_port_t
*port
,
136 const char* port_name
);
137 LIB_EXPORT
const char* * jack_port_get_connections(const jack_port_t
*port
);
138 LIB_EXPORT
const char* * jack_port_get_all_connections(const jack_client_t
*client
,
139 const jack_port_t
*port
);
140 LIB_EXPORT
int jack_port_tie(jack_port_t
*src
, jack_port_t
*dst
);
141 LIB_EXPORT
int jack_port_untie(jack_port_t
*port
);
144 LIB_EXPORT jack_nframes_t
jack_port_get_latency(jack_port_t
*port
);
145 LIB_EXPORT jack_nframes_t
jack_port_get_total_latency(jack_client_t
*,
147 LIB_EXPORT
void jack_port_set_latency(jack_port_t
*, jack_nframes_t
);
148 LIB_EXPORT
int jack_recompute_total_latency(jack_client_t
*, jack_port_t
* port
);
151 LIB_EXPORT
void jack_port_get_latency_range(jack_port_t
*port
, jack_latency_callback_mode_t mode
, jack_latency_range_t
*range
);
152 LIB_EXPORT
void jack_port_set_latency_range(jack_port_t
*port
, jack_latency_callback_mode_t mode
, jack_latency_range_t
*range
);
153 LIB_EXPORT
int jack_recompute_total_latencies(jack_client_t
*);
155 LIB_EXPORT
int jack_port_set_name(jack_port_t
*port
, const char* port_name
);
156 LIB_EXPORT
int jack_port_rename(jack_client_t
*client
, jack_port_t
*port
, const char* port_name
);
157 LIB_EXPORT
int jack_port_set_alias(jack_port_t
*port
, const char* alias
);
158 LIB_EXPORT
int jack_port_unset_alias(jack_port_t
*port
, const char* alias
);
159 LIB_EXPORT
int jack_port_get_aliases(const jack_port_t
*port
, char* const aliases
[2]);
160 LIB_EXPORT
int jack_port_request_monitor(jack_port_t
*port
, int onoff
);
161 LIB_EXPORT
int jack_port_request_monitor_by_name(jack_client_t
*client
,
162 const char* port_name
, int onoff
);
163 LIB_EXPORT
int jack_port_ensure_monitor(jack_port_t
*port
, int onoff
);
164 LIB_EXPORT
int jack_port_monitoring_input(jack_port_t
*port
);
165 LIB_EXPORT
int jack_connect(jack_client_t
*,
166 const char* source_port
,
167 const char* destination_port
);
168 LIB_EXPORT
int jack_disconnect(jack_client_t
*,
169 const char* source_port
,
170 const char* destination_port
);
171 LIB_EXPORT
int jack_port_disconnect(jack_client_t
*, jack_port_t
*);
172 LIB_EXPORT
int jack_port_name_size(void);
173 LIB_EXPORT
int jack_port_type_size(void);
174 LIB_EXPORT
size_t jack_port_type_get_buffer_size(jack_client_t
*client
, const char* port_type
);
175 LIB_EXPORT jack_nframes_t
jack_get_sample_rate(jack_client_t
*);
176 LIB_EXPORT jack_nframes_t
jack_get_buffer_size(jack_client_t
*);
177 LIB_EXPORT
const char* * jack_get_ports(jack_client_t
*,
178 const char* port_name_pattern
,
179 const char* type_name_pattern
,
180 unsigned long flags
);
181 LIB_EXPORT jack_port_t
* jack_port_by_name(jack_client_t
*, const char* port_name
);
182 LIB_EXPORT jack_port_t
* jack_port_by_id(jack_client_t
*client
,
183 jack_port_id_t port_id
);
184 LIB_EXPORT
int jack_engine_takeover_timebase(jack_client_t
*);
185 LIB_EXPORT jack_nframes_t
jack_frames_since_cycle_start(const jack_client_t
*);
186 LIB_EXPORT jack_time_t
jack_get_time();
187 LIB_EXPORT jack_nframes_t
jack_time_to_frames(const jack_client_t
*client
, jack_time_t usecs
);
188 LIB_EXPORT jack_time_t
jack_frames_to_time(const jack_client_t
*client
, jack_nframes_t frames
);
189 LIB_EXPORT jack_nframes_t
jack_frame_time(const jack_client_t
*);
190 LIB_EXPORT jack_nframes_t
jack_last_frame_time(const jack_client_t
*client
);
191 LIB_EXPORT
int jack_get_cycle_times(const jack_client_t
*client
,
192 jack_nframes_t
*current_frames
,
193 jack_time_t
*current_usecs
,
194 jack_time_t
*next_usecs
,
195 float *period_usecs
);
196 LIB_EXPORT
float jack_cpu_load(jack_client_t
*client
);
197 LIB_EXPORT jack_native_thread_t
jack_client_thread_id(jack_client_t
*);
198 LIB_EXPORT
void jack_set_error_function(print_function
);
199 LIB_EXPORT
void jack_set_info_function(print_function
);
201 LIB_EXPORT
float jack_get_max_delayed_usecs(jack_client_t
*client
);
202 LIB_EXPORT
float jack_get_xrun_delayed_usecs(jack_client_t
*client
);
203 LIB_EXPORT
void jack_reset_max_delayed_usecs(jack_client_t
*client
);
205 LIB_EXPORT
int jack_release_timebase(jack_client_t
*client
);
206 LIB_EXPORT
int jack_set_sync_callback(jack_client_t
*client
,
207 JackSyncCallback sync_callback
,
209 LIB_EXPORT
int jack_set_sync_timeout(jack_client_t
*client
,
210 jack_time_t timeout
);
211 LIB_EXPORT
int jack_set_timebase_callback(jack_client_t
*client
,
213 JackTimebaseCallback timebase_callback
,
215 LIB_EXPORT
int jack_transport_locate(jack_client_t
*client
,
216 jack_nframes_t frame
);
217 LIB_EXPORT jack_transport_state_t
jack_transport_query(const jack_client_t
*client
,
218 jack_position_t
*pos
);
219 LIB_EXPORT jack_nframes_t
jack_get_current_transport_frame(const jack_client_t
*client
);
220 LIB_EXPORT
int jack_transport_reposition(jack_client_t
*client
,
221 const jack_position_t
*pos
);
222 LIB_EXPORT
void jack_transport_start(jack_client_t
*client
);
223 LIB_EXPORT
void jack_transport_stop(jack_client_t
*client
);
224 LIB_EXPORT
void jack_get_transport_info(jack_client_t
*client
,
225 jack_transport_info_t
*tinfo
);
226 LIB_EXPORT
void jack_set_transport_info(jack_client_t
*client
,
227 jack_transport_info_t
*tinfo
);
229 LIB_EXPORT
int jack_client_real_time_priority(jack_client_t
*);
230 LIB_EXPORT
int jack_client_max_real_time_priority(jack_client_t
*);
231 LIB_EXPORT
int jack_acquire_real_time_scheduling(jack_native_thread_t thread
, int priority
);
232 LIB_EXPORT
int jack_client_create_thread(jack_client_t
* client
,
233 jack_native_thread_t
*thread
,
235 int realtime
, // boolean
236 thread_routine routine
,
238 LIB_EXPORT
int jack_drop_real_time_scheduling(jack_native_thread_t thread
);
240 LIB_EXPORT
int jack_client_stop_thread(jack_client_t
* client
, jack_native_thread_t thread
);
241 LIB_EXPORT
int jack_client_kill_thread(jack_client_t
* client
, jack_native_thread_t thread
);
243 LIB_EXPORT
void jack_set_thread_creator(jack_thread_creator_t jtc
);
245 LIB_EXPORT
char * jack_get_internal_client_name(jack_client_t
*client
,
246 jack_intclient_t intclient
);
247 LIB_EXPORT jack_intclient_t
jack_internal_client_handle(jack_client_t
*client
,
248 const char* client_name
,
249 jack_status_t
*status
);
250 LIB_EXPORT jack_intclient_t
jack_internal_client_load(jack_client_t
*client
,
251 const char* client_name
,
252 jack_options_t options
,
253 jack_status_t
*status
, ...);
255 LIB_EXPORT jack_status_t
jack_internal_client_unload(jack_client_t
*client
,
256 jack_intclient_t intclient
);
257 LIB_EXPORT
void jack_free(void* ptr
);
259 LIB_EXPORT
int jack_set_session_callback(jack_client_t
* ext_client
, JackSessionCallback session_callback
, void* arg
);
260 LIB_EXPORT jack_session_command_t
*jack_session_notify(jack_client_t
* ext_client
, const char* target
, jack_session_event_type_t ev_type
, const char* path
);
261 LIB_EXPORT
int jack_session_reply(jack_client_t
* ext_client
, jack_session_event_t
*event
);
262 LIB_EXPORT
void jack_session_event_free(jack_session_event_t
* ev
);
263 LIB_EXPORT
char* jack_client_get_uuid (jack_client_t
*client
);
264 LIB_EXPORT
char* jack_get_uuid_for_client_name(jack_client_t
* ext_client
, const char* client_name
);
265 LIB_EXPORT
char* jack_get_client_name_by_uuid(jack_client_t
* ext_client
, const char* client_uuid
);
266 LIB_EXPORT
int jack_reserve_client_name(jack_client_t
* ext_client
, const char* name
, const char* uuid
);
267 LIB_EXPORT
void jack_session_commands_free(jack_session_command_t
*cmds
);
268 LIB_EXPORT
int jack_client_has_session_callback(jack_client_t
*client
, const char* client_name
);
270 LIB_EXPORT jack_uuid_t
jack_client_uuid_generate();
271 LIB_EXPORT jack_uuid_t
jack_port_uuid_generate(uint32_t port_id
);
272 LIB_EXPORT
uint32_t jack_uuid_to_index(jack_uuid_t
);
273 LIB_EXPORT
int jack_uuid_compare(jack_uuid_t
, jack_uuid_t
);
274 LIB_EXPORT
void jack_uuid_copy(jack_uuid_t
* dst
, jack_uuid_t src
);
275 LIB_EXPORT
void jack_uuid_clear(jack_uuid_t
*);
276 LIB_EXPORT
int jack_uuid_parse(const char* buf
, jack_uuid_t
*);
277 LIB_EXPORT
void jack_uuid_unparse(jack_uuid_t
, char buf
[JACK_UUID_STRING_SIZE
]);
278 LIB_EXPORT
int jack_uuid_empty(jack_uuid_t
);
284 static inline bool CheckPort(jack_port_id_t port_index
)
286 return (port_index
> 0 && port_index
< PORT_NUM_MAX
);
289 static inline bool CheckBufferSize(jack_nframes_t buffer_size
)
291 return (buffer_size
>= 1 && buffer_size
<= BUFFER_SIZE_MAX
);
294 static inline void WaitGraphChange()
297 TLS key that is set only in RT thread, so never waits for pending
298 graph change in RT context (just read the current graph state).
301 if (jack_tls_get(JackGlobals::fRealTimeThread
) == NULL
) {
302 JackGraphManager
* manager
= GetGraphManager();
303 JackEngineControl
* control
= GetEngineControl();
306 if (manager
->IsPendingChange()) {
307 jack_log("WaitGraphChange...");
308 JackSleep(int(control
->fPeriodUsecs
* 1.1f
));
313 LIB_EXPORT
void jack_set_error_function(print_function func
)
315 jack_error_callback
= (func
== NULL
) ? &default_jack_error_callback
: func
;
318 LIB_EXPORT
void jack_set_info_function(print_function func
)
320 jack_info_callback
= (func
== NULL
) ? &default_jack_info_callback
: func
;
323 LIB_EXPORT jack_client_t
* jack_client_new(const char* client_name
)
325 JackGlobals::CheckContext("jack_client_new");
328 assert(JackGlobals::fOpenMutex
);
329 JackGlobals::fOpenMutex
->Lock();
330 jack_error("jack_client_new: deprecated");
331 int options
= JackUseExactName
;
332 if (getenv("JACK_START_SERVER") == NULL
) {
333 options
|= JackNoStartServer
;
335 jack_client_t
* res
= jack_client_new_aux(client_name
, (jack_options_t
)options
, NULL
);
336 JackGlobals::fOpenMutex
->Unlock();
338 } catch (std::bad_alloc
& e
) {
339 jack_error("Memory allocation error...");
342 jack_error("Unknown error...");
347 LIB_EXPORT
void* jack_port_get_buffer(jack_port_t
* port
, jack_nframes_t frames
)
349 JackGlobals::CheckContext("jack_port_get_buffer");
351 uintptr_t port_aux
= (uintptr_t)port
;
352 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
353 if (!CheckPort(myport
)) {
354 jack_error("jack_port_get_buffer called with an incorrect port %ld", myport
);
357 JackGraphManager
* manager
= GetGraphManager();
358 return (manager
? manager
->GetBuffer(myport
, frames
) : NULL
);
362 LIB_EXPORT jack_uuid_t
jack_port_uuid(const jack_port_t
* port
)
364 JackGlobals::CheckContext("jack_port_uuid");
366 uintptr_t port_aux
= (uintptr_t)port
;
367 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
368 if (!CheckPort(myport
)) {
369 jack_error("jack_port_uuid called with an incorrect port %ld", myport
);
372 return jack_port_uuid_generate(myport
);
376 LIB_EXPORT
const char* jack_port_name(const jack_port_t
* port
)
378 JackGlobals::CheckContext("jack_port_name");
380 uintptr_t port_aux
= (uintptr_t)port
;
381 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
382 if (!CheckPort(myport
)) {
383 jack_error("jack_port_name called with an incorrect port %ld", myport
);
386 JackGraphManager
* manager
= GetGraphManager();
387 return (manager
? manager
->GetPort(myport
)->GetName() : NULL
);
391 LIB_EXPORT
const char* jack_port_short_name(const jack_port_t
* port
)
393 JackGlobals::CheckContext("jack_port_short_name");
395 uintptr_t port_aux
= (uintptr_t)port
;
396 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
397 if (!CheckPort(myport
)) {
398 jack_error("jack_port_short_name called with an incorrect port %ld", myport
);
401 JackGraphManager
* manager
= GetGraphManager();
402 return (manager
? manager
->GetPort(myport
)->GetShortName() : NULL
);
406 LIB_EXPORT
int jack_port_flags(const jack_port_t
* port
)
408 JackGlobals::CheckContext("jack_port_flags");
410 uintptr_t port_aux
= (uintptr_t)port
;
411 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
412 if (!CheckPort(myport
)) {
413 jack_error("jack_port_flags called with an incorrect port %ld", myport
);
416 JackGraphManager
* manager
= GetGraphManager();
417 return (manager
? manager
->GetPort(myport
)->GetFlags() : -1);
421 LIB_EXPORT
const char* jack_port_type(const jack_port_t
* port
)
423 JackGlobals::CheckContext("jack_port_type");
425 uintptr_t port_aux
= (uintptr_t)port
;
426 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
427 if (!CheckPort(myport
)) {
428 jack_error("jack_port_flags called an incorrect port %ld", myport
);
431 JackGraphManager
* manager
= GetGraphManager();
432 return (manager
? manager
->GetPort(myport
)->GetType() : NULL
);
436 LIB_EXPORT jack_port_type_id_t
jack_port_type_id(const jack_port_t
*port
)
438 JackGlobals::CheckContext("jack_port_type_id");
440 uintptr_t port_aux
= (uintptr_t)port
;
441 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
442 if (!CheckPort(myport
)) {
443 jack_error("jack_port_type_id called an incorrect port %ld", myport
);
446 JackGraphManager
* manager
= GetGraphManager();
447 return (manager
? GetPortTypeId(manager
->GetPort(myport
)->GetType()) : 0);
451 LIB_EXPORT
int jack_port_connected(const jack_port_t
* port
)
453 JackGlobals::CheckContext("jack_port_connected");
455 uintptr_t port_aux
= (uintptr_t)port
;
456 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
457 if (!CheckPort(myport
)) {
458 jack_error("jack_port_connected called with an incorrect port %ld", myport
);
462 JackGraphManager
* manager
= GetGraphManager();
463 return (manager
? manager
->GetConnectionsNum(myport
) : -1);
467 LIB_EXPORT
int jack_port_connected_to(const jack_port_t
* port
, const char* port_name
)
469 JackGlobals::CheckContext("jack_port_connected_to");
471 uintptr_t port_aux
= (uintptr_t)port
;
472 jack_port_id_t src
= (jack_port_id_t
)port_aux
;
473 if (!CheckPort(src
)) {
474 jack_error("jack_port_connected_to called with an incorrect port %ld", src
);
476 } else if (port_name
== NULL
) {
477 jack_error("jack_port_connected_to called with a NULL port name");
481 JackGraphManager
* manager
= GetGraphManager();
482 jack_port_id_t dst
= (manager
? manager
->GetPort(port_name
) : NO_PORT
);
483 if (dst
== NO_PORT
) {
484 jack_error("Unknown destination port port_name = %s", port_name
);
487 return manager
->IsConnected(src
, dst
);
492 LIB_EXPORT
int jack_port_tie(jack_port_t
* src
, jack_port_t
* dst
)
494 JackGlobals::CheckContext("jack_port_tie");
496 uintptr_t src_aux
= (uintptr_t)src
;
497 jack_port_id_t mysrc
= (jack_port_id_t
)src_aux
;
498 if (!CheckPort(mysrc
)) {
499 jack_error("jack_port_tie called with a NULL src port");
502 uintptr_t dst_aux
= (uintptr_t)dst
;
503 jack_port_id_t mydst
= (jack_port_id_t
)dst_aux
;
504 if (!CheckPort(mydst
)) {
505 jack_error("jack_port_tie called with a NULL dst port");
508 JackGraphManager
* manager
= GetGraphManager();
509 if (manager
&& manager
->GetPort(mysrc
)->GetRefNum() != manager
->GetPort(mydst
)->GetRefNum()) {
510 jack_error("jack_port_tie called with ports not belonging to the same client");
513 return manager
->GetPort(mydst
)->Tie(mysrc
);
517 LIB_EXPORT
int jack_port_untie(jack_port_t
* port
)
519 JackGlobals::CheckContext("jack_port_untie");
521 uintptr_t port_aux
= (uintptr_t)port
;
522 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
523 if (!CheckPort(myport
)) {
524 jack_error("jack_port_untie called with an incorrect port %ld", myport
);
527 JackGraphManager
* manager
= GetGraphManager();
528 return (manager
? manager
->GetPort(myport
)->UnTie() : -1);
532 LIB_EXPORT jack_nframes_t
jack_port_get_latency(jack_port_t
* port
)
534 JackGlobals::CheckContext("jack_port_get_latency");
536 uintptr_t port_aux
= (uintptr_t)port
;
537 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
538 if (!CheckPort(myport
)) {
539 jack_error("jack_port_get_latency called with an incorrect port %ld", myport
);
543 JackGraphManager
* manager
= GetGraphManager();
544 return (manager
? manager
->GetPort(myport
)->GetLatency() : 0);
548 LIB_EXPORT
void jack_port_set_latency(jack_port_t
* port
, jack_nframes_t frames
)
550 JackGlobals::CheckContext("jack_port_set_latency");
552 uintptr_t port_aux
= (uintptr_t)port
;
553 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
554 if (!CheckPort(myport
)) {
555 jack_error("jack_port_set_latency called with an incorrect port %ld", myport
);
557 JackGraphManager
* manager
= GetGraphManager();
559 manager
->GetPort(myport
)->SetLatency(frames
);
563 LIB_EXPORT
void jack_port_get_latency_range(jack_port_t
*port
, jack_latency_callback_mode_t mode
, jack_latency_range_t
*range
)
565 JackGlobals::CheckContext("jack_port_get_latency_range");
567 uintptr_t port_aux
= (uintptr_t)port
;
568 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
569 if (!CheckPort(myport
)) {
570 jack_error("jack_port_get_latency_range called with an incorrect port %ld", myport
);
573 JackGraphManager
* manager
= GetGraphManager();
575 manager
->GetPort(myport
)->GetLatencyRange(mode
, range
);
579 LIB_EXPORT
void jack_port_set_latency_range(jack_port_t
*port
, jack_latency_callback_mode_t mode
, jack_latency_range_t
*range
)
581 JackGlobals::CheckContext("jack_port_set_latency_range");
583 uintptr_t port_aux
= (uintptr_t)port
;
584 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
585 if (!CheckPort(myport
)) {
586 jack_error("jack_port_set_latency_range called with an incorrect port %ld", myport
);
589 JackGraphManager
* manager
= GetGraphManager();
591 manager
->GetPort(myport
)->SetLatencyRange(mode
, range
);
595 LIB_EXPORT
int jack_recompute_total_latency(jack_client_t
* ext_client
, jack_port_t
* port
)
597 JackGlobals::CheckContext("jack_recompute_total_latency");
600 JackClient
* client
= (JackClient
*)ext_client
;
601 uintptr_t port_aux
= (uintptr_t)port
;
602 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
603 if (client
== NULL
) {
604 jack_error("jack_recompute_total_latency called with a NULL client");
606 } else if (!CheckPort(myport
)) {
607 jack_error("jack_recompute_total_latency called with a NULL port");
611 JackGraphManager
* manager
= GetGraphManager();
612 return (manager
? manager
->ComputeTotalLatency(myport
) : -1);
616 LIB_EXPORT
int jack_recompute_total_latencies(jack_client_t
* ext_client
)
618 JackGlobals::CheckContext("jack_recompute_total_latencies");
620 JackClient
* client
= (JackClient
*)ext_client
;
621 if (client
== NULL
) {
622 jack_error("jack_recompute_total_latencies called with a NULL client");
625 return client
->ComputeTotalLatencies();
629 LIB_EXPORT
int jack_port_set_name(jack_port_t
* port
, const char* name
)
631 JackGlobals::CheckContext("jack_port_set_name");
632 jack_error("jack_port_set_name: deprecated");
634 // Find a valid client
635 jack_client_t
* client
= NULL
;
636 for (int i
= 0; i
< CLIENT_NUM
; i
++) {
637 if ((client
= (jack_client_t
*)JackGlobals::fClientTable
[i
])) {
642 return (client
) ? jack_port_rename(client
, port
, name
) : -1;
645 LIB_EXPORT
int jack_port_rename(jack_client_t
* ext_client
, jack_port_t
* port
, const char* name
)
647 JackGlobals::CheckContext("jack_port_rename");
649 JackClient
* client
= (JackClient
*)ext_client
;
650 uintptr_t port_aux
= (uintptr_t)port
;
651 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
652 if (client
== NULL
) {
653 jack_error("jack_port_rename called with a NULL client");
655 } else if (!CheckPort(myport
)) {
656 jack_error("jack_port_rename called with an incorrect port %ld", myport
);
658 } else if (name
== NULL
) {
659 jack_error("jack_port_rename called with a NULL port name");
662 return client
->PortRename(myport
, name
);
666 LIB_EXPORT
int jack_port_set_alias(jack_port_t
* port
, const char* name
)
668 JackGlobals::CheckContext("jack_port_set_alias");
670 uintptr_t port_aux
= (uintptr_t)port
;
671 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
672 if (!CheckPort(myport
)) {
673 jack_error("jack_port_set_alias called with an incorrect port %ld", myport
);
675 } else if (name
== NULL
) {
676 jack_error("jack_port_set_alias called with a NULL port name");
679 JackGraphManager
* manager
= GetGraphManager();
680 return (manager
? manager
->GetPort(myport
)->SetAlias(name
) : -1);
684 LIB_EXPORT
int jack_port_unset_alias(jack_port_t
* port
, const char* name
)
686 JackGlobals::CheckContext("jack_port_unset_alias");
688 uintptr_t port_aux
= (uintptr_t)port
;
689 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
690 if (!CheckPort(myport
)) {
691 jack_error("jack_port_unset_alias called with an incorrect port %ld", myport
);
693 } else if (name
== NULL
) {
694 jack_error("jack_port_unset_alias called with a NULL port name");
697 JackGraphManager
* manager
= GetGraphManager();
698 return (manager
? manager
->GetPort(myport
)->UnsetAlias(name
) : -1);
702 LIB_EXPORT
int jack_port_get_aliases(const jack_port_t
* port
, char* const aliases
[2])
704 JackGlobals::CheckContext("jack_port_get_aliases");
706 uintptr_t port_aux
= (uintptr_t)port
;
707 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
708 if (!CheckPort(myport
)) {
709 jack_error("jack_port_get_aliases called with an incorrect port %ld", myport
);
712 JackGraphManager
* manager
= GetGraphManager();
713 return (manager
? manager
->GetPort(myport
)->GetAliases(aliases
) : -1);
717 LIB_EXPORT
int jack_port_request_monitor(jack_port_t
* port
, int onoff
)
719 JackGlobals::CheckContext("jack_port_request_monitor");
721 uintptr_t port_aux
= (uintptr_t)port
;
722 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
723 if (!CheckPort(myport
)) {
724 jack_error("jack_port_request_monitor called with an incorrect port %ld", myport
);
727 JackGraphManager
* manager
= GetGraphManager();
728 return (manager
? manager
->RequestMonitor(myport
, onoff
) : -1);
732 LIB_EXPORT
int jack_port_request_monitor_by_name(jack_client_t
* ext_client
, const char* port_name
, int onoff
)
734 JackGlobals::CheckContext("jack_port_request_monitor_by_name");
736 JackClient
* client
= (JackClient
*)ext_client
;
737 if (client
== NULL
) {
738 jack_error("jack_port_request_monitor_by_name called with a NULL client");
741 JackGraphManager
* manager
= GetGraphManager();
744 jack_port_id_t myport
= manager
->GetPort(port_name
);
745 if (!CheckPort(myport
)) {
746 jack_error("jack_port_request_monitor_by_name called with an incorrect port %s", port_name
);
749 return manager
->RequestMonitor(myport
, onoff
);
754 LIB_EXPORT
int jack_port_ensure_monitor(jack_port_t
* port
, int onoff
)
756 JackGlobals::CheckContext("jack_port_ensure_monitor");
758 uintptr_t port_aux
= (uintptr_t)port
;
759 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
760 if (!CheckPort(myport
)) {
761 jack_error("jack_port_ensure_monitor called with an incorrect port %ld", myport
);
764 JackGraphManager
* manager
= GetGraphManager();
765 return (manager
? manager
->GetPort(myport
)->EnsureMonitor(onoff
) : -1);
769 LIB_EXPORT
int jack_port_monitoring_input(jack_port_t
* port
)
771 JackGlobals::CheckContext("jack_port_monitoring_input");
773 uintptr_t port_aux
= (uintptr_t)port
;
774 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
775 if (!CheckPort(myport
)) {
776 jack_error("jack_port_monitoring_input called with an incorrect port %ld", myport
);
779 JackGraphManager
* manager
= GetGraphManager();
780 return (manager
? manager
->GetPort(myport
)->MonitoringInput() : -1);
784 LIB_EXPORT
int jack_is_realtime(jack_client_t
* ext_client
)
786 JackGlobals::CheckContext("jack_is_realtime");
788 JackClient
* client
= (JackClient
*)ext_client
;
789 if (client
== NULL
) {
790 jack_error("jack_is_realtime called with a NULL client");
793 JackEngineControl
* control
= GetEngineControl();
794 return (control
? control
->fRealTime
: -1);
798 LIB_EXPORT
void jack_on_shutdown(jack_client_t
* ext_client
, JackShutdownCallback callback
, void* arg
)
800 JackGlobals::CheckContext("jack_on_shutdown");
802 JackClient
* client
= (JackClient
*)ext_client
;
803 if (client
== NULL
) {
804 jack_error("jack_on_shutdown called with a NULL client");
806 client
->OnShutdown(callback
, arg
);
810 LIB_EXPORT
void jack_on_info_shutdown(jack_client_t
* ext_client
, JackInfoShutdownCallback callback
, void* arg
)
812 JackGlobals::CheckContext("jack_on_info_shutdown");
814 JackClient
* client
= (JackClient
*)ext_client
;
815 if (client
== NULL
) {
816 jack_error("jack_on_info_shutdown called with a NULL client");
818 client
->OnInfoShutdown(callback
, arg
);
822 LIB_EXPORT
int jack_set_process_callback(jack_client_t
* ext_client
, JackProcessCallback callback
, void* arg
)
824 JackGlobals::CheckContext("jack_set_process_callback");
826 JackClient
* client
= (JackClient
*)ext_client
;
827 if (client
== NULL
) {
828 jack_error("jack_set_process_callback called with a NULL client");
831 return client
->SetProcessCallback(callback
, arg
);
835 LIB_EXPORT jack_nframes_t
jack_thread_wait(jack_client_t
* ext_client
, int status
)
837 JackGlobals::CheckContext("jack_thread_wait");
839 JackClient
* client
= (JackClient
*)ext_client
;
840 if (client
== NULL
) {
841 jack_error("jack_thread_wait called with a NULL client");
844 jack_error("jack_thread_wait: deprecated, use jack_cycle_wait/jack_cycle_signal");
849 LIB_EXPORT jack_nframes_t
jack_cycle_wait(jack_client_t
* ext_client
)
851 JackGlobals::CheckContext("jack_cycle_wait");
853 JackClient
* client
= (JackClient
*)ext_client
;
854 if (client
== NULL
) {
855 jack_error("jack_cycle_wait called with a NULL client");
858 return client
->CycleWait();
862 LIB_EXPORT
void jack_cycle_signal(jack_client_t
* ext_client
, int status
)
864 JackGlobals::CheckContext("jack_cycle_signal");
866 JackClient
* client
= (JackClient
*)ext_client
;
867 if (client
== NULL
) {
868 jack_error("jack_cycle_signal called with a NULL client");
870 client
->CycleSignal(status
);
874 LIB_EXPORT
int jack_set_process_thread(jack_client_t
* ext_client
, JackThreadCallback fun
, void *arg
)
876 JackGlobals::CheckContext("jack_set_process_thread");
878 JackClient
* client
= (JackClient
*)ext_client
;
879 if (client
== NULL
) {
880 jack_error("jack_set_process_thread called with a NULL client");
883 return client
->SetProcessThread(fun
, arg
);
887 LIB_EXPORT
int jack_set_freewheel_callback(jack_client_t
* ext_client
, JackFreewheelCallback freewheel_callback
, void* arg
)
889 JackGlobals::CheckContext("jack_set_freewheel_callback");
891 JackClient
* client
= (JackClient
*)ext_client
;
892 if (client
== NULL
) {
893 jack_error("jack_set_freewheel_callback called with a NULL client");
896 return client
->SetFreewheelCallback(freewheel_callback
, arg
);
900 LIB_EXPORT
int jack_set_freewheel(jack_client_t
* ext_client
, int onoff
)
902 JackGlobals::CheckContext("jack_set_freewheel");
904 JackClient
* client
= (JackClient
*)ext_client
;
905 if (client
== NULL
) {
906 jack_error("jack_set_freewheel called with a NULL client");
909 return client
->SetFreeWheel(onoff
);
913 LIB_EXPORT
int jack_set_buffer_size(jack_client_t
* ext_client
, jack_nframes_t buffer_size
)
915 JackGlobals::CheckContext("jack_set_buffer_size");
917 JackClient
* client
= (JackClient
*)ext_client
;
918 if (client
== NULL
) {
919 jack_error("jack_set_buffer_size called with a NULL client");
921 } else if (!CheckBufferSize(buffer_size
)) {
924 return client
->SetBufferSize(buffer_size
);
928 LIB_EXPORT
int jack_set_buffer_size_callback(jack_client_t
* ext_client
, JackBufferSizeCallback bufsize_callback
, void* arg
)
930 JackGlobals::CheckContext("jack_set_buffer_size_callback");
932 JackClient
* client
= (JackClient
*)ext_client
;
933 if (client
== NULL
) {
934 jack_error("jack_set_buffer_size_callback called with a NULL client");
937 return client
->SetBufferSizeCallback(bufsize_callback
, arg
);
941 LIB_EXPORT
int jack_set_sample_rate_callback(jack_client_t
* ext_client
, JackSampleRateCallback srate_callback
, void* arg
)
943 JackGlobals::CheckContext("jack_set_sample_rate_callback");
945 JackClient
* client
= (JackClient
*)ext_client
;
946 if (client
== NULL
) {
947 jack_error("jack_set_sample_rate_callback called with a NULL client");
950 return client
->SetSampleRateCallback(srate_callback
, arg
);
954 LIB_EXPORT
int jack_set_client_registration_callback(jack_client_t
* ext_client
, JackClientRegistrationCallback registration_callback
, void* arg
)
956 JackGlobals::CheckContext("jack_set_client_registration_callback");
958 JackClient
* client
= (JackClient
*)ext_client
;
959 if (client
== NULL
) {
960 jack_error("jack_set_client_registration_callback called with a NULL client");
963 return client
->SetClientRegistrationCallback(registration_callback
, arg
);
967 LIB_EXPORT
int jack_set_port_registration_callback(jack_client_t
* ext_client
, JackPortRegistrationCallback registration_callback
, void* arg
)
969 JackGlobals::CheckContext("jack_set_port_registration_callback");
971 JackClient
* client
= (JackClient
*)ext_client
;
972 if (client
== NULL
) {
973 jack_error("jack_set_port_registration_callback called with a NULL client");
976 return client
->SetPortRegistrationCallback(registration_callback
, arg
);
980 LIB_EXPORT
int jack_set_port_connect_callback(jack_client_t
* ext_client
, JackPortConnectCallback portconnect_callback
, void* arg
)
982 JackGlobals::CheckContext("jack_set_port_connect_callback");
984 JackClient
* client
= (JackClient
*)ext_client
;
985 if (client
== NULL
) {
986 jack_error("jack_set_port_connect_callback called with a NULL client");
989 return client
->SetPortConnectCallback(portconnect_callback
, arg
);
993 LIB_EXPORT
int jack_set_port_rename_callback(jack_client_t
* ext_client
, JackPortRenameCallback rename_callback
, void* arg
)
995 JackGlobals::CheckContext("jack_set_port_rename_callback");
997 JackClient
* client
= (JackClient
*)ext_client
;
998 if (client
== NULL
) {
999 jack_error("jack_set_port_rename_callback called with a NULL client");
1002 return client
->SetPortRenameCallback(rename_callback
, arg
);
1006 LIB_EXPORT
int jack_set_graph_order_callback(jack_client_t
* ext_client
, JackGraphOrderCallback graph_callback
, void* arg
)
1008 JackGlobals::CheckContext("jack_set_graph_order_callback");
1010 JackClient
* client
= (JackClient
*)ext_client
;
1011 jack_log("jack_set_graph_order_callback ext_client %x client %x ", ext_client
, client
);
1012 if (client
== NULL
) {
1013 jack_error("jack_set_graph_order_callback called with a NULL client");
1016 return client
->SetGraphOrderCallback(graph_callback
, arg
);
1020 LIB_EXPORT
int jack_set_xrun_callback(jack_client_t
* ext_client
, JackXRunCallback xrun_callback
, void* arg
)
1022 JackGlobals::CheckContext("jack_set_xrun_callback");
1024 JackClient
* client
= (JackClient
*)ext_client
;
1025 if (client
== NULL
) {
1026 jack_error("jack_set_xrun_callback called with a NULL client");
1029 return client
->SetXRunCallback(xrun_callback
, arg
);
1033 LIB_EXPORT
int jack_set_latency_callback(jack_client_t
* ext_client
, JackLatencyCallback latency_callback
, void *arg
)
1035 JackGlobals::CheckContext("jack_set_latency_callback");
1037 JackClient
* client
= (JackClient
*)ext_client
;
1038 if (client
== NULL
) {
1039 jack_error("jack_set_latency_callback called with a NULL client");
1042 return client
->SetLatencyCallback(latency_callback
, arg
);
1046 LIB_EXPORT
int jack_set_thread_init_callback(jack_client_t
* ext_client
, JackThreadInitCallback init_callback
, void *arg
)
1048 JackGlobals::CheckContext("jack_set_thread_init_callback");
1050 JackClient
* client
= (JackClient
*)ext_client
;
1051 jack_log("jack_set_thread_init_callback ext_client %x client %x ", ext_client
, client
);
1052 if (client
== NULL
) {
1053 jack_error("jack_set_thread_init_callback called with a NULL client");
1056 return client
->SetInitCallback(init_callback
, arg
);
1060 LIB_EXPORT
int jack_activate(jack_client_t
* ext_client
)
1062 JackGlobals::CheckContext("jack_activate");
1064 JackClient
* client
= (JackClient
*)ext_client
;
1065 if (client
== NULL
) {
1066 jack_error("jack_activate called with a NULL client");
1069 return client
->Activate();
1073 LIB_EXPORT
int jack_deactivate(jack_client_t
* ext_client
)
1075 JackGlobals::CheckContext("jack_deactivate");
1077 JackClient
* client
= (JackClient
*)ext_client
;
1078 if (client
== NULL
) {
1079 jack_error("jack_deactivate called with a NULL client");
1082 return client
->Deactivate();
1086 LIB_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
)
1088 JackGlobals::CheckContext("jack_port_register");
1090 JackClient
* client
= (JackClient
*)ext_client
;
1091 if (client
== NULL
) {
1092 jack_error("jack_port_register called with a NULL client");
1094 } else if ((port_name
== NULL
) || (port_type
== NULL
)) {
1095 jack_error("jack_port_register called with a NULL port name or a NULL port_type");
1098 return (jack_port_t
*)((uintptr_t)client
->PortRegister(port_name
, port_type
, flags
, buffer_size
));
1102 LIB_EXPORT
int jack_port_unregister(jack_client_t
* ext_client
, jack_port_t
* port
)
1104 JackGlobals::CheckContext("jack_port_unregister");
1106 JackClient
* client
= (JackClient
*)ext_client
;
1107 if (client
== NULL
) {
1108 jack_error("jack_port_unregister called with a NULL client");
1111 uintptr_t port_aux
= (uintptr_t)port
;
1112 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
1113 if (!CheckPort(myport
)) {
1114 jack_error("jack_port_unregister called with an incorrect port %ld", myport
);
1117 return client
->PortUnRegister(myport
);
1120 LIB_EXPORT
int jack_port_is_mine(const jack_client_t
* ext_client
, const jack_port_t
* port
)
1122 JackGlobals::CheckContext("jack_port_is_mine");
1124 JackClient
* client
= (JackClient
*)ext_client
;
1125 if (client
== NULL
) {
1126 jack_error("jack_port_is_mine called with a NULL client");
1129 uintptr_t port_aux
= (uintptr_t)port
;
1130 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
1131 if (!CheckPort(myport
)) {
1132 jack_error("jack_port_is_mine called with an incorrect port %ld", myport
);
1135 return client
->PortIsMine(myport
);
1138 LIB_EXPORT
const char** jack_port_get_connections(const jack_port_t
* port
)
1140 JackGlobals::CheckContext("jack_port_get_connections");
1142 uintptr_t port_aux
= (uintptr_t)port
;
1143 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
1144 if (!CheckPort(myport
)) {
1145 jack_error("jack_port_get_connections called with an incorrect port %ld", myport
);
1149 JackGraphManager
* manager
= GetGraphManager();
1150 return (manager
? manager
->GetConnections(myport
) : NULL
);
1154 // Calling client does not need to "own" the port
1155 LIB_EXPORT
const char** jack_port_get_all_connections(const jack_client_t
* ext_client
, const jack_port_t
* port
)
1157 JackGlobals::CheckContext("jack_port_get_all_connections");
1159 JackClient
* client
= (JackClient
*)ext_client
;
1160 if (client
== NULL
) {
1161 jack_error("jack_port_get_all_connections called with a NULL client");
1165 uintptr_t port_aux
= (uintptr_t)port
;
1166 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
1167 if (!CheckPort(myport
)) {
1168 jack_error("jack_port_get_all_connections called with an incorrect port %ld", myport
);
1172 JackGraphManager
* manager
= GetGraphManager();
1173 return (manager
? manager
->GetConnections(myport
) : NULL
);
1177 LIB_EXPORT jack_nframes_t
jack_port_get_total_latency(jack_client_t
* ext_client
, jack_port_t
* port
)
1179 JackGlobals::CheckContext("jack_port_get_total_latency");
1181 JackClient
* client
= (JackClient
*)ext_client
;
1182 if (client
== NULL
) {
1183 jack_error("jack_port_get_total_latency called with a NULL client");
1187 uintptr_t port_aux
= (uintptr_t)port
;
1188 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
1189 if (!CheckPort(myport
)) {
1190 jack_error("jack_port_get_total_latency called with an incorrect port %ld", myport
);
1194 JackGraphManager
* manager
= GetGraphManager();
1196 manager
->ComputeTotalLatency(myport
);
1197 return manager
->GetPort(myport
)->GetTotalLatency();
1204 LIB_EXPORT
int jack_connect(jack_client_t
* ext_client
, const char* src
, const char* dst
)
1206 JackGlobals::CheckContext("jack_connect");
1208 JackClient
* client
= (JackClient
*)ext_client
;
1209 if (client
== NULL
) {
1210 jack_error("jack_connect called with a NULL client");
1212 } else if ((src
== NULL
) || (dst
== NULL
)) {
1213 jack_error("jack_connect called with a NULL port name");
1216 return client
->PortConnect(src
, dst
);
1220 LIB_EXPORT
int jack_disconnect(jack_client_t
* ext_client
, const char* src
, const char* dst
)
1222 JackGlobals::CheckContext("jack_disconnect");
1224 JackClient
* client
= (JackClient
*)ext_client
;
1225 if (client
== NULL
) {
1226 jack_error("jack_disconnect called with a NULL client");
1228 } else if ((src
== NULL
) || (dst
== NULL
)) {
1229 jack_error("jack_disconnect called with a NULL port name");
1232 return client
->PortDisconnect(src
, dst
);
1236 LIB_EXPORT
int jack_port_disconnect(jack_client_t
* ext_client
, jack_port_t
* src
)
1238 JackGlobals::CheckContext("jack_port_disconnect");
1240 JackClient
* client
= (JackClient
*)ext_client
;
1241 if (client
== NULL
) {
1242 jack_error("jack_port_disconnect called with a NULL client");
1245 uintptr_t port_aux
= (uintptr_t)src
;
1246 jack_port_id_t myport
= (jack_port_id_t
)port_aux
;
1247 if (!CheckPort(myport
)) {
1248 jack_error("jack_port_disconnect called with an incorrect port %ld", myport
);
1251 return client
->PortDisconnect(myport
);
1254 LIB_EXPORT jack_nframes_t
jack_get_sample_rate(jack_client_t
* ext_client
)
1256 JackGlobals::CheckContext("jack_get_sample_rate");
1258 JackClient
* client
= (JackClient
*)ext_client
;
1259 if (client
== NULL
) {
1260 jack_error("jack_get_sample_rate called with a NULL client");
1263 JackEngineControl
* control
= GetEngineControl();
1264 return (control
? control
->fSampleRate
: 0);
1268 LIB_EXPORT jack_nframes_t
jack_get_buffer_size(jack_client_t
* ext_client
)
1270 JackGlobals::CheckContext("jack_get_buffer_size");
1272 JackClient
* client
= (JackClient
*)ext_client
;
1273 if (client
== NULL
) {
1274 jack_error("jack_get_buffer_size called with a NULL client");
1277 JackEngineControl
* control
= GetEngineControl();
1278 return (control
? control
->fBufferSize
: 0);
1282 LIB_EXPORT
const char** jack_get_ports(jack_client_t
* ext_client
, const char* port_name_pattern
, const char* type_name_pattern
, unsigned long flags
)
1284 JackGlobals::CheckContext("jack_get_ports");
1286 JackClient
* client
= (JackClient
*)ext_client
;
1287 if (client
== NULL
) {
1288 jack_error("jack_get_ports called with a NULL client");
1291 JackGraphManager
* manager
= GetGraphManager();
1292 return (manager
? manager
->GetPorts(port_name_pattern
, type_name_pattern
, flags
) : NULL
);
1295 LIB_EXPORT jack_port_t
* jack_port_by_name(jack_client_t
* ext_client
, const char* portname
)
1297 JackGlobals::CheckContext("jack_port_by_name");
1299 JackClient
* client
= (JackClient
*)ext_client
;
1300 if (client
== NULL
) {
1301 jack_error("jack_port_by_name called with a NULL client");
1305 if (portname
== NULL
) {
1306 jack_error("jack_port_by_name called with a NULL port name");
1310 JackGraphManager
* manager
= GetGraphManager();
1312 int res
= manager
->GetPort(portname
); // returns a port index at least > 1
1313 return (res
== NO_PORT
) ? NULL
: (jack_port_t
*)((uintptr_t)res
);
1319 LIB_EXPORT jack_port_t
* jack_port_by_id(jack_client_t
* ext_client
, jack_port_id_t id
)
1321 JackGlobals::CheckContext("jack_port_by_id");
1323 /* jack_port_t* type is actually the port index */
1324 return (jack_port_t
*)((uintptr_t)id
);
1327 LIB_EXPORT
int jack_engine_takeover_timebase(jack_client_t
* ext_client
)
1329 JackGlobals::CheckContext("jack_engine_takeover_timebase");
1331 JackClient
* client
= (JackClient
*)ext_client
;
1332 if (client
== NULL
) {
1333 jack_error("jack_engine_takeover_timebase called with a NULL client");
1336 jack_error("jack_engine_takeover_timebase: deprecated\n");
1341 LIB_EXPORT jack_nframes_t
jack_frames_since_cycle_start(const jack_client_t
* ext_client
)
1343 JackGlobals::CheckContext("jack_frames_since_cycle_start");
1346 JackEngineControl
* control
= GetEngineControl();
1348 control
->ReadFrameTime(&timer
);
1349 return timer
.FramesSinceCycleStart(GetMicroSeconds(), control
->fSampleRate
);
1355 LIB_EXPORT jack_time_t
jack_get_time()
1357 JackGlobals::CheckContext("jack_get_time");
1359 return GetMicroSeconds();
1362 LIB_EXPORT jack_time_t
jack_frames_to_time(const jack_client_t
* ext_client
, jack_nframes_t frames
)
1364 JackGlobals::CheckContext("jack_frames_to_time");
1366 JackClient
* client
= (JackClient
*)ext_client
;
1367 if (client
== NULL
) {
1368 jack_error("jack_frames_to_time called with a NULL client");
1372 JackEngineControl
* control
= GetEngineControl();
1374 control
->ReadFrameTime(&timer
);
1375 return timer
.Frames2Time(frames
, control
->fBufferSize
);
1382 LIB_EXPORT jack_nframes_t
jack_time_to_frames(const jack_client_t
* ext_client
, jack_time_t usecs
)
1384 JackGlobals::CheckContext("jack_time_to_frames");
1386 JackClient
* client
= (JackClient
*)ext_client
;
1387 if (client
== NULL
) {
1388 jack_error("jack_time_to_frames called with a NULL client");
1392 JackEngineControl
* control
= GetEngineControl();
1394 control
->ReadFrameTime(&timer
);
1395 return timer
.Time2Frames(usecs
, control
->fBufferSize
);
1402 LIB_EXPORT jack_nframes_t
jack_frame_time(const jack_client_t
* ext_client
)
1404 JackGlobals::CheckContext("jack_frame_time");
1406 return jack_time_to_frames(ext_client
, GetMicroSeconds());
1409 LIB_EXPORT jack_nframes_t
jack_last_frame_time(const jack_client_t
* ext_client
)
1411 JackGlobals::CheckContext("jack_last_frame_time");
1413 JackEngineControl
* control
= GetEngineControl();
1414 return (control
) ? control
->fFrameTimer
.ReadCurrentState()->CurFrame() : 0;
1417 LIB_EXPORT
int jack_get_cycle_times(const jack_client_t
*client
,
1418 jack_nframes_t
*current_frames
,
1419 jack_time_t
*current_usecs
,
1420 jack_time_t
*next_usecs
,
1421 float *period_usecs
)
1423 JackGlobals::CheckContext("jack_get_cycle_times");
1425 JackEngineControl
* control
= GetEngineControl();
1428 control
->ReadFrameTime(&timer
);
1429 return timer
.GetCycleTimes(current_frames
, current_usecs
, next_usecs
, period_usecs
);
1435 LIB_EXPORT
float jack_cpu_load(jack_client_t
* ext_client
)
1437 JackGlobals::CheckContext("jack_cpu_load");
1439 JackClient
* client
= (JackClient
*)ext_client
;
1440 if (client
== NULL
) {
1441 jack_error("jack_cpu_load called with a NULL client");
1444 JackEngineControl
* control
= GetEngineControl();
1445 return (control
? control
->fCPULoad
: 0.0f
);
1449 LIB_EXPORT jack_native_thread_t
jack_client_thread_id(jack_client_t
* ext_client
)
1451 JackGlobals::CheckContext("jack_client_thread_id");
1453 JackClient
* client
= (JackClient
*)ext_client
;
1454 if (client
== NULL
) {
1455 jack_error("jack_client_thread_id called with a NULL client");
1456 return (jack_native_thread_t
)NULL
;
1458 return client
->GetThreadID();
1462 LIB_EXPORT
char* jack_get_client_name(jack_client_t
* ext_client
)
1464 JackGlobals::CheckContext("jack_get_client_name");
1466 JackClient
* client
= (JackClient
*)ext_client
;
1467 if (client
== NULL
) {
1468 jack_error("jack_get_client_name called with a NULL client");
1471 return client
->GetClientControl()->fName
;
1475 LIB_EXPORT
int jack_client_name_size(void)
1477 return JACK_CLIENT_NAME_SIZE
+1;
1480 LIB_EXPORT
int jack_port_name_size(void)
1482 return REAL_JACK_PORT_NAME_SIZE
+1;
1485 LIB_EXPORT
int jack_port_type_size(void)
1487 return JACK_PORT_TYPE_SIZE
;
1490 LIB_EXPORT
size_t jack_port_type_get_buffer_size(jack_client_t
* ext_client
, const char* port_type
)
1492 JackGlobals::CheckContext("jack_port_type_get_buffer_size");
1494 JackClient
* client
= (JackClient
*)ext_client
;
1495 if (client
== NULL
) {
1496 jack_error("jack_port_type_get_buffer_size called with a NULL client");
1499 jack_port_type_id_t port_id
= GetPortTypeId(port_type
);
1500 if (port_id
== PORT_TYPES_MAX
) {
1501 jack_error("jack_port_type_get_buffer_size called with an unknown port type = %s", port_type
);
1504 return GetPortType(port_id
)->size();
1510 LIB_EXPORT
int jack_release_timebase(jack_client_t
* ext_client
)
1512 JackGlobals::CheckContext("jack_release_timebase");
1514 JackClient
* client
= (JackClient
*)ext_client
;
1515 if (client
== NULL
) {
1516 jack_error("jack_release_timebase called with a NULL client");
1519 return client
->ReleaseTimebase();
1523 LIB_EXPORT
int jack_set_sync_callback(jack_client_t
* ext_client
, JackSyncCallback sync_callback
, void *arg
)
1525 JackGlobals::CheckContext("jack_set_sync_callback");
1527 JackClient
* client
= (JackClient
*)ext_client
;
1528 if (client
== NULL
) {
1529 jack_error("jack_set_sync_callback called with a NULL client");
1532 return client
->SetSyncCallback(sync_callback
, arg
);
1536 LIB_EXPORT
int jack_set_sync_timeout(jack_client_t
* ext_client
, jack_time_t timeout
)
1538 JackGlobals::CheckContext("jack_set_sync_timeout");
1540 JackClient
* client
= (JackClient
*)ext_client
;
1541 if (client
== NULL
) {
1542 jack_error("jack_set_sync_timeout called with a NULL client");
1545 return client
->SetSyncTimeout(timeout
);
1549 LIB_EXPORT
int jack_set_timebase_callback(jack_client_t
* ext_client
, int conditional
, JackTimebaseCallback timebase_callback
, void* arg
)
1551 JackGlobals::CheckContext("jack_set_timebase_callback");
1553 JackClient
* client
= (JackClient
*)ext_client
;
1554 if (client
== NULL
) {
1555 jack_error("jack_set_timebase_callback called with a NULL client");
1558 return client
->SetTimebaseCallback(conditional
, timebase_callback
, arg
);
1562 LIB_EXPORT
int jack_transport_locate(jack_client_t
* ext_client
, jack_nframes_t frame
)
1564 JackGlobals::CheckContext("jack_transport_locate");
1566 JackClient
* client
= (JackClient
*)ext_client
;
1567 if (client
== NULL
) {
1568 jack_error("jack_transport_locate called with a NULL client");
1571 client
->TransportLocate(frame
);
1576 LIB_EXPORT jack_transport_state_t
jack_transport_query(const jack_client_t
* ext_client
, jack_position_t
* pos
)
1578 JackGlobals::CheckContext("jack_transport_query");
1580 JackClient
* client
= (JackClient
*)ext_client
;
1581 if (client
== NULL
) {
1582 jack_error("jack_transport_query called with a NULL client");
1583 return JackTransportStopped
;
1585 return client
->TransportQuery(pos
);
1589 LIB_EXPORT jack_nframes_t
jack_get_current_transport_frame(const jack_client_t
* ext_client
)
1591 JackGlobals::CheckContext("jack_get_current_transport_frame");
1593 JackClient
* client
= (JackClient
*)ext_client
;
1594 if (client
== NULL
) {
1595 jack_error("jack_get_current_transport_frame called with a NULL client");
1598 return client
->GetCurrentTransportFrame();
1602 LIB_EXPORT
int jack_transport_reposition(jack_client_t
* ext_client
, const jack_position_t
* pos
)
1604 JackGlobals::CheckContext("jack_transport_reposition");
1606 JackClient
* client
= (JackClient
*)ext_client
;
1607 if (client
== NULL
) {
1608 jack_error("jack_transport_reposition called with a NULL client");
1611 client
->TransportReposition(pos
);
1616 LIB_EXPORT
void jack_transport_start(jack_client_t
* ext_client
)
1618 JackGlobals::CheckContext("jack_transport_start");
1620 JackClient
* client
= (JackClient
*)ext_client
;
1621 if (client
== NULL
) {
1622 jack_error("jack_transport_start called with a NULL client");
1624 client
->TransportStart();
1628 LIB_EXPORT
void jack_transport_stop(jack_client_t
* ext_client
)
1630 JackGlobals::CheckContext("jack_transport_stop");
1632 JackClient
* client
= (JackClient
*)ext_client
;
1633 if (client
== NULL
) {
1634 jack_error("jack_transport_stop called with a NULL client");
1636 client
->TransportStop();
1641 LIB_EXPORT
void jack_get_transport_info(jack_client_t
* ext_client
, jack_transport_info_t
* tinfo
)
1643 JackGlobals::CheckContext("jack_get_transport_info");
1645 jack_error("jack_get_transport_info: deprecated");
1647 memset(tinfo
, 0, sizeof(jack_transport_info_t
));
1650 LIB_EXPORT
void jack_set_transport_info(jack_client_t
* ext_client
, jack_transport_info_t
* tinfo
)
1652 JackGlobals::CheckContext("jack_set_transport_info");
1654 jack_error("jack_set_transport_info: deprecated");
1656 memset(tinfo
, 0, sizeof(jack_transport_info_t
));
1660 LIB_EXPORT
float jack_get_max_delayed_usecs(jack_client_t
* ext_client
)
1662 JackGlobals::CheckContext("jack_get_max_delayed_usecs");
1664 JackClient
* client
= (JackClient
*)ext_client
;
1665 if (client
== NULL
) {
1666 jack_error("jack_get_max_delayed_usecs called with a NULL client");
1669 JackEngineControl
* control
= GetEngineControl();
1670 return (control
? control
->fMaxDelayedUsecs
: 0.f
);
1674 LIB_EXPORT
float jack_get_xrun_delayed_usecs(jack_client_t
* ext_client
)
1676 JackGlobals::CheckContext("jack_get_xrun_delayed_usecs");
1678 JackClient
* client
= (JackClient
*)ext_client
;
1679 if (client
== NULL
) {
1680 jack_error("jack_get_xrun_delayed_usecs called with a NULL client");
1683 JackEngineControl
* control
= GetEngineControl();
1684 return (control
? control
->fXrunDelayedUsecs
: 0.f
);
1688 LIB_EXPORT
void jack_reset_max_delayed_usecs(jack_client_t
* ext_client
)
1690 JackGlobals::CheckContext("jack_reset_max_delayed_usecs");
1692 JackClient
* client
= (JackClient
*)ext_client
;
1693 if (client
== NULL
) {
1694 jack_error("jack_reset_max_delayed_usecs called with a NULL client");
1696 JackEngineControl
* control
= GetEngineControl();
1697 control
->ResetXRun();
1702 LIB_EXPORT
int jack_client_real_time_priority(jack_client_t
* ext_client
)
1704 JackGlobals::CheckContext("jack_client_real_time_priority");
1706 JackClient
* client
= (JackClient
*)ext_client
;
1707 if (client
== NULL
) {
1708 jack_error("jack_client_real_time_priority called with a NULL client");
1711 JackEngineControl
* control
= GetEngineControl();
1712 return (control
->fRealTime
) ? control
->fClientPriority
: -1;
1716 LIB_EXPORT
int jack_client_max_real_time_priority(jack_client_t
* ext_client
)
1718 JackGlobals::CheckContext("jack_client_max_real_time_priority");
1720 JackClient
* client
= (JackClient
*)ext_client
;
1721 if (client
== NULL
) {
1722 jack_error("jack_client_max_real_time_priority called with a NULL client");
1725 JackEngineControl
* control
= GetEngineControl();
1726 return (control
->fRealTime
) ? control
->fMaxClientPriority
: -1;
1730 LIB_EXPORT
int jack_acquire_real_time_scheduling(jack_native_thread_t thread
, int priority
)
1732 JackEngineControl
* control
= GetEngineControl();
1734 ? JackThread::AcquireRealTimeImp(thread
, priority
, control
->fPeriod
, control
->fComputation
, control
->fConstraint
)
1738 LIB_EXPORT
int jack_client_create_thread(jack_client_t
* client
,
1739 jack_native_thread_t
*thread
,
1741 int realtime
, /* boolean */
1742 thread_routine routine
,
1745 JackGlobals::CheckContext("jack_client_create_thread");
1747 JackEngineControl
* control
= GetEngineControl();
1748 int res
= JackThread::StartImp(thread
, priority
, realtime
, routine
, arg
);
1750 ? ((realtime
? JackThread::AcquireRealTimeImp(*thread
, priority
, control
->fPeriod
, control
->fComputation
, control
->fConstraint
) : res
))
1754 LIB_EXPORT
int jack_drop_real_time_scheduling(jack_native_thread_t thread
)
1756 return JackThread::DropRealTimeImp(thread
);
1759 LIB_EXPORT
int jack_client_stop_thread(jack_client_t
* client
, jack_native_thread_t thread
)
1761 JackGlobals::CheckContext("jack_client_stop_thread");
1762 return JackThread::StopImp(thread
);
1765 LIB_EXPORT
int jack_client_kill_thread(jack_client_t
* client
, jack_native_thread_t thread
)
1767 JackGlobals::CheckContext("jack_client_kill_thread");
1768 return JackThread::KillImp(thread
);
1772 LIB_EXPORT
void jack_set_thread_creator (jack_thread_creator_t jtc
)
1775 JackGlobals::fJackThreadCreator
= pthread_create
;
1777 JackGlobals::fJackThreadCreator
= jtc
;
1783 LIB_EXPORT
int jack_internal_client_new (const char* client_name
,
1784 const char* load_name
,
1785 const char* load_init
)
1787 JackGlobals::CheckContext("jack_internal_client_new");
1788 jack_error("jack_internal_client_new: deprecated");
1792 LIB_EXPORT
void jack_internal_client_close (const char* client_name
)
1794 JackGlobals::CheckContext("jack_internal_client_close");
1795 jack_error("jack_internal_client_close: deprecated");
1798 LIB_EXPORT
char* jack_get_internal_client_name(jack_client_t
* ext_client
, jack_intclient_t intclient
)
1800 JackGlobals::CheckContext("jack_get_internal_client_name");
1802 JackClient
* client
= (JackClient
*)ext_client
;
1803 if (client
== NULL
) {
1804 jack_error("jack_get_internal_client_name called with a NULL client");
1806 } else if (intclient
>= CLIENT_NUM
) {
1807 jack_error("jack_get_internal_client_name: incorrect client");
1810 return client
->GetInternalClientName(intclient
);
1814 LIB_EXPORT jack_intclient_t
jack_internal_client_handle(jack_client_t
* ext_client
, const char* client_name
, jack_status_t
* status
)
1816 JackGlobals::CheckContext("jack_internal_client_handle");
1818 JackClient
* client
= (JackClient
*)ext_client
;
1819 if (client
== NULL
) {
1820 jack_error("jack_internal_client_handle called with a NULL client");
1823 jack_status_t my_status
;
1824 if (status
== NULL
) /* no status from caller? */
1825 status
= &my_status
; /* use local status word */
1826 *status
= (jack_status_t
)0;
1827 return client
->InternalClientHandle(client_name
, status
);
1831 static 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
)
1833 JackGlobals::CheckContext("jack_internal_client_load_aux");
1835 JackClient
* client
= (JackClient
*)ext_client
;
1836 if (client
== NULL
) {
1837 jack_error("jack_internal_client_load called with a NULL client");
1841 jack_status_t my_status
;
1843 if (status
== NULL
) /* no status from caller? */
1844 status
= &my_status
; /* use local status word */
1845 *status
= (jack_status_t
)0;
1847 /* validate parameters */
1848 if ((options
& ~JackLoadOptions
)) {
1849 int my_status1
= *status
| (JackFailure
| JackInvalidOption
);
1850 *status
= (jack_status_t
)my_status1
;
1854 /* parse variable arguments */
1855 jack_varargs_parse(options
, ap
, &va
);
1856 return client
->InternalClientLoad(client_name
, options
, status
, &va
);
1860 LIB_EXPORT jack_intclient_t
jack_internal_client_load(jack_client_t
*client
, const char* client_name
, jack_options_t options
, jack_status_t
*status
, ...)
1862 JackGlobals::CheckContext("jack_internal_client_load");
1865 va_start(ap
, status
);
1866 jack_intclient_t res
= jack_internal_client_load_aux(client
, client_name
, options
, status
, ap
);
1871 LIB_EXPORT jack_status_t
jack_internal_client_unload(jack_client_t
* ext_client
, jack_intclient_t intclient
)
1873 JackGlobals::CheckContext("jack_internal_client_load");
1875 JackClient
* client
= (JackClient
*)ext_client
;
1876 if (client
== NULL
) {
1877 jack_error("jack_internal_client_unload called with a NULL client");
1878 return (jack_status_t
)(JackNoSuchClient
| JackFailure
);
1879 } else if (intclient
>= CLIENT_NUM
) {
1880 jack_error("jack_internal_client_unload: incorrect client");
1881 return (jack_status_t
)(JackNoSuchClient
| JackFailure
);
1883 jack_status_t my_status
;
1884 client
->InternalClientUnload(intclient
, &my_status
);
1889 LIB_EXPORT
void jack_get_version(int *major_ptr
,
1894 JackGlobals::CheckContext("jack_get_version");
1896 // FIXME: We need these coming from build system
1903 LIB_EXPORT
const char* jack_get_version_string()
1905 JackGlobals::CheckContext("jack_get_version_string");
1909 LIB_EXPORT
void jack_free(void* ptr
)
1911 JackGlobals::CheckContext("jack_free");
1919 LIB_EXPORT
int jack_set_session_callback(jack_client_t
* ext_client
, JackSessionCallback session_callback
, void* arg
)
1921 JackGlobals::CheckContext("jack_set_session_callback");
1923 JackClient
* client
= (JackClient
*)ext_client
;
1924 jack_log("jack_set_session_callback ext_client %x client %x ", ext_client
, client
);
1925 if (client
== NULL
) {
1926 jack_error("jack_set_session_callback called with a NULL client");
1929 return client
->SetSessionCallback(session_callback
, arg
);
1933 LIB_EXPORT jack_session_command_t
* jack_session_notify(jack_client_t
* ext_client
, const char* target
, jack_session_event_type_t ev_type
, const char* path
)
1935 JackGlobals::CheckContext("jack_session_notify");
1937 JackClient
* client
= (JackClient
*)ext_client
;
1938 jack_log("jack_session_notify ext_client %x client %x ", ext_client
, client
);
1939 if (client
== NULL
) {
1940 jack_error("jack_session_notify called with a NULL client");
1943 return client
->SessionNotify(target
, ev_type
, path
);
1947 LIB_EXPORT
int jack_session_reply(jack_client_t
* ext_client
, jack_session_event_t
*event
)
1949 JackGlobals::CheckContext("jack_session_reply");
1951 JackClient
* client
= (JackClient
*)ext_client
;
1952 jack_log("jack_session_reply ext_client %x client %x ", ext_client
, client
);
1953 if (client
== NULL
) {
1954 jack_error("jack_session_reply called with a NULL client");
1957 return client
->SessionReply(event
);
1961 LIB_EXPORT
void jack_session_event_free(jack_session_event_t
* ev
)
1963 JackGlobals::CheckContext("jack_session_event_free");
1966 if (ev
->session_dir
)
1967 free((void *)ev
->session_dir
);
1968 if (ev
->client_uuid
)
1969 free((void *)ev
->client_uuid
);
1970 if (ev
->command_line
)
1971 free(ev
->command_line
);
1976 LIB_EXPORT
char *jack_client_get_uuid(jack_client_t
* ext_client
)
1978 JackGlobals::CheckContext("jack_client_get_uuid");
1980 JackClient
* client
= (JackClient
*)ext_client
;
1981 if (client
== NULL
) {
1982 jack_error("jack_client_get_uuid called with a NULL client");
1985 char retval
[JACK_UUID_STRING_SIZE
];
1986 jack_uuid_unparse(client
->GetClientControl()->fSessionID
, retval
);
1987 return strdup(retval
);
1991 LIB_EXPORT
char* jack_get_uuid_for_client_name(jack_client_t
* ext_client
, const char* client_name
)
1993 JackGlobals::CheckContext("jack_get_uuid_for_client_name");
1995 JackClient
* client
= (JackClient
*)ext_client
;
1996 jack_log("jack_get_uuid_for_client_name ext_client %x client %x ", ext_client
, client
);
1997 if (client
== NULL
) {
1998 jack_error("jack_get_uuid_for_client_name called with a NULL client");
2001 return client
->GetUUIDForClientName(client_name
);
2005 LIB_EXPORT
char* jack_get_client_name_by_uuid(jack_client_t
* ext_client
, const char* client_uuid
)
2007 JackGlobals::CheckContext("jack_get_client_name_by_uuid");
2009 JackClient
* client
= (JackClient
*)ext_client
;
2010 jack_log("jack_get_uuid_for_client_name ext_client %x client %x ", ext_client
, client
);
2011 if (client
== NULL
) {
2012 jack_error("jack_get_client_name_by_uuid called with a NULL client");
2015 return client
->GetClientNameByUUID(client_uuid
);
2019 LIB_EXPORT
int jack_reserve_client_name(jack_client_t
* ext_client
, const char* client_name
, const char* uuid
)
2021 JackGlobals::CheckContext("jack_reserve_client_name");
2023 JackClient
* client
= (JackClient
*)ext_client
;
2024 jack_log("jack_reserve_client_name ext_client %x client %x ", ext_client
, client
);
2025 if (client
== NULL
) {
2026 jack_error("jack_reserve_client_name called with a NULL client");
2029 return client
->ReserveClientName(client_name
, uuid
);
2033 LIB_EXPORT
void jack_session_commands_free(jack_session_command_t
*cmds
)
2035 JackGlobals::CheckContext("jack_session_commands_free");
2044 if (cmds
[i
].client_name
) {
2045 free ((char *)cmds
[i
].client_name
);
2047 if (cmds
[i
].command
) {
2048 free ((char *)cmds
[i
].command
);
2051 free ((char *)cmds
[i
].uuid
);
2062 LIB_EXPORT
int jack_client_has_session_callback(jack_client_t
* ext_client
, const char* client_name
)
2064 JackGlobals::CheckContext("jack_client_has_session_callback");
2066 JackClient
* client
= (JackClient
*)ext_client
;
2067 jack_log("jack_client_has_session_callback ext_client %x client %x ", ext_client
, client
);
2068 if (client
== NULL
) {
2069 jack_error("jack_client_has_session_callback called with a NULL client");
2072 return client
->ClientHasSessionCallback(client_name
);
2076 LIB_EXPORT jack_uuid_t
jack_client_uuid_generate()
2078 static uint32_t uuid_cnt
= 0;
2079 jack_uuid_t uuid
= 0x2; /* JackUUIDClient */;
2080 uuid
= (uuid
<< 32) | ++uuid_cnt
;
2084 LIB_EXPORT jack_uuid_t
jack_port_uuid_generate(uint32_t port_id
)
2086 jack_uuid_t uuid
= 0x1; /* JackUUIDPort */
2087 uuid
= (uuid
<< 32) | (port_id
+ 1);
2091 LIB_EXPORT
uint32_t jack_uuid_to_index(jack_uuid_t u
)
2093 return (u
& 0xffff) - 1;
2096 LIB_EXPORT
int jack_uuid_compare(jack_uuid_t a
, jack_uuid_t b
)
2109 LIB_EXPORT
void jack_uuid_copy(jack_uuid_t
* dst
, jack_uuid_t src
)
2114 LIB_EXPORT
void jack_uuid_clear(jack_uuid_t
* u
)
2116 *u
= JACK_UUID_EMPTY_INITIALIZER
;
2119 LIB_EXPORT
int jack_uuid_parse(const char* b
, jack_uuid_t
* u
)
2121 if (sscanf (b
, "%" PRIu64
, u
) == 1) {
2123 if (*u
< (0x1LL
<< 32)) {
2124 /* has not type bits set - not legal */
2134 LIB_EXPORT
void jack_uuid_unparse(jack_uuid_t u
, char b
[JACK_UUID_STRING_SIZE
])
2136 snprintf (b
, JACK_UUID_STRING_SIZE
, "%" PRIu64
, u
);
2139 LIB_EXPORT
int jack_uuid_empty(jack_uuid_t u
)
2141 return u
== JACK_UUID_EMPTY_INITIALIZER
;