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"
31 #ifdef __CLIENTDEBUG__
32 #include "JackLibGlobals.h"
42 typedef void (*print_function)(
const char*);
43 typedef void *(*thread_routine)(
void*);
55 jack_get_version_string();
57 jack_client_t * jack_client_new_aux(
const char* client_name,
58 jack_options_t options,
59 jack_status_t *status);
61 LIB_EXPORT jack_client_t * jack_client_open(
const char* client_name,
62 jack_options_t options,
63 jack_status_t *status, ...);
64 LIB_EXPORT jack_client_t * jack_client_new(
const char* client_name);
65 LIB_EXPORT
int jack_client_name_size(
void);
66 LIB_EXPORT
char* jack_get_client_name(jack_client_t *client);
67 LIB_EXPORT
int jack_internal_client_new(
const char* client_name,
68 const char* load_name,
69 const char* load_init);
70 LIB_EXPORT
void jack_internal_client_close(
const char* client_name);
71 LIB_EXPORT
int jack_is_realtime(jack_client_t *client);
73 JackShutdownCallback shutdown_callback,
void *arg);
75 JackInfoShutdownCallback shutdown_callback,
void *arg);
77 JackProcessCallback process_callback,
79 LIB_EXPORT jack_nframes_t
jack_thread_wait(jack_client_t *client,
int status);
87 JackThreadInitCallback thread_init_callback,
90 JackFreewheelCallback freewheel_callback,
95 JackBufferSizeCallback bufsize_callback,
98 JackSampleRateCallback srate_callback,
101 JackClientRegistrationCallback
102 registration_callback,
void *arg);
104 JackPortRegistrationCallback
105 registration_callback,
void *arg);
107 JackPortConnectCallback
108 connect_callback,
void *arg);
110 JackPortRenameCallback
111 rename_callback,
void *arg);
113 JackGraphOrderCallback graph_callback,
116 JackXRunCallback xrun_callback,
void *arg);
117 LIB_EXPORT
int jack_set_latency_callback(jack_client_t *client,
118 JackLatencyCallback latency_callback,
void *arg);
120 LIB_EXPORT
int jack_activate(jack_client_t *client);
121 LIB_EXPORT
int jack_deactivate(jack_client_t *client);
123 const char* port_name,
124 const char* port_type,
126 unsigned long buffer_size);
134 LIB_EXPORT
int jack_port_is_mine(
const jack_client_t *,
const jack_port_t *port);
137 const char* port_name);
140 const jack_port_t *port);
141 LIB_EXPORT
int jack_port_tie(jack_port_t *src, jack_port_t *dst);
162 const char* port_name,
int onoff);
166 const char* source_port,
167 const char* destination_port);
169 const char* source_port,
170 const char* destination_port);
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);
183 jack_port_id_t port_id);
187 LIB_EXPORT jack_nframes_t
jack_time_to_frames(
const jack_client_t *client, jack_time_t time);
188 LIB_EXPORT jack_time_t
jack_frames_to_time(
const jack_client_t *client, jack_nframes_t frames);
192 LIB_EXPORT jack_native_thread_t jack_client_thread_id(jack_client_t *);
196 LIB_EXPORT
float jack_get_max_delayed_usecs(jack_client_t *client);
197 LIB_EXPORT
float jack_get_xrun_delayed_usecs(jack_client_t *client);
198 LIB_EXPORT
void jack_reset_max_delayed_usecs(jack_client_t *client);
202 JackSyncCallback sync_callback,
205 jack_time_t timeout);
208 JackTimebaseCallback timebase_callback,
211 jack_nframes_t frame);
228 jack_native_thread_t *thread,
231 thread_routine routine,
240 LIB_EXPORT
char * jack_get_internal_client_name(jack_client_t *client,
241 jack_intclient_t intclient);
242 LIB_EXPORT jack_intclient_t jack_internal_client_handle(jack_client_t *client,
243 const char* client_name,
244 jack_status_t *status);
245 LIB_EXPORT jack_intclient_t jack_internal_client_load(jack_client_t *client,
246 const char* client_name,
247 jack_options_t options,
248 jack_status_t *status, ...);
249 LIB_EXPORT jack_intclient_t jack_internal_client_load_aux(jack_client_t *client,
250 const char* client_name,
251 jack_options_t options,
252 jack_status_t *status, va_list ap);
254 LIB_EXPORT jack_status_t jack_internal_client_unload(jack_client_t *client,
255 jack_intclient_t intclient);
256 LIB_EXPORT
void jack_free(
void* ptr);
273 static inline bool CheckPort(jack_port_id_t port_index)
275 return (port_index > 0 && port_index < PORT_NUM_MAX);
278 static inline bool CheckBufferSize(jack_nframes_t buffer_size)
280 return (buffer_size >= 1 && buffer_size <= BUFFER_SIZE_MAX);
283 static inline void WaitGraphChange()
290 if (jack_tls_get(JackGlobals::fRealTime) == NULL) {
295 if (manager->IsPendingChange()) {
297 JackSleep(
int(control->fPeriodUsecs * 1.1f));
312 LIB_EXPORT jack_client_t* jack_client_new(
const char* client_name)
314 #ifdef __CLIENTDEBUG__
315 JackGlobals::CheckContext(
"jack_client_new");
318 assert(JackGlobals::fOpenMutex);
319 JackGlobals::fOpenMutex->Lock();
321 int options = JackUseExactName;
322 if (getenv(
"JACK_START_SERVER") == NULL)
323 options |= JackNoStartServer;
324 jack_client_t* res = jack_client_new_aux(client_name, (jack_options_t)options, NULL);
325 JackGlobals::fOpenMutex->Unlock();
327 }
catch (std::bad_alloc& e) {
338 #ifdef __CLIENTDEBUG__
339 JackGlobals::CheckContext(
"jack_port_get_buffer");
341 uintptr_t port_aux = (uintptr_t)port;
342 jack_port_id_t myport = (jack_port_id_t)port_aux;
343 if (!CheckPort(myport)) {
344 jack_error(
"jack_port_get_buffer called with an incorrect port %ld", myport);
348 return (manager ? manager->GetBuffer(myport, frames) : NULL);
354 #ifdef __CLIENTDEBUG__
355 JackGlobals::CheckContext(
"jack_port_name");
357 uintptr_t port_aux = (uintptr_t)port;
358 jack_port_id_t myport = (jack_port_id_t)port_aux;
359 if (!CheckPort(myport)) {
360 jack_error(
"jack_port_name called with an incorrect port %ld", myport);
364 return (manager ? manager->GetPort(myport)->GetName() : NULL);
370 #ifdef __CLIENTDEBUG__
371 JackGlobals::CheckContext(
"jack_port_short_name");
373 uintptr_t port_aux = (uintptr_t)port;
374 jack_port_id_t myport = (jack_port_id_t)port_aux;
375 if (!CheckPort(myport)) {
376 jack_error(
"jack_port_short_name called with an incorrect port %ld", myport);
380 return (manager ? manager->GetPort(myport)->GetShortName() : NULL);
386 #ifdef __CLIENTDEBUG__
387 JackGlobals::CheckContext(
"jack_port_flags");
389 uintptr_t port_aux = (uintptr_t)port;
390 jack_port_id_t myport = (jack_port_id_t)port_aux;
391 if (!CheckPort(myport)) {
392 jack_error(
"jack_port_flags called with an incorrect port %ld", myport);
396 return (manager ? manager->GetPort(myport)->GetFlags() : -1);
402 #ifdef __CLIENTDEBUG__
403 JackGlobals::CheckContext(
"jack_port_type");
405 uintptr_t port_aux = (uintptr_t)port;
406 jack_port_id_t myport = (jack_port_id_t)port_aux;
407 if (!CheckPort(myport)) {
408 jack_error(
"jack_port_flags called an incorrect port %ld", myport);
412 return (manager ? manager->GetPort(myport)->GetType() : NULL);
418 #ifdef __CLIENTDEBUG__
419 JackGlobals::CheckContext(
"jack_port_type_id");
421 uintptr_t port_aux = (uintptr_t)port;
422 jack_port_id_t myport = (jack_port_id_t)port_aux;
423 if (!CheckPort(myport)) {
424 jack_error(
"jack_port_type_id called an incorrect port %ld", myport);
428 return (manager ? GetPortTypeId(manager->GetPort(myport)->GetType()) : 0);
434 #ifdef __CLIENTDEBUG__
435 JackGlobals::CheckContext(
"jack_port_connected");
437 uintptr_t port_aux = (uintptr_t)port;
438 jack_port_id_t myport = (jack_port_id_t)port_aux;
439 if (!CheckPort(myport)) {
440 jack_error(
"jack_port_connected called with an incorrect port %ld", myport);
445 return (manager ? manager->GetConnectionsNum(myport) : -1);
451 #ifdef __CLIENTDEBUG__
452 JackGlobals::CheckContext(
"jack_port_connected_to");
454 uintptr_t port_aux = (uintptr_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");
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);
477 #ifdef __CLIENTDEBUG__
478 JackGlobals::CheckContext(
"jack_port_tie");
480 uintptr_t src_aux = (uintptr_t)src;
481 jack_port_id_t mysrc = (jack_port_id_t)src_aux;
482 if (!CheckPort(mysrc)) {
483 jack_error(
"jack_port_tie called with a NULL src port");
486 uintptr_t dst_aux = (uintptr_t)dst;
487 jack_port_id_t mydst = (jack_port_id_t)dst_aux;
488 if (!CheckPort(mydst)) {
489 jack_error(
"jack_port_tie called with a NULL dst port");
493 if (manager && manager->GetPort(mysrc)->GetRefNum() != manager->GetPort(mydst)->GetRefNum()) {
494 jack_error(
"jack_port_tie called with ports not belonging to the same client");
497 return manager->GetPort(mydst)->Tie(mysrc);
503 #ifdef __CLIENTDEBUG__
504 JackGlobals::CheckContext(
"jack_port_untie");
506 uintptr_t port_aux = (uintptr_t)port;
507 jack_port_id_t myport = (jack_port_id_t)port_aux;
508 if (!CheckPort(myport)) {
509 jack_error(
"jack_port_untie called with an incorrect port %ld", myport);
513 return (manager ? manager->GetPort(myport)->UnTie() : -1);
519 #ifdef __CLIENTDEBUG__
520 JackGlobals::CheckContext(
"jack_port_get_latency");
522 uintptr_t port_aux = (uintptr_t)port;
523 jack_port_id_t myport = (jack_port_id_t)port_aux;
524 if (!CheckPort(myport)) {
525 jack_error(
"jack_port_get_latency called with an incorrect port %ld", myport);
530 return (manager ? manager->GetPort(myport)->GetLatency() : 0);
536 #ifdef __CLIENTDEBUG__
537 JackGlobals::CheckContext(
"jack_port_set_latency");
539 uintptr_t port_aux = (uintptr_t)port;
540 jack_port_id_t myport = (jack_port_id_t)port_aux;
541 if (!CheckPort(myport)) {
542 jack_error(
"jack_port_set_latency called with an incorrect port %ld", myport);
546 manager->GetPort(myport)->SetLatency(frames);
552 #ifdef __CLIENTDEBUG__
553 JackGlobals::CheckContext(
"jack_port_get_latency_range");
555 uintptr_t port_aux = (uintptr_t)port;
556 jack_port_id_t myport = (jack_port_id_t)port_aux;
557 if (!CheckPort(myport)) {
558 jack_error(
"jack_port_get_latency_range called with an incorrect port %ld", myport);
563 manager->GetPort(myport)->GetLatencyRange(mode, range);
569 #ifdef __CLIENTDEBUG__
570 JackGlobals::CheckContext(
"jack_port_set_latency_range");
572 uintptr_t port_aux = (uintptr_t)port;
573 jack_port_id_t myport = (jack_port_id_t)port_aux;
574 if (!CheckPort(myport)) {
575 jack_error(
"jack_port_set_latency_range called with an incorrect port %ld", myport);
580 manager->GetPort(myport)->SetLatencyRange(mode, range);
586 #ifdef __CLIENTDEBUG__
587 JackGlobals::CheckContext(
"jack_recompute_total_latency");
591 uintptr_t port_aux = (uintptr_t)port;
592 jack_port_id_t myport = (jack_port_id_t)port_aux;
593 if (client == NULL) {
594 jack_error(
"jack_recompute_total_latency called with a NULL client");
596 }
else if (!CheckPort(myport)) {
597 jack_error(
"jack_recompute_total_latency called with a NULL port");
602 return (manager ? manager->ComputeTotalLatency(myport) : -1);
608 #ifdef __CLIENTDEBUG__
609 JackGlobals::CheckContext(
"jack_recompute_total_latencies");
613 if (client == NULL) {
614 jack_error(
"jack_recompute_total_latencies called with a NULL client");
617 return client->ComputeTotalLatencies();
623 #ifdef __CLIENTDEBUG__
624 JackGlobals::CheckContext(
"jack_port_set_name");
626 uintptr_t port_aux = (uintptr_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");
636 for (
int i = 0; i < CLIENT_NUM; i++) {
638 if ((client = JackGlobals::fClientTable[i])) {
642 return (client) ? client->PortRename(myport, name) : -1;
648 #ifdef __CLIENTDEBUG__
649 JackGlobals::CheckContext(
"jack_port_set_alias");
651 uintptr_t port_aux = (uintptr_t)port;
652 jack_port_id_t myport = (jack_port_id_t)port_aux;
653 if (!CheckPort(myport)) {
654 jack_error(
"jack_port_set_alias called with an incorrect port %ld", myport);
656 }
else if (name == NULL) {
657 jack_error(
"jack_port_set_alias called with a NULL port name");
661 return (manager ? manager->GetPort(myport)->SetAlias(name) : -1);
667 #ifdef __CLIENTDEBUG__
668 JackGlobals::CheckContext(
"jack_port_unset_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_unset_alias called with an incorrect port %ld", myport);
675 }
else if (name == NULL) {
676 jack_error(
"jack_port_unset_alias called with a NULL port name");
680 return (manager ? manager->GetPort(myport)->UnsetAlias(name) : -1);
686 #ifdef __CLIENTDEBUG__
687 JackGlobals::CheckContext(
"jack_port_get_aliases");
689 uintptr_t port_aux = (uintptr_t)port;
690 jack_port_id_t myport = (jack_port_id_t)port_aux;
691 if (!CheckPort(myport)) {
692 jack_error(
"jack_port_get_aliases called with an incorrect port %ld", myport);
696 return (manager ? manager->GetPort(myport)->GetAliases(aliases) : -1);
702 #ifdef __CLIENTDEBUG__
703 JackGlobals::CheckContext(
"jack_port_request_monitor");
705 uintptr_t port_aux = (uintptr_t)port;
706 jack_port_id_t myport = (jack_port_id_t)port_aux;
707 if (!CheckPort(myport)) {
708 jack_error(
"jack_port_request_monitor called with an incorrect port %ld", myport);
718 #ifdef __CLIENTDEBUG__
719 JackGlobals::CheckContext(
"jack_port_request_monitor_by_name");
722 if (client == NULL) {
723 jack_error(
"jack_port_request_monitor_by_name called with a NULL client");
729 jack_port_id_t myport = manager->GetPort(port_name);
730 if (!CheckPort(myport)) {
731 jack_error(
"jack_port_request_monitor_by_name called with an incorrect port %s", port_name);
741 #ifdef __CLIENTDEBUG__
742 JackGlobals::CheckContext(
"jack_port_ensure_monitor");
744 uintptr_t port_aux = (uintptr_t)port;
745 jack_port_id_t myport = (jack_port_id_t)port_aux;
746 if (!CheckPort(myport)) {
747 jack_error(
"jack_port_ensure_monitor called with an incorrect port %ld", myport);
751 return (manager ? manager->GetPort(myport)->
EnsureMonitor(onoff) : -1);
757 #ifdef __CLIENTDEBUG__
758 JackGlobals::CheckContext(
"jack_port_monitoring_input");
760 uintptr_t port_aux = (uintptr_t)port;
761 jack_port_id_t myport = (jack_port_id_t)port_aux;
762 if (!CheckPort(myport)) {
763 jack_error(
"jack_port_monitoring_input called with an incorrect port %ld", myport);
767 return (manager ? manager->GetPort(myport)->MonitoringInput() : -1);
771 LIB_EXPORT
int jack_is_realtime(jack_client_t* ext_client)
773 #ifdef __CLIENTDEBUG__
774 JackGlobals::CheckContext(
"jack_is_realtime");
777 if (client == NULL) {
778 jack_error(
"jack_is_realtime called with a NULL client");
782 return (control ? control->fRealTime : -1);
786 LIB_EXPORT
void jack_on_shutdown(jack_client_t* ext_client, JackShutdownCallback callback,
void* arg)
788 #ifdef __CLIENTDEBUG__
789 JackGlobals::CheckContext(
"jack_on_shutdown");
792 if (client == NULL) {
793 jack_error(
"jack_on_shutdown called with a NULL client");
795 client->OnShutdown(callback, arg);
801 #ifdef __CLIENTDEBUG__
802 JackGlobals::CheckContext(
"jack_on_info_shutdown");
805 if (client == NULL) {
806 jack_error(
"jack_on_info_shutdown called with a NULL client");
808 client->OnInfoShutdown(callback, arg);
814 #ifdef __CLIENTDEBUG__
815 JackGlobals::CheckContext(
"jack_set_process_callback");
818 if (client == NULL) {
819 jack_error(
"jack_set_process_callback called with a NULL client");
822 return client->SetProcessCallback(callback, arg);
828 #ifdef __CLIENTDEBUG__
829 JackGlobals::CheckContext(
"jack_thread_wait");
832 if (client == NULL) {
833 jack_error(
"jack_thread_wait called with a NULL client");
836 jack_error(
"jack_thread_wait: deprecated, use jack_cycle_wait/jack_cycle_signal");
843 #ifdef __CLIENTDEBUG__
844 JackGlobals::CheckContext(
"jack_cycle_wait");
847 if (client == NULL) {
848 jack_error(
"jack_cycle_wait called with a NULL client");
851 return client->CycleWait();
857 #ifdef __CLIENTDEBUG__
858 JackGlobals::CheckContext(
"jack_cycle_signal");
861 if (client == NULL) {
862 jack_error(
"jack_cycle_signal called with a NULL client");
864 client->CycleSignal(status);
870 #ifdef __CLIENTDEBUG__
871 JackGlobals::CheckContext(
"jack_set_process_thread");
874 if (client == NULL) {
875 jack_error(
"jack_set_process_thread called with a NULL client");
878 return client->SetProcessThread(fun, arg);
884 #ifdef __CLIENTDEBUG__
885 JackGlobals::CheckContext(
"jack_set_freewheel_callback");
888 if (client == NULL) {
889 jack_error(
"jack_set_freewheel_callback called with a NULL client");
892 return client->SetFreewheelCallback(freewheel_callback, arg);
898 #ifdef __CLIENTDEBUG__
899 JackGlobals::CheckContext(
"jack_set_freewheel");
902 if (client == NULL) {
903 jack_error(
"jack_set_freewheel called with a NULL client");
906 return client->SetFreeWheel(onoff);
912 #ifdef __CLIENTDEBUG__
913 JackGlobals::CheckContext(
"jack_set_buffer_size");
916 if (client == NULL) {
917 jack_error(
"jack_set_buffer_size called with a NULL client");
919 }
else if (!CheckBufferSize(buffer_size)) {
922 return client->SetBufferSize(buffer_size);
928 #ifdef __CLIENTDEBUG__
929 JackGlobals::CheckContext(
"jack_set_buffer_size_callback");
932 if (client == NULL) {
933 jack_error(
"jack_set_buffer_size_callback called with a NULL client");
936 return client->SetBufferSizeCallback(bufsize_callback, arg);
942 #ifdef __CLIENTDEBUG__
943 JackGlobals::CheckContext(
"jack_set_sample_rate_callback");
946 if (client == NULL) {
947 jack_error(
"jack_set_sample_rate_callback called with a NULL client");
950 return client->SetSampleRateCallback(srate_callback, arg);
956 #ifdef __CLIENTDEBUG__
957 JackGlobals::CheckContext(
"jack_set_client_registration_callback");
960 if (client == NULL) {
961 jack_error(
"jack_set_client_registration_callback called with a NULL client");
964 return client->SetClientRegistrationCallback(registration_callback, arg);
970 #ifdef __CLIENTDEBUG__
971 JackGlobals::CheckContext(
"jack_set_port_registration_callback");
974 if (client == NULL) {
975 jack_error(
"jack_set_port_registration_callback called with a NULL client");
978 return client->SetPortRegistrationCallback(registration_callback, arg);
984 #ifdef __CLIENTDEBUG__
985 JackGlobals::CheckContext(
"jack_set_port_connect_callback");
988 if (client == NULL) {
989 jack_error(
"jack_set_port_connect_callback called with a NULL client");
992 return client->SetPortConnectCallback(portconnect_callback, arg);
998 #ifdef __CLIENTDEBUG__
999 JackGlobals::CheckContext(
"jack_set_port_rename_callback");
1002 if (client == NULL) {
1003 jack_error(
"jack_set_port_rename_callback called with a NULL client");
1006 return client->SetPortRenameCallback(rename_callback, arg);
1012 #ifdef __CLIENTDEBUG__
1013 JackGlobals::CheckContext(
"jack_set_graph_order_callback");
1016 jack_log(
"jack_set_graph_order_callback ext_client %x client %x ", ext_client, client);
1017 if (client == NULL) {
1018 jack_error(
"jack_set_graph_order_callback called with a NULL client");
1021 return client->SetGraphOrderCallback(graph_callback, arg);
1027 #ifdef __CLIENTDEBUG__
1028 JackGlobals::CheckContext(
"jack_set_xrun_callback");
1031 if (client == NULL) {
1032 jack_error(
"jack_set_xrun_callback called with a NULL client");
1035 return client->SetXRunCallback(xrun_callback, arg);
1039 LIB_EXPORT
int jack_set_latency_callback(jack_client_t* ext_client, JackLatencyCallback latency_callback,
void *arg)
1041 #ifdef __CLIENTDEBUG__
1042 JackGlobals::CheckContext(
"jack_set_latency_callback");
1045 if (client == NULL) {
1046 jack_error(
"jack_set_latency_callback called with a NULL client");
1049 return client->SetLatencyCallback(latency_callback, arg);
1055 #ifdef __CLIENTDEBUG__
1056 JackGlobals::CheckContext(
"jack_set_thread_init_callback");
1059 jack_log(
"jack_set_thread_init_callback ext_client %x client %x ", ext_client, client);
1060 if (client == NULL) {
1061 jack_error(
"jack_set_thread_init_callback called with a NULL client");
1064 return client->SetInitCallback(init_callback, arg);
1068 LIB_EXPORT
int jack_activate(jack_client_t* ext_client)
1070 #ifdef __CLIENTDEBUG__
1071 JackGlobals::CheckContext(
"jack_activate");
1074 if (client == NULL) {
1075 jack_error(
"jack_activate called with a NULL client");
1082 LIB_EXPORT
int jack_deactivate(jack_client_t* ext_client)
1084 #ifdef __CLIENTDEBUG__
1085 JackGlobals::CheckContext(
"jack_deactivate");
1088 if (client == NULL) {
1089 jack_error(
"jack_deactivate called with a NULL client");
1096 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)
1098 #ifdef __CLIENTDEBUG__
1099 JackGlobals::CheckContext(
"jack_port_register");
1102 if (client == NULL) {
1103 jack_error(
"jack_port_register called with a NULL client");
1105 }
else if ((port_name == NULL) || (port_type == NULL)) {
1106 jack_error(
"jack_port_register called with a NULL port name or a NULL port_type");
1109 return (jack_port_t *)((uintptr_t)client->PortRegister(port_name, port_type, flags, buffer_size));
1115 #ifdef __CLIENTDEBUG__
1116 JackGlobals::CheckContext(
"jack_port_unregister");
1119 if (client == NULL) {
1120 jack_error(
"jack_port_unregister called with a NULL client");
1123 uintptr_t port_aux = (uintptr_t)port;
1124 jack_port_id_t myport = (jack_port_id_t)port_aux;
1125 if (!CheckPort(myport)) {
1126 jack_error(
"jack_port_unregister called with an incorrect port %ld", myport);
1129 return client->PortUnRegister(myport);
1134 #ifdef __CLIENTDEBUG__
1135 JackGlobals::CheckContext(
"jack_port_is_mine");
1138 if (client == NULL) {
1139 jack_error(
"jack_port_is_mine called with a NULL client");
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_is_mine called with an incorrect port %ld", myport);
1148 return client->PortIsMine(myport);
1153 #ifdef __CLIENTDEBUG__
1154 JackGlobals::CheckContext(
"jack_port_get_connections");
1156 uintptr_t port_aux = (uintptr_t)port;
1157 jack_port_id_t myport = (jack_port_id_t)port_aux;
1158 if (!CheckPort(myport)) {
1159 jack_error(
"jack_port_get_connections called with an incorrect port %ld", myport);
1164 return (manager ? manager->GetConnections(myport) : NULL);
1171 #ifdef __CLIENTDEBUG__
1172 JackGlobals::CheckContext(
"jack_port_get_all_connections");
1175 if (client == NULL) {
1176 jack_error(
"jack_port_get_all_connections called with a NULL client");
1180 uintptr_t port_aux = (uintptr_t)port;
1181 jack_port_id_t myport = (jack_port_id_t)port_aux;
1182 if (!CheckPort(myport)) {
1183 jack_error(
"jack_port_get_all_connections called with an incorrect port %ld", myport);
1188 return (manager ? manager->GetConnections(myport) : NULL);
1194 #ifdef __CLIENTDEBUG__
1195 JackGlobals::CheckContext(
"jack_port_get_total_latency");
1198 if (client == NULL) {
1199 jack_error(
"jack_port_get_total_latency called with a NULL client");
1203 uintptr_t port_aux = (uintptr_t)port;
1204 jack_port_id_t myport = (jack_port_id_t)port_aux;
1205 if (!CheckPort(myport)) {
1206 jack_error(
"jack_port_get_total_latency called with an incorrect port %ld", myport);
1212 manager->ComputeTotalLatency(myport);
1213 return manager->GetPort(myport)->GetTotalLatency();
1220 LIB_EXPORT
int jack_connect(jack_client_t* ext_client,
const char* src,
const char* dst)
1222 #ifdef __CLIENTDEBUG__
1223 JackGlobals::CheckContext(
"jack_connect");
1226 if (client == NULL) {
1227 jack_error(
"jack_connect called with a NULL client");
1229 }
else if ((src == NULL) || (dst == NULL)) {
1230 jack_error(
"jack_connect called with a NULL port name");
1233 return client->PortConnect(src, dst);
1237 LIB_EXPORT
int jack_disconnect(jack_client_t* ext_client,
const char* src,
const char* dst)
1239 #ifdef __CLIENTDEBUG__
1240 JackGlobals::CheckContext(
"jack_disconnect");
1243 if (client == NULL) {
1244 jack_error(
"jack_disconnect called with a NULL client");
1246 }
else if ((src == NULL) || (dst == NULL)) {
1247 jack_error(
"jack_connect called with a NULL port name");
1250 return client->PortDisconnect(src, dst);
1256 #ifdef __CLIENTDEBUG__
1257 JackGlobals::CheckContext(
"jack_port_disconnect");
1260 if (client == NULL) {
1261 jack_error(
"jack_port_disconnect called with a NULL client");
1264 uintptr_t port_aux = (uintptr_t)src;
1265 jack_port_id_t myport = (jack_port_id_t)port_aux;
1266 if (!CheckPort(myport)) {
1267 jack_error(
"jack_port_disconnect called with an incorrect port %ld", myport);
1270 return client->PortDisconnect(myport);
1275 #ifdef __CLIENTDEBUG__
1276 JackGlobals::CheckContext(
"jack_get_sample_rate");
1279 if (client == NULL) {
1280 jack_error(
"jack_get_sample_rate called with a NULL client");
1284 return (control ? control->fSampleRate : 0);
1290 #ifdef __CLIENTDEBUG__
1291 JackGlobals::CheckContext(
"jack_get_buffer_size");
1294 if (client == NULL) {
1295 jack_error(
"jack_get_buffer_size called with a NULL client");
1299 return (control ? control->fBufferSize : 0);
1303 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)
1305 #ifdef __CLIENTDEBUG__
1306 JackGlobals::CheckContext(
"jack_get_ports");
1309 if (client == NULL) {
1310 jack_error(
"jack_get_ports called with a NULL client");
1314 return (manager ? manager->GetPorts(port_name_pattern, type_name_pattern, flags) : NULL);
1319 #ifdef __CLIENTDEBUG__
1320 JackGlobals::CheckContext(
"jack_port_by_name");
1323 if (client == NULL) {
1324 jack_error(
"jack_get_ports called with a NULL client");
1328 if (portname == NULL) {
1329 jack_error(
"jack_port_by_name called with a NULL port name");
1335 int res = manager->GetPort(portname);
1336 return (res == NO_PORT) ? NULL : (jack_port_t*)((uintptr_t)res);
1342 #ifdef __CLIENTDEBUG__
1343 JackGlobals::CheckContext(
"jack_port_by_id");
1346 return (jack_port_t*)((uintptr_t)
id);
1351 #ifdef __CLIENTDEBUG__
1352 JackGlobals::CheckContext(
"jack_engine_takeover_timebase");
1355 if (client == NULL) {
1356 jack_error(
"jack_engine_takeover_timebase called with a NULL client");
1359 jack_error(
"jack_engine_takeover_timebase: deprecated\n");
1366 #ifdef __CLIENTDEBUG__
1367 JackGlobals::CheckContext(
"jack_frames_since_cycle_start");
1372 control->ReadFrameTime(&timer);
1373 return timer.FramesSinceCycleStart(GetMicroSeconds(), control->fSampleRate);
1381 #ifdef __CLIENTDEBUG__
1382 JackGlobals::CheckContext(
"jack_get_time");
1384 return GetMicroSeconds();
1389 #ifdef __CLIENTDEBUG__
1390 JackGlobals::CheckContext(
"jack_frames_to_time");
1393 if (client == NULL) {
1394 jack_error(
"jack_frames_to_time called with a NULL client");
1400 control->ReadFrameTime(&timer);
1401 return timer.Frames2Time(frames, control->fBufferSize);
1410 #ifdef __CLIENTDEBUG__
1411 JackGlobals::CheckContext(
"jack_time_to_frames");
1414 if (client == NULL) {
1415 jack_error(
"jack_time_to_frames called with a NULL client");
1421 control->ReadFrameTime(&timer);
1422 return timer.Time2Frames(time, control->fBufferSize);
1431 #ifdef __CLIENTDEBUG__
1432 JackGlobals::CheckContext(
"jack_frame_time");
1439 #ifdef __CLIENTDEBUG__
1440 JackGlobals::CheckContext(
"jack_last_frame_time");
1443 return (control) ? control->fFrameTimer.
ReadCurrentState()->CurFrame() : 0;
1448 #ifdef __CLIENTDEBUG__
1449 JackGlobals::CheckContext(
"jack_cpu_load");
1452 if (client == NULL) {
1453 jack_error(
"jack_cpu_load called with a NULL client");
1457 return (control ? control->fCPULoad : 0.0f);
1461 LIB_EXPORT jack_native_thread_t jack_client_thread_id(jack_client_t* ext_client)
1463 #ifdef __CLIENTDEBUG__
1464 JackGlobals::CheckContext(
"jack_client_thread_id");
1467 if (client == NULL) {
1468 jack_error(
"jack_client_thread_id called with a NULL client");
1469 return (jack_native_thread_t)NULL;
1471 return client->GetThreadID();
1475 LIB_EXPORT
char* jack_get_client_name(jack_client_t* ext_client)
1477 #ifdef __CLIENTDEBUG__
1478 JackGlobals::CheckContext(
"jack_get_client_name");
1481 if (client == NULL) {
1482 jack_error(
"jack_get_client_name called with a NULL client");
1485 return client->GetClientControl()->fName;
1489 LIB_EXPORT
int jack_client_name_size(
void)
1491 return JACK_CLIENT_NAME_SIZE;
1496 return REAL_JACK_PORT_NAME_SIZE;
1501 return JACK_PORT_TYPE_SIZE;
1506 #ifdef __CLIENTDEBUG__
1507 JackGlobals::CheckContext(
"jack_port_type_get_buffer_size");
1510 if (client == NULL) {
1511 jack_error(
"jack_port_type_get_buffer_size called with a NULL client");
1514 jack_port_type_id_t port_id = GetPortTypeId(port_type);
1515 if (port_id == PORT_TYPES_MAX) {
1516 jack_error(
"jack_port_type_get_buffer_size called with an unknown port type = %s", port_type);
1519 return GetPortType(port_id)->size();
1527 #ifdef __CLIENTDEBUG__
1528 JackGlobals::CheckContext(
"jack_release_timebase");
1531 if (client == NULL) {
1532 jack_error(
"jack_release_timebase called with a NULL client");
1535 return client->ReleaseTimebase();
1541 #ifdef __CLIENTDEBUG__
1542 JackGlobals::CheckContext(
"jack_set_sync_callback");
1545 if (client == NULL) {
1546 jack_error(
"jack_set_sync_callback called with a NULL client");
1549 return client->SetSyncCallback(sync_callback, arg);
1555 #ifdef __CLIENTDEBUG__
1556 JackGlobals::CheckContext(
"jack_set_sync_timeout");
1559 if (client == NULL) {
1560 jack_error(
"jack_set_sync_timeout called with a NULL client");
1563 return client->SetSyncTimeout(timeout);
1569 #ifdef __CLIENTDEBUG__
1570 JackGlobals::CheckContext(
"jack_set_timebase_callback");
1573 if (client == NULL) {
1574 jack_error(
"jack_set_timebase_callback called with a NULL client");
1577 return client->SetTimebaseCallback(conditional, timebase_callback, arg);
1583 #ifdef __CLIENTDEBUG__
1584 JackGlobals::CheckContext(
"jack_transport_locate");
1587 if (client == NULL) {
1588 jack_error(
"jack_transport_locate called with a NULL client");
1591 client->TransportLocate(frame);
1598 #ifdef __CLIENTDEBUG__
1599 JackGlobals::CheckContext(
"jack_transport_query");
1602 if (client == NULL) {
1603 jack_error(
"jack_transport_query called with a NULL client");
1604 return JackTransportStopped;
1606 return client->TransportQuery(pos);
1612 #ifdef __CLIENTDEBUG__
1613 JackGlobals::CheckContext(
"jack_get_current_transport_frame");
1616 if (client == NULL) {
1617 jack_error(
"jack_get_current_transport_frame called with a NULL client");
1620 return client->GetCurrentTransportFrame();
1626 #ifdef __CLIENTDEBUG__
1627 JackGlobals::CheckContext(
"jack_transport_reposition");
1630 if (client == NULL) {
1631 jack_error(
"jack_transport_reposition called with a NULL client");
1634 client->TransportReposition(pos);
1641 #ifdef __CLIENTDEBUG__
1642 JackGlobals::CheckContext(
"jack_transport_start");
1645 if (client == NULL) {
1646 jack_error(
"jack_transport_start called with a NULL client");
1648 client->TransportStart();
1654 #ifdef __CLIENTDEBUG__
1655 JackGlobals::CheckContext(
"jack_transport_stop");
1658 if (client == NULL) {
1659 jack_error(
"jack_transport_stop called with a NULL client");
1661 client->TransportStop();
1668 #ifdef __CLIENTDEBUG__
1669 JackGlobals::CheckContext(
"jack_get_transport_info");
1671 jack_error(
"jack_get_transport_info: deprecated");
1678 #ifdef __CLIENTDEBUG__
1679 JackGlobals::CheckContext(
"jack_set_transport_info");
1681 jack_error(
"jack_set_transport_info: deprecated");
1687 LIB_EXPORT
float jack_get_max_delayed_usecs(jack_client_t* ext_client)
1689 #ifdef __CLIENTDEBUG__
1690 JackGlobals::CheckContext(
"jack_get_max_delayed_usecs");
1693 if (client == NULL) {
1694 jack_error(
"jack_get_max_delayed_usecs called with a NULL client");
1698 return (control ? control->fMaxDelayedUsecs : 0.f);
1702 LIB_EXPORT
float jack_get_xrun_delayed_usecs(jack_client_t* ext_client)
1704 #ifdef __CLIENTDEBUG__
1705 JackGlobals::CheckContext(
"jack_get_xrun_delayed_usecs");
1708 if (client == NULL) {
1709 jack_error(
"jack_get_xrun_delayed_usecs called with a NULL client");
1713 return (control ? control->fXrunDelayedUsecs : 0.f);
1717 LIB_EXPORT
void jack_reset_max_delayed_usecs(jack_client_t* ext_client)
1719 #ifdef __CLIENTDEBUG__
1720 JackGlobals::CheckContext(
"jack_reset_max_delayed_usecs");
1723 if (client == NULL) {
1724 jack_error(
"jack_reset_max_delayed_usecs called with a NULL client");
1727 control->ResetXRun();
1734 #ifdef __CLIENTDEBUG__
1735 JackGlobals::CheckContext(
"jack_client_real_time_priority");
1738 if (client == NULL) {
1739 jack_error(
"jack_client_real_time_priority called with a NULL client");
1743 return (control->fRealTime) ? control->fClientPriority : -1;
1749 #ifdef __CLIENTDEBUG__
1750 JackGlobals::CheckContext(
"jack_client_max_real_time_priority");
1753 if (client == NULL) {
1754 jack_error(
"jack_client_max_real_time_priority called with a NULL client");
1758 return (control->fRealTime) ? control->fMaxClientPriority : -1;
1766 ? JackThread::AcquireRealTimeImp(thread, priority, control->fPeriod, control->fComputation, control->fConstraint)
1771 jack_native_thread_t *thread,
1774 thread_routine routine,
1777 #ifdef __CLIENTDEBUG__
1778 JackGlobals::CheckContext(
"jack_client_create_thread");
1781 int res = JackThread::StartImp(thread, priority, realtime, routine, arg);
1783 ? ((realtime ? JackThread::AcquireRealTimeImp(*thread, priority, control->fPeriod, control->fComputation, control->fConstraint) : res))
1789 return JackThread::DropRealTimeImp(thread);
1794 #ifdef __CLIENTDEBUG__
1795 JackGlobals::CheckContext(
"jack_client_stop_thread");
1797 return JackThread::StopImp(thread);
1802 #ifdef __CLIENTDEBUG__
1803 JackGlobals::CheckContext(
"jack_client_kill_thread");
1805 return JackThread::KillImp(thread);
1811 JackGlobals::fJackThreadCreator = (jtc == NULL) ? pthread_create : jtc;
1816 LIB_EXPORT
int jack_internal_client_new (
const char* client_name,
1817 const char* load_name,
1818 const char* load_init)
1820 #ifdef __CLIENTDEBUG__
1821 JackGlobals::CheckContext(
"jack_internal_client_new");
1823 jack_error(
"jack_internal_client_new: deprecated");
1827 LIB_EXPORT
void jack_internal_client_close (
const char* client_name)
1829 #ifdef __CLIENTDEBUG__
1830 JackGlobals::CheckContext(
"jack_internal_client_close");
1832 jack_error(
"jack_internal_client_close: deprecated");
1835 LIB_EXPORT
char* jack_get_internal_client_name(jack_client_t* ext_client, jack_intclient_t intclient)
1837 #ifdef __CLIENTDEBUG__
1838 JackGlobals::CheckContext(
"jack_get_internal_client_name");
1841 if (client == NULL) {
1842 jack_error(
"jack_get_internal_client_name called with a NULL client");
1844 }
else if (intclient >= CLIENT_NUM) {
1845 jack_error(
"jack_get_internal_client_name: incorrect client");
1848 return client->GetInternalClientName(intclient);
1852 LIB_EXPORT jack_intclient_t jack_internal_client_handle(jack_client_t* ext_client,
const char* client_name, jack_status_t* status)
1854 #ifdef __CLIENTDEBUG__
1855 JackGlobals::CheckContext(
"jack_internal_client_handle");
1858 if (client == NULL) {
1859 jack_error(
"jack_internal_client_handle called with a NULL client");
1862 jack_status_t my_status;
1864 status = &my_status;
1865 *status = (jack_status_t)0;
1866 return client->InternalClientHandle(client_name, status);
1870 LIB_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)
1872 #ifdef __CLIENTDEBUG__
1873 JackGlobals::CheckContext(
"jack_internal_client_load_aux");
1876 if (client == NULL) {
1877 jack_error(
"jack_internal_client_load called with a NULL client");
1881 jack_status_t my_status;
1884 status = &my_status;
1885 *status = (jack_status_t)0;
1888 if ((options & ~JackLoadOptions)) {
1889 int my_status1 = *status | (JackFailure | JackInvalidOption);
1890 *status = (jack_status_t)my_status1;
1895 jack_varargs_parse(options, ap, &va);
1896 return client->InternalClientLoad(client_name, options, status, &va);
1900 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, ...)
1902 #ifdef __CLIENTDEBUG__
1903 JackGlobals::CheckContext(
"jack_internal_client_load");
1906 va_start(ap, status);
1907 jack_intclient_t res = jack_internal_client_load_aux(client, client_name, options, status, ap);
1912 LIB_EXPORT jack_status_t jack_internal_client_unload(jack_client_t* ext_client, jack_intclient_t intclient)
1914 #ifdef __CLIENTDEBUG__
1915 JackGlobals::CheckContext(
"jack_internal_client_load");
1918 if (client == NULL) {
1919 jack_error(
"jack_internal_client_unload called with a NULL client");
1920 return (jack_status_t)(JackNoSuchClient | JackFailure);
1921 }
else if (intclient >= CLIENT_NUM) {
1922 jack_error(
"jack_internal_client_unload: incorrect client");
1923 return (jack_status_t)(JackNoSuchClient | JackFailure);
1925 jack_status_t my_status;
1926 client->InternalClientUnload(intclient, &my_status);
1931 LIB_EXPORT
void jack_get_version(
int *major_ptr,
1936 #ifdef __CLIENTDEBUG__
1937 JackGlobals::CheckContext(
"jack_get_version");
1946 LIB_EXPORT
const char* jack_get_version_string()
1948 #ifdef __CLIENTDEBUG__
1949 JackGlobals::CheckContext(
"jack_get_version_string");
1954 LIB_EXPORT
void jack_free(
void* ptr)
1956 #ifdef __CLIENTDEBUG__
1957 JackGlobals::CheckContext(
"jack_free");
1967 #ifdef __CLIENTDEBUG__
1968 JackGlobals::CheckContext(
"jack_set_session_callback");
1971 jack_log(
"jack_set_session_callback ext_client %x client %x ", ext_client, client);
1972 if (client == NULL) {
1973 jack_error(
"jack_set_session_callback called with a NULL client");
1976 return client->SetSessionCallback(session_callback, arg);
1982 #ifdef __CLIENTDEBUG__
1983 JackGlobals::CheckContext(
"jack_session_notify");
1986 jack_log(
"jack_session_notify ext_client %x client %x ", ext_client, client);
1987 if (client == NULL) {
1988 jack_error(
"jack_session_notify called with a NULL client");
1991 return client->SessionNotify(target, ev_type, path);
1997 #ifdef __CLIENTDEBUG__
1998 JackGlobals::CheckContext(
"jack_session_reply");
2001 jack_log(
"jack_session_reply ext_client %x client %x ", ext_client, client);
2002 if (client == NULL) {
2003 jack_error(
"jack_session_reply called with a NULL client");
2006 return client->SessionReply(event);
2012 #ifdef __CLIENTDEBUG__
2013 JackGlobals::CheckContext(
"jack_session_event_free");
2028 #ifdef __CLIENTDEBUG__
2029 JackGlobals::CheckContext(
"jack_client_get_uuid");
2032 if (client == NULL) {
2033 jack_error(
"jack_client_get_uuid called with a NULL client");
2037 snprintf(retval,
sizeof(retval),
"%d", client->GetClientControl()->fSessionID);
2038 return strdup(retval);
2044 #ifdef __CLIENTDEBUG__
2045 JackGlobals::CheckContext(
"jack_get_uuid_for_client_name");
2048 jack_log(
"jack_get_uuid_for_client_name ext_client %x client %x ", ext_client, client);
2049 if (client == NULL) {
2050 jack_error(
"jack_get_uuid_for_client_name called with a NULL client");
2053 return client->GetUUIDForClientName(client_name);
2059 #ifdef __CLIENTDEBUG__
2060 JackGlobals::CheckContext(
"jack_get_client_name_by_uuid");
2063 jack_log(
"jack_get_uuid_for_client_name ext_client %x client %x ", ext_client, client);
2064 if (client == NULL) {
2065 jack_error(
"jack_get_client_name_by_uuid called with a NULL client");
2068 return client->GetClientNameByUUID(client_uuid);
2074 #ifdef __CLIENTDEBUG__
2075 JackGlobals::CheckContext(
"jack_reserve_client_name");
2078 jack_log(
"jack_reserve_client_name ext_client %x client %x ", ext_client, client);
2079 if (client == NULL) {
2080 jack_error(
"jack_reserve_client_name called with a NULL client");
2083 return client->ReserveClientName(client_name, uuid);
2089 #ifdef __CLIENTDEBUG__
2090 JackGlobals::CheckContext(
"jack_session_commands_free");
2099 if (cmds[i].client_name) {
2100 free ((
char *)cmds[i].client_name);
2102 if (cmds[i].command) {
2103 free ((
char *)cmds[i].command);
2106 free ((
char *)cmds[i].uuid);
2119 #ifdef __CLIENTDEBUG__
2120 JackGlobals::CheckContext(
"jack_client_has_session_callback");
2123 jack_log(
"jack_client_has_session_callback ext_client %x client %x ", ext_client, client);
2124 if (client == NULL) {
2125 jack_error(
"jack_client_has_session_callback called with a NULL client");
2128 return client->ClientHasSessionCallback(client_name);