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"
29 #include "JackMetadata.h"
39 typedef void (*print_function)(
const char*);
40 typedef void *(*thread_routine)(
void*);
42 LIB_EXPORT
const char* JACK_METADATA_PRETTY_NAME =
"http://jackaudio.org/metadata/pretty-name";
43 LIB_EXPORT
const char* JACK_METADATA_HARDWARE =
"http://jackaudio.org/metadata/hardware";
44 LIB_EXPORT
const char* JACK_METADATA_CONNECTED =
"http://jackaudio.org/metadata/connected";
45 LIB_EXPORT
const char* JACK_METADATA_PORT_GROUP =
"http://jackaudio.org/metadata/port-group";
46 LIB_EXPORT
const char* JACK_METADATA_ICON_SMALL =
"http://jackaudio.org/metadata/icon-small";
47 LIB_EXPORT
const char* JACK_METADATA_ICON_LARGE =
"http://jackaudio.org/metadata/icon-large";
59 jack_get_version_string();
61 jack_client_t * jack_client_new_aux(
const char* client_name,
62 jack_options_t options,
63 jack_status_t *status);
66 jack_options_t options,
67 jack_status_t *status, ...);
72 const char* load_name,
73 const char* load_init);
75 LIB_EXPORT
int jack_is_realtime(jack_client_t *client);
77 JackShutdownCallback shutdown_callback,
void *arg);
79 JackInfoShutdownCallback shutdown_callback,
void *arg);
81 JackProcessCallback process_callback,
83 LIB_EXPORT jack_nframes_t
jack_thread_wait(jack_client_t *client,
int status);
91 JackThreadInitCallback thread_init_callback,
94 JackFreewheelCallback freewheel_callback,
99 JackBufferSizeCallback bufsize_callback,
102 JackSampleRateCallback srate_callback,
105 JackClientRegistrationCallback
106 registration_callback,
void *arg);
108 JackPortRegistrationCallback
109 registration_callback,
void *arg);
111 JackPortConnectCallback
112 connect_callback,
void *arg);
114 JackPortRenameCallback
115 rename_callback,
void *arg);
117 JackGraphOrderCallback graph_callback,
120 JackXRunCallback xrun_callback,
void *arg);
121 LIB_EXPORT
int jack_set_latency_callback(jack_client_t *client,
122 JackLatencyCallback latency_callback,
void *arg);
127 const char* port_name,
128 const char* port_type,
130 unsigned long buffer_size);
139 LIB_EXPORT
int jack_port_is_mine(
const jack_client_t *,
const jack_port_t *port);
142 const char* port_name);
145 const jack_port_t *port);
146 LIB_EXPORT
int jack_port_tie(jack_port_t *src, jack_port_t *dst);
167 const char* port_name,
int onoff);
171 const char* source_port,
172 const char* destination_port);
174 const char* source_port,
175 const char* destination_port);
183 const char* port_name_pattern,
184 const char* type_name_pattern,
185 unsigned long flags);
186 LIB_EXPORT jack_port_t *
jack_port_by_name(jack_client_t *,
const char* port_name);
188 jack_port_id_t port_id);
192 LIB_EXPORT jack_nframes_t
jack_time_to_frames(
const jack_client_t *client, jack_time_t usecs);
193 LIB_EXPORT jack_time_t
jack_frames_to_time(
const jack_client_t *client, jack_nframes_t frames);
197 jack_nframes_t *current_frames,
198 jack_time_t *current_usecs,
199 jack_time_t *next_usecs,
200 float *period_usecs);
206 LIB_EXPORT
float jack_get_max_delayed_usecs(jack_client_t *client);
207 LIB_EXPORT
float jack_get_xrun_delayed_usecs(jack_client_t *client);
208 LIB_EXPORT
void jack_reset_max_delayed_usecs(jack_client_t *client);
212 JackSyncCallback sync_callback,
215 jack_time_t timeout);
218 JackTimebaseCallback timebase_callback,
221 jack_nframes_t frame);
238 jack_native_thread_t *thread,
241 thread_routine routine,
250 LIB_EXPORT
char * jack_get_internal_client_name(jack_client_t *client,
251 jack_intclient_t intclient);
252 LIB_EXPORT jack_intclient_t jack_internal_client_handle(jack_client_t *client,
253 const char* client_name,
254 jack_status_t *status);
255 LIB_EXPORT jack_intclient_t jack_internal_client_load(jack_client_t *client,
256 const char* client_name,
257 jack_options_t options,
258 jack_status_t *status, ...);
260 LIB_EXPORT jack_status_t jack_internal_client_unload(jack_client_t *client,
261 jack_intclient_t intclient);
262 LIB_EXPORT
void jack_free(
void* ptr);
275 LIB_EXPORT
int jack_set_property(jack_client_t*, jack_uuid_t subject,
const char* key,
const char* value,
const char* type);
276 LIB_EXPORT
int jack_get_property(jack_uuid_t subject,
const char* key,
char** value,
char** type);
280 LIB_EXPORT
int jack_remove_property(jack_client_t* client, jack_uuid_t subject,
const char* key);
285 LIB_EXPORT jack_uuid_t jack_client_uuid_generate();
286 LIB_EXPORT jack_uuid_t jack_port_uuid_generate(uint32_t port_id);
287 LIB_EXPORT uint32_t jack_uuid_to_index(jack_uuid_t);
288 LIB_EXPORT
int jack_uuid_compare(jack_uuid_t, jack_uuid_t);
289 LIB_EXPORT
void jack_uuid_copy(jack_uuid_t* dst, jack_uuid_t src);
290 LIB_EXPORT
void jack_uuid_clear(jack_uuid_t*);
291 LIB_EXPORT
int jack_uuid_parse(
const char* buf, jack_uuid_t*);
292 LIB_EXPORT
void jack_uuid_unparse(jack_uuid_t,
char buf[JACK_UUID_STRING_SIZE]);
293 LIB_EXPORT
int jack_uuid_empty(jack_uuid_t);
299 static inline bool CheckPort(jack_port_id_t port_index)
301 return (port_index > 0 && port_index < PORT_NUM_MAX);
304 static inline bool CheckBufferSize(jack_nframes_t buffer_size)
306 return (buffer_size >= 1 && buffer_size <= BUFFER_SIZE_MAX);
309 static inline void WaitGraphChange()
316 if (jack_tls_get(JackGlobals::fRealTimeThread) == NULL) {
321 if (manager->IsPendingChange()) {
323 JackSleep(
int(control->fPeriodUsecs * 1.1f));
340 JackGlobals::CheckContext(
"jack_client_new");
343 assert(JackGlobals::fOpenMutex);
344 JackGlobals::fOpenMutex->Lock();
346 int options = JackUseExactName;
347 if (getenv(
"JACK_START_SERVER") == NULL) {
348 options |= JackNoStartServer;
350 jack_client_t* res = jack_client_new_aux(client_name, (jack_options_t)options, NULL);
351 JackGlobals::fOpenMutex->Unlock();
353 }
catch (std::bad_alloc& e) {
364 JackGlobals::CheckContext(
"jack_port_get_buffer");
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_get_buffer called with an incorrect port %ld", myport);
373 return (manager ? manager->GetBuffer(myport, frames) : NULL);
384 JackGlobals::CheckContext(
"jack_port_name");
386 uintptr_t port_aux = (uintptr_t)port;
387 jack_port_id_t myport = (jack_port_id_t)port_aux;
388 if (!CheckPort(myport)) {
389 jack_error(
"jack_port_name called with an incorrect port %ld", myport);
393 return (manager ? manager->GetPort(myport)->GetName() : NULL);
399 JackGlobals::CheckContext(
"jack_port_short_name");
401 uintptr_t port_aux = (uintptr_t)port;
402 jack_port_id_t myport = (jack_port_id_t)port_aux;
403 if (!CheckPort(myport)) {
404 jack_error(
"jack_port_short_name called with an incorrect port %ld", myport);
408 return (manager ? manager->GetPort(myport)->GetShortName() : NULL);
414 JackGlobals::CheckContext(
"jack_port_flags");
416 uintptr_t port_aux = (uintptr_t)port;
417 jack_port_id_t myport = (jack_port_id_t)port_aux;
418 if (!CheckPort(myport)) {
419 jack_error(
"jack_port_flags called with an incorrect port %ld", myport);
423 return (manager ? manager->GetPort(myport)->GetFlags() : -1);
429 JackGlobals::CheckContext(
"jack_port_type");
431 uintptr_t port_aux = (uintptr_t)port;
432 jack_port_id_t myport = (jack_port_id_t)port_aux;
433 if (!CheckPort(myport)) {
434 jack_error(
"jack_port_flags called an incorrect port %ld", myport);
438 return (manager ? manager->GetPort(myport)->GetType() : NULL);
444 JackGlobals::CheckContext(
"jack_port_type_id");
446 uintptr_t port_aux = (uintptr_t)port;
447 jack_port_id_t myport = (jack_port_id_t)port_aux;
448 if (!CheckPort(myport)) {
449 jack_error(
"jack_port_type_id called an incorrect port %ld", myport);
453 return (manager ? GetPortTypeId(manager->GetPort(myport)->GetType()) : 0);
459 JackGlobals::CheckContext(
"jack_port_connected");
461 uintptr_t port_aux = (uintptr_t)port;
462 jack_port_id_t myport = (jack_port_id_t)port_aux;
463 if (!CheckPort(myport)) {
464 jack_error(
"jack_port_connected called with an incorrect port %ld", myport);
469 return (manager ? manager->GetConnectionsNum(myport) : -1);
475 JackGlobals::CheckContext(
"jack_port_connected_to");
477 uintptr_t port_aux = (uintptr_t)port;
478 jack_port_id_t src = (jack_port_id_t)port_aux;
479 if (!CheckPort(src)) {
480 jack_error(
"jack_port_connected_to called with an incorrect port %ld", src);
482 }
else if (port_name == NULL) {
483 jack_error(
"jack_port_connected_to called with a NULL port name");
488 jack_port_id_t dst = (manager ? manager->GetPort(port_name) : NO_PORT);
489 if (dst == NO_PORT) {
490 jack_error(
"Unknown destination port port_name = %s", port_name);
493 return manager->IsConnected(src, dst);
500 JackGlobals::CheckContext(
"jack_port_tie");
502 uintptr_t src_aux = (uintptr_t)src;
503 jack_port_id_t mysrc = (jack_port_id_t)src_aux;
504 if (!CheckPort(mysrc)) {
505 jack_error(
"jack_port_tie called with a NULL src port");
508 uintptr_t dst_aux = (uintptr_t)dst;
509 jack_port_id_t mydst = (jack_port_id_t)dst_aux;
510 if (!CheckPort(mydst)) {
511 jack_error(
"jack_port_tie called with a NULL dst port");
515 if (manager && manager->GetPort(mysrc)->GetRefNum() != manager->GetPort(mydst)->GetRefNum()) {
516 jack_error(
"jack_port_tie called with ports not belonging to the same client");
519 return manager->GetPort(mydst)->Tie(mysrc);
525 JackGlobals::CheckContext(
"jack_port_untie");
527 uintptr_t port_aux = (uintptr_t)port;
528 jack_port_id_t myport = (jack_port_id_t)port_aux;
529 if (!CheckPort(myport)) {
530 jack_error(
"jack_port_untie called with an incorrect port %ld", myport);
534 return (manager ? manager->GetPort(myport)->UnTie() : -1);
540 JackGlobals::CheckContext(
"jack_port_get_latency");
542 uintptr_t port_aux = (uintptr_t)port;
543 jack_port_id_t myport = (jack_port_id_t)port_aux;
544 if (!CheckPort(myport)) {
545 jack_error(
"jack_port_get_latency called with an incorrect port %ld", myport);
550 return (manager ? manager->GetPort(myport)->GetLatency() : 0);
556 JackGlobals::CheckContext(
"jack_port_set_latency");
558 uintptr_t port_aux = (uintptr_t)port;
559 jack_port_id_t myport = (jack_port_id_t)port_aux;
560 if (!CheckPort(myport)) {
561 jack_error(
"jack_port_set_latency called with an incorrect port %ld", myport);
565 manager->GetPort(myport)->SetLatency(frames);
571 JackGlobals::CheckContext(
"jack_port_get_latency_range");
573 uintptr_t port_aux = (uintptr_t)port;
574 jack_port_id_t myport = (jack_port_id_t)port_aux;
575 if (!CheckPort(myport)) {
576 jack_error(
"jack_port_get_latency_range called with an incorrect port %ld", myport);
581 manager->GetPort(myport)->GetLatencyRange(mode, range);
587 JackGlobals::CheckContext(
"jack_port_set_latency_range");
589 uintptr_t port_aux = (uintptr_t)port;
590 jack_port_id_t myport = (jack_port_id_t)port_aux;
591 if (!CheckPort(myport)) {
592 jack_error(
"jack_port_set_latency_range called with an incorrect port %ld", myport);
597 manager->GetPort(myport)->SetLatencyRange(mode, range);
603 JackGlobals::CheckContext(
"jack_recompute_total_latency");
607 uintptr_t port_aux = (uintptr_t)port;
608 jack_port_id_t myport = (jack_port_id_t)port_aux;
609 if (client == NULL) {
610 jack_error(
"jack_recompute_total_latency called with a NULL client");
612 }
else if (!CheckPort(myport)) {
613 jack_error(
"jack_recompute_total_latency called with a NULL port");
618 return (manager ? manager->ComputeTotalLatency(myport) : -1);
624 JackGlobals::CheckContext(
"jack_recompute_total_latencies");
627 if (client == NULL) {
628 jack_error(
"jack_recompute_total_latencies called with a NULL client");
631 return client->ComputeTotalLatencies();
637 JackGlobals::CheckContext(
"jack_port_set_name");
639 uintptr_t port_aux = (uintptr_t)port;
640 jack_port_id_t myport = (jack_port_id_t)port_aux;
641 if (!CheckPort(myport)) {
642 jack_error(
"jack_port_set_name called with an incorrect port %ld", myport);
644 }
else if (name == NULL) {
645 jack_error(
"jack_port_set_name called with a NULL port name");
649 for (
int i = 0; i < CLIENT_NUM; i++) {
651 if ((client = JackGlobals::fClientTable[i])) {
655 return (client) ? client->PortRename(myport, name) : -1;
661 JackGlobals::CheckContext(
"jack_port_set_alias");
663 uintptr_t port_aux = (uintptr_t)port;
664 jack_port_id_t myport = (jack_port_id_t)port_aux;
665 if (!CheckPort(myport)) {
666 jack_error(
"jack_port_set_alias called with an incorrect port %ld", myport);
668 }
else if (name == NULL) {
669 jack_error(
"jack_port_set_alias called with a NULL port name");
673 return (manager ? manager->GetPort(myport)->SetAlias(name) : -1);
679 JackGlobals::CheckContext(
"jack_port_unset_alias");
681 uintptr_t port_aux = (uintptr_t)port;
682 jack_port_id_t myport = (jack_port_id_t)port_aux;
683 if (!CheckPort(myport)) {
684 jack_error(
"jack_port_unset_alias called with an incorrect port %ld", myport);
686 }
else if (name == NULL) {
687 jack_error(
"jack_port_unset_alias called with a NULL port name");
691 return (manager ? manager->GetPort(myport)->UnsetAlias(name) : -1);
697 JackGlobals::CheckContext(
"jack_port_get_aliases");
699 uintptr_t port_aux = (uintptr_t)port;
700 jack_port_id_t myport = (jack_port_id_t)port_aux;
701 if (!CheckPort(myport)) {
702 jack_error(
"jack_port_get_aliases called with an incorrect port %ld", myport);
706 return (manager ? manager->GetPort(myport)->GetAliases(aliases) : -1);
712 JackGlobals::CheckContext(
"jack_port_request_monitor");
714 uintptr_t port_aux = (uintptr_t)port;
715 jack_port_id_t myport = (jack_port_id_t)port_aux;
716 if (!CheckPort(myport)) {
717 jack_error(
"jack_port_request_monitor called with an incorrect port %ld", myport);
727 JackGlobals::CheckContext(
"jack_port_request_monitor_by_name");
730 if (client == NULL) {
731 jack_error(
"jack_port_request_monitor_by_name called with a NULL client");
737 jack_port_id_t myport = manager->GetPort(port_name);
738 if (!CheckPort(myport)) {
739 jack_error(
"jack_port_request_monitor_by_name called with an incorrect port %s", port_name);
749 JackGlobals::CheckContext(
"jack_port_ensure_monitor");
751 uintptr_t port_aux = (uintptr_t)port;
752 jack_port_id_t myport = (jack_port_id_t)port_aux;
753 if (!CheckPort(myport)) {
754 jack_error(
"jack_port_ensure_monitor called with an incorrect port %ld", myport);
758 return (manager ? manager->GetPort(myport)->
EnsureMonitor(onoff) : -1);
764 JackGlobals::CheckContext(
"jack_port_monitoring_input");
766 uintptr_t port_aux = (uintptr_t)port;
767 jack_port_id_t myport = (jack_port_id_t)port_aux;
768 if (!CheckPort(myport)) {
769 jack_error(
"jack_port_monitoring_input called with an incorrect port %ld", myport);
773 return (manager ? manager->GetPort(myport)->MonitoringInput() : -1);
777 LIB_EXPORT
int jack_is_realtime(jack_client_t* ext_client)
779 JackGlobals::CheckContext(
"jack_is_realtime");
782 if (client == NULL) {
783 jack_error(
"jack_is_realtime called with a NULL client");
787 return (control ? control->fRealTime : -1);
791 LIB_EXPORT
void jack_on_shutdown(jack_client_t* ext_client, JackShutdownCallback callback,
void* arg)
793 JackGlobals::CheckContext(
"jack_on_shutdown");
796 if (client == NULL) {
797 jack_error(
"jack_on_shutdown called with a NULL client");
799 client->OnShutdown(callback, arg);
805 JackGlobals::CheckContext(
"jack_on_info_shutdown");
808 if (client == NULL) {
809 jack_error(
"jack_on_info_shutdown called with a NULL client");
811 client->OnInfoShutdown(callback, arg);
817 JackGlobals::CheckContext(
"jack_set_process_callback");
820 if (client == NULL) {
821 jack_error(
"jack_set_process_callback called with a NULL client");
824 return client->SetProcessCallback(callback, arg);
830 JackGlobals::CheckContext(
"jack_thread_wait");
833 if (client == NULL) {
834 jack_error(
"jack_thread_wait called with a NULL client");
837 jack_error(
"jack_thread_wait: deprecated, use jack_cycle_wait/jack_cycle_signal");
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 JackGlobals::CheckContext(
"jack_cycle_signal");
860 if (client == NULL) {
861 jack_error(
"jack_cycle_signal called with a NULL client");
863 client->CycleSignal(status);
869 JackGlobals::CheckContext(
"jack_set_process_thread");
872 if (client == NULL) {
873 jack_error(
"jack_set_process_thread called with a NULL client");
876 return client->SetProcessThread(fun, arg);
882 JackGlobals::CheckContext(
"jack_set_freewheel_callback");
885 if (client == NULL) {
886 jack_error(
"jack_set_freewheel_callback called with a NULL client");
889 return client->SetFreewheelCallback(freewheel_callback, arg);
895 JackGlobals::CheckContext(
"jack_set_freewheel");
898 if (client == NULL) {
899 jack_error(
"jack_set_freewheel called with a NULL client");
902 return client->SetFreeWheel(onoff);
908 JackGlobals::CheckContext(
"jack_set_buffer_size");
911 if (client == NULL) {
912 jack_error(
"jack_set_buffer_size called with a NULL client");
914 }
else if (!CheckBufferSize(buffer_size)) {
917 return client->SetBufferSize(buffer_size);
923 JackGlobals::CheckContext(
"jack_set_buffer_size_callback");
926 if (client == NULL) {
927 jack_error(
"jack_set_buffer_size_callback called with a NULL client");
930 return client->SetBufferSizeCallback(bufsize_callback, arg);
936 JackGlobals::CheckContext(
"jack_set_sample_rate_callback");
939 if (client == NULL) {
940 jack_error(
"jack_set_sample_rate_callback called with a NULL client");
943 return client->SetSampleRateCallback(srate_callback, arg);
949 JackGlobals::CheckContext(
"jack_set_client_registration_callback");
952 if (client == NULL) {
953 jack_error(
"jack_set_client_registration_callback called with a NULL client");
956 return client->SetClientRegistrationCallback(registration_callback, arg);
962 JackGlobals::CheckContext(
"jack_set_port_registration_callback");
965 if (client == NULL) {
966 jack_error(
"jack_set_port_registration_callback called with a NULL client");
969 return client->SetPortRegistrationCallback(registration_callback, arg);
975 JackGlobals::CheckContext(
"jack_set_port_connect_callback");
978 if (client == NULL) {
979 jack_error(
"jack_set_port_connect_callback called with a NULL client");
982 return client->SetPortConnectCallback(portconnect_callback, arg);
988 JackGlobals::CheckContext(
"jack_set_port_rename_callback");
991 if (client == NULL) {
992 jack_error(
"jack_set_port_rename_callback called with a NULL client");
995 return client->SetPortRenameCallback(rename_callback, arg);
1001 JackGlobals::CheckContext(
"jack_set_graph_order_callback");
1004 jack_log(
"jack_set_graph_order_callback ext_client %x client %x ", ext_client, client);
1005 if (client == NULL) {
1006 jack_error(
"jack_set_graph_order_callback called with a NULL client");
1009 return client->SetGraphOrderCallback(graph_callback, arg);
1015 JackGlobals::CheckContext(
"jack_set_xrun_callback");
1018 if (client == NULL) {
1019 jack_error(
"jack_set_xrun_callback called with a NULL client");
1022 return client->SetXRunCallback(xrun_callback, arg);
1026 LIB_EXPORT
int jack_set_latency_callback(jack_client_t* ext_client, JackLatencyCallback latency_callback,
void *arg)
1028 JackGlobals::CheckContext(
"jack_set_latency_callback");
1031 if (client == NULL) {
1032 jack_error(
"jack_set_latency_callback called with a NULL client");
1035 return client->SetLatencyCallback(latency_callback, arg);
1041 JackGlobals::CheckContext(
"jack_set_thread_init_callback");
1044 jack_log(
"jack_set_thread_init_callback ext_client %x client %x ", ext_client, client);
1045 if (client == NULL) {
1046 jack_error(
"jack_set_thread_init_callback called with a NULL client");
1049 return client->SetInitCallback(init_callback, arg);
1055 JackGlobals::CheckContext(
"jack_activate");
1058 if (client == NULL) {
1059 jack_error(
"jack_activate called with a NULL client");
1068 JackGlobals::CheckContext(
"jack_deactivate");
1071 if (client == NULL) {
1072 jack_error(
"jack_deactivate called with a NULL client");
1079 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)
1081 JackGlobals::CheckContext(
"jack_port_register");
1084 if (client == NULL) {
1085 jack_error(
"jack_port_register called with a NULL client");
1087 }
else if ((port_name == NULL) || (port_type == NULL)) {
1088 jack_error(
"jack_port_register called with a NULL port name or a NULL port_type");
1091 return (jack_port_t *)((uintptr_t)client->PortRegister(port_name, port_type, flags, buffer_size));
1097 JackGlobals::CheckContext(
"jack_port_unregister");
1100 if (client == NULL) {
1101 jack_error(
"jack_port_unregister called with a NULL client");
1104 uintptr_t port_aux = (uintptr_t)port;
1105 jack_port_id_t myport = (jack_port_id_t)port_aux;
1106 if (!CheckPort(myport)) {
1107 jack_error(
"jack_port_unregister called with an incorrect port %ld", myport);
1110 return client->PortUnRegister(myport);
1115 JackGlobals::CheckContext(
"jack_port_is_mine");
1118 if (client == NULL) {
1119 jack_error(
"jack_port_is_mine called with a NULL client");
1122 uintptr_t port_aux = (uintptr_t)port;
1123 jack_port_id_t myport = (jack_port_id_t)port_aux;
1124 if (!CheckPort(myport)) {
1125 jack_error(
"jack_port_is_mine called with an incorrect port %ld", myport);
1128 return client->PortIsMine(myport);
1133 JackGlobals::CheckContext(
"jack_port_get_connections");
1135 uintptr_t port_aux = (uintptr_t)port;
1136 jack_port_id_t myport = (jack_port_id_t)port_aux;
1137 if (!CheckPort(myport)) {
1138 jack_error(
"jack_port_get_connections called with an incorrect port %ld", myport);
1143 return (manager ? manager->GetConnections(myport) : NULL);
1150 JackGlobals::CheckContext(
"jack_port_get_all_connections");
1153 if (client == NULL) {
1154 jack_error(
"jack_port_get_all_connections called with a NULL client");
1158 uintptr_t port_aux = (uintptr_t)port;
1159 jack_port_id_t myport = (jack_port_id_t)port_aux;
1160 if (!CheckPort(myport)) {
1161 jack_error(
"jack_port_get_all_connections called with an incorrect port %ld", myport);
1166 return (manager ? manager->GetConnections(myport) : NULL);
1172 JackGlobals::CheckContext(
"jack_port_get_total_latency");
1175 if (client == NULL) {
1176 jack_error(
"jack_port_get_total_latency 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_total_latency called with an incorrect port %ld", myport);
1189 manager->ComputeTotalLatency(myport);
1190 return manager->GetPort(myport)->GetTotalLatency();
1197 LIB_EXPORT
int jack_connect(jack_client_t* ext_client,
const char* src,
const char* dst)
1199 JackGlobals::CheckContext(
"jack_connect");
1202 if (client == NULL) {
1203 jack_error(
"jack_connect called with a NULL client");
1205 }
else if ((src == NULL) || (dst == NULL)) {
1206 jack_error(
"jack_connect called with a NULL port name");
1209 return client->PortConnect(src, dst);
1213 LIB_EXPORT
int jack_disconnect(jack_client_t* ext_client,
const char* src,
const char* dst)
1215 JackGlobals::CheckContext(
"jack_disconnect");
1218 if (client == NULL) {
1219 jack_error(
"jack_disconnect called with a NULL client");
1221 }
else if ((src == NULL) || (dst == NULL)) {
1222 jack_error(
"jack_disconnect called with a NULL port name");
1225 return client->PortDisconnect(src, dst);
1231 JackGlobals::CheckContext(
"jack_port_disconnect");
1234 if (client == NULL) {
1235 jack_error(
"jack_port_disconnect called with a NULL client");
1238 uintptr_t port_aux = (uintptr_t)src;
1239 jack_port_id_t myport = (jack_port_id_t)port_aux;
1240 if (!CheckPort(myport)) {
1241 jack_error(
"jack_port_disconnect called with an incorrect port %ld", myport);
1244 return client->PortDisconnect(myport);
1249 JackGlobals::CheckContext(
"jack_get_sample_rate");
1252 if (client == NULL) {
1253 jack_error(
"jack_get_sample_rate called with a NULL client");
1257 return (control ? control->fSampleRate : 0);
1263 JackGlobals::CheckContext(
"jack_get_buffer_size");
1266 if (client == NULL) {
1267 jack_error(
"jack_get_buffer_size called with a NULL client");
1271 return (control ? control->fBufferSize : 0);
1275 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)
1277 JackGlobals::CheckContext(
"jack_get_ports");
1280 if (client == NULL) {
1281 jack_error(
"jack_get_ports called with a NULL client");
1285 return (manager ? manager->GetPorts(port_name_pattern, type_name_pattern, flags) : NULL);
1290 JackGlobals::CheckContext(
"jack_port_by_name");
1293 if (client == NULL) {
1294 jack_error(
"jack_port_by_name called with a NULL client");
1298 if (portname == NULL) {
1299 jack_error(
"jack_port_by_name called with a NULL port name");
1305 int res = manager->GetPort(portname);
1306 return (res == NO_PORT) ? NULL : (jack_port_t*)((uintptr_t)res);
1314 JackGlobals::CheckContext(
"jack_port_by_id");
1317 return (jack_port_t*)((uintptr_t)
id);
1322 JackGlobals::CheckContext(
"jack_engine_takeover_timebase");
1325 if (client == NULL) {
1326 jack_error(
"jack_engine_takeover_timebase called with a NULL client");
1329 jack_error(
"jack_engine_takeover_timebase: deprecated\n");
1336 JackGlobals::CheckContext(
"jack_frames_since_cycle_start");
1341 control->ReadFrameTime(&timer);
1342 return timer.FramesSinceCycleStart(GetMicroSeconds(), control->fSampleRate);
1350 JackGlobals::CheckContext(
"jack_get_time");
1352 return GetMicroSeconds();
1357 JackGlobals::CheckContext(
"jack_frames_to_time");
1360 if (client == NULL) {
1361 jack_error(
"jack_frames_to_time called with a NULL client");
1367 control->ReadFrameTime(&timer);
1368 return timer.Frames2Time(frames, control->fBufferSize);
1377 JackGlobals::CheckContext(
"jack_time_to_frames");
1380 if (client == NULL) {
1381 jack_error(
"jack_time_to_frames called with a NULL client");
1387 control->ReadFrameTime(&timer);
1388 return timer.Time2Frames(usecs, control->fBufferSize);
1397 JackGlobals::CheckContext(
"jack_frame_time");
1404 JackGlobals::CheckContext(
"jack_last_frame_time");
1407 return (control) ? control->fFrameTimer.
ReadCurrentState()->CurFrame() : 0;
1411 jack_nframes_t *current_frames,
1412 jack_time_t *current_usecs,
1413 jack_time_t *next_usecs,
1414 float *period_usecs)
1416 JackGlobals::CheckContext(
"jack_get_cycle_times");
1421 control->ReadFrameTime(&timer);
1422 return timer.GetCycleTimes(current_frames, current_usecs, next_usecs, period_usecs);
1430 JackGlobals::CheckContext(
"jack_cpu_load");
1433 if (client == NULL) {
1434 jack_error(
"jack_cpu_load called with a NULL client");
1438 return (control ? control->fCPULoad : 0.0f);
1444 JackGlobals::CheckContext(
"jack_client_thread_id");
1447 if (client == NULL) {
1448 jack_error(
"jack_client_thread_id called with a NULL client");
1449 return (jack_native_thread_t)NULL;
1451 return client->GetThreadID();
1457 JackGlobals::CheckContext(
"jack_get_client_name");
1460 if (client == NULL) {
1461 jack_error(
"jack_get_client_name called with a NULL client");
1464 return client->GetClientControl()->fName;
1470 return JACK_CLIENT_NAME_SIZE;
1475 return REAL_JACK_PORT_NAME_SIZE;
1480 return JACK_PORT_TYPE_SIZE;
1485 JackGlobals::CheckContext(
"jack_port_type_get_buffer_size");
1488 if (client == NULL) {
1489 jack_error(
"jack_port_type_get_buffer_size called with a NULL client");
1492 jack_port_type_id_t port_id = GetPortTypeId(port_type);
1493 if (port_id == PORT_TYPES_MAX) {
1494 jack_error(
"jack_port_type_get_buffer_size called with an unknown port type = %s", port_type);
1497 return GetPortType(port_id)->size();
1505 JackGlobals::CheckContext(
"jack_release_timebase");
1508 if (client == NULL) {
1509 jack_error(
"jack_release_timebase called with a NULL client");
1512 return client->ReleaseTimebase();
1518 JackGlobals::CheckContext(
"jack_set_sync_callback");
1521 if (client == NULL) {
1522 jack_error(
"jack_set_sync_callback called with a NULL client");
1525 return client->SetSyncCallback(sync_callback, arg);
1531 JackGlobals::CheckContext(
"jack_set_sync_timeout");
1534 if (client == NULL) {
1535 jack_error(
"jack_set_sync_timeout called with a NULL client");
1538 return client->SetSyncTimeout(timeout);
1544 JackGlobals::CheckContext(
"jack_set_timebase_callback");
1547 if (client == NULL) {
1548 jack_error(
"jack_set_timebase_callback called with a NULL client");
1551 return client->SetTimebaseCallback(conditional, timebase_callback, arg);
1557 JackGlobals::CheckContext(
"jack_transport_locate");
1560 if (client == NULL) {
1561 jack_error(
"jack_transport_locate called with a NULL client");
1564 client->TransportLocate(frame);
1571 JackGlobals::CheckContext(
"jack_transport_query");
1574 if (client == NULL) {
1575 jack_error(
"jack_transport_query called with a NULL client");
1576 return JackTransportStopped;
1578 return client->TransportQuery(pos);
1584 JackGlobals::CheckContext(
"jack_get_current_transport_frame");
1587 if (client == NULL) {
1588 jack_error(
"jack_get_current_transport_frame called with a NULL client");
1591 return client->GetCurrentTransportFrame();
1597 JackGlobals::CheckContext(
"jack_transport_reposition");
1600 if (client == NULL) {
1601 jack_error(
"jack_transport_reposition called with a NULL client");
1604 client->TransportReposition(pos);
1611 JackGlobals::CheckContext(
"jack_transport_start");
1614 if (client == NULL) {
1615 jack_error(
"jack_transport_start called with a NULL client");
1617 client->TransportStart();
1623 JackGlobals::CheckContext(
"jack_transport_stop");
1626 if (client == NULL) {
1627 jack_error(
"jack_transport_stop called with a NULL client");
1629 client->TransportStop();
1636 JackGlobals::CheckContext(
"jack_get_transport_info");
1638 jack_error(
"jack_get_transport_info: deprecated");
1645 JackGlobals::CheckContext(
"jack_set_transport_info");
1647 jack_error(
"jack_set_transport_info: deprecated");
1653 LIB_EXPORT
float jack_get_max_delayed_usecs(jack_client_t* ext_client)
1655 JackGlobals::CheckContext(
"jack_get_max_delayed_usecs");
1658 if (client == NULL) {
1659 jack_error(
"jack_get_max_delayed_usecs called with a NULL client");
1663 return (control ? control->fMaxDelayedUsecs : 0.f);
1667 LIB_EXPORT
float jack_get_xrun_delayed_usecs(jack_client_t* ext_client)
1669 JackGlobals::CheckContext(
"jack_get_xrun_delayed_usecs");
1672 if (client == NULL) {
1673 jack_error(
"jack_get_xrun_delayed_usecs called with a NULL client");
1677 return (control ? control->fXrunDelayedUsecs : 0.f);
1681 LIB_EXPORT
void jack_reset_max_delayed_usecs(jack_client_t* ext_client)
1683 JackGlobals::CheckContext(
"jack_reset_max_delayed_usecs");
1686 if (client == NULL) {
1687 jack_error(
"jack_reset_max_delayed_usecs called with a NULL client");
1690 control->ResetXRun();
1697 JackGlobals::CheckContext(
"jack_client_real_time_priority");
1700 if (client == NULL) {
1701 jack_error(
"jack_client_real_time_priority called with a NULL client");
1705 return (control->fRealTime) ? control->fClientPriority : -1;
1711 JackGlobals::CheckContext(
"jack_client_max_real_time_priority");
1714 if (client == NULL) {
1715 jack_error(
"jack_client_max_real_time_priority called with a NULL client");
1719 return (control->fRealTime) ? control->fMaxClientPriority : -1;
1727 ? JackThread::AcquireRealTimeImp(thread, priority, control->fPeriod, control->fComputation, control->fConstraint)
1732 jack_native_thread_t *thread,
1735 thread_routine routine,
1738 JackGlobals::CheckContext(
"jack_client_create_thread");
1741 int res = JackThread::StartImp(thread, priority, realtime, routine, arg);
1743 ? ((realtime ? JackThread::AcquireRealTimeImp(*thread, priority, control->fPeriod, control->fComputation, control->fConstraint) : res))
1749 return JackThread::DropRealTimeImp(thread);
1754 JackGlobals::CheckContext(
"jack_client_stop_thread");
1755 return JackThread::StopImp(thread);
1760 JackGlobals::CheckContext(
"jack_client_kill_thread");
1761 return JackThread::KillImp(thread);
1768 JackGlobals::fJackThreadCreator = pthread_create;
1770 JackGlobals::fJackThreadCreator = jtc;
1777 const char* load_name,
1778 const char* load_init)
1780 JackGlobals::CheckContext(
"jack_internal_client_new");
1781 jack_error(
"jack_internal_client_new: deprecated");
1787 JackGlobals::CheckContext(
"jack_internal_client_close");
1788 jack_error(
"jack_internal_client_close: deprecated");
1791 LIB_EXPORT
char* jack_get_internal_client_name(jack_client_t* ext_client, jack_intclient_t intclient)
1793 JackGlobals::CheckContext(
"jack_get_internal_client_name");
1796 if (client == NULL) {
1797 jack_error(
"jack_get_internal_client_name called with a NULL client");
1799 }
else if (intclient >= CLIENT_NUM) {
1800 jack_error(
"jack_get_internal_client_name: incorrect client");
1803 return client->GetInternalClientName(intclient);
1807 LIB_EXPORT jack_intclient_t jack_internal_client_handle(jack_client_t* ext_client,
const char* client_name, jack_status_t* status)
1809 JackGlobals::CheckContext(
"jack_internal_client_handle");
1812 if (client == NULL) {
1813 jack_error(
"jack_internal_client_handle called with a NULL client");
1816 jack_status_t my_status;
1818 status = &my_status;
1819 *status = (jack_status_t)0;
1820 return client->InternalClientHandle(client_name, status);
1824 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)
1826 JackGlobals::CheckContext(
"jack_internal_client_load_aux");
1829 if (client == NULL) {
1830 jack_error(
"jack_internal_client_load called with a NULL client");
1834 jack_status_t my_status;
1837 status = &my_status;
1838 *status = (jack_status_t)0;
1841 if ((options & ~JackLoadOptions)) {
1842 int my_status1 = *status | (JackFailure | JackInvalidOption);
1843 *status = (jack_status_t)my_status1;
1848 jack_varargs_parse(options, ap, &va);
1849 return client->InternalClientLoad(client_name, options, status, &va);
1853 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, ...)
1855 JackGlobals::CheckContext(
"jack_internal_client_load");
1858 va_start(ap, status);
1859 jack_intclient_t res = jack_internal_client_load_aux(client, client_name, options, status, ap);
1864 LIB_EXPORT jack_status_t jack_internal_client_unload(jack_client_t* ext_client, jack_intclient_t intclient)
1866 JackGlobals::CheckContext(
"jack_internal_client_load");
1869 if (client == NULL) {
1870 jack_error(
"jack_internal_client_unload called with a NULL client");
1871 return (jack_status_t)(JackNoSuchClient | JackFailure);
1872 }
else if (intclient >= CLIENT_NUM) {
1873 jack_error(
"jack_internal_client_unload: incorrect client");
1874 return (jack_status_t)(JackNoSuchClient | JackFailure);
1876 jack_status_t my_status;
1877 client->InternalClientUnload(intclient, &my_status);
1882 LIB_EXPORT
void jack_get_version(
int *major_ptr,
1887 JackGlobals::CheckContext(
"jack_get_version");
1896 LIB_EXPORT
const char* jack_get_version_string()
1898 JackGlobals::CheckContext(
"jack_get_version_string");
1902 LIB_EXPORT
void jack_free(
void* ptr)
1904 JackGlobals::CheckContext(
"jack_free");
1914 JackGlobals::CheckContext(
"jack_set_session_callback");
1917 jack_log(
"jack_set_session_callback ext_client %x client %x ", ext_client, client);
1918 if (client == NULL) {
1919 jack_error(
"jack_set_session_callback called with a NULL client");
1922 return client->SetSessionCallback(session_callback, arg);
1928 JackGlobals::CheckContext(
"jack_session_notify");
1931 jack_log(
"jack_session_notify ext_client %x client %x ", ext_client, client);
1932 if (client == NULL) {
1933 jack_error(
"jack_session_notify called with a NULL client");
1936 return client->SessionNotify(target, ev_type, path);
1942 JackGlobals::CheckContext(
"jack_session_reply");
1945 jack_log(
"jack_session_reply ext_client %x client %x ", ext_client, client);
1946 if (client == NULL) {
1947 jack_error(
"jack_session_reply called with a NULL client");
1950 return client->SessionReply(event);
1956 JackGlobals::CheckContext(
"jack_session_event_free");
1971 JackGlobals::CheckContext(
"jack_client_get_uuid");
1974 if (client == NULL) {
1975 jack_error(
"jack_client_get_uuid called with a NULL client");
1979 snprintf(retval,
sizeof(retval),
"%d", client->GetClientControl()->fSessionID);
1980 return strdup(retval);
1986 JackGlobals::CheckContext(
"jack_get_uuid_for_client_name");
1989 jack_log(
"jack_get_uuid_for_client_name ext_client %x client %x ", ext_client, client);
1990 if (client == NULL) {
1991 jack_error(
"jack_get_uuid_for_client_name called with a NULL client");
1994 return client->GetUUIDForClientName(client_name);
2000 JackGlobals::CheckContext(
"jack_get_client_name_by_uuid");
2003 jack_log(
"jack_get_uuid_for_client_name ext_client %x client %x ", ext_client, client);
2004 if (client == NULL) {
2005 jack_error(
"jack_get_client_name_by_uuid called with a NULL client");
2008 return client->GetClientNameByUUID(client_uuid);
2014 JackGlobals::CheckContext(
"jack_reserve_client_name");
2017 jack_log(
"jack_reserve_client_name ext_client %x client %x ", ext_client, client);
2018 if (client == NULL) {
2019 jack_error(
"jack_reserve_client_name called with a NULL client");
2022 return client->ReserveClientName(client_name, uuid);
2028 JackGlobals::CheckContext(
"jack_session_commands_free");
2037 if (cmds[i].client_name) {
2038 free ((
char *)cmds[i].client_name);
2040 if (cmds[i].command) {
2041 free ((
char *)cmds[i].command);
2044 free ((
char *)cmds[i].uuid);
2057 JackGlobals::CheckContext(
"jack_client_has_session_callback");
2060 jack_log(
"jack_client_has_session_callback ext_client %x client %x ", ext_client, client);
2061 if (client == NULL) {
2062 jack_error(
"jack_client_has_session_callback called with a NULL client");
2065 return client->ClientHasSessionCallback(client_name);
2069 LIB_EXPORT
int jack_set_property(jack_client_t*, jack_uuid_t,
const char*,
const char*,
const char*)
2113 LIB_EXPORT jack_uuid_t jack_client_uuid_generate()
2118 LIB_EXPORT jack_uuid_t jack_port_uuid_generate(uint32_t)
2123 LIB_EXPORT uint32_t jack_uuid_to_index(jack_uuid_t)
2128 LIB_EXPORT
int jack_uuid_compare(jack_uuid_t, jack_uuid_t)
2133 LIB_EXPORT
void jack_uuid_copy(jack_uuid_t*, jack_uuid_t)
2137 LIB_EXPORT
void jack_uuid_clear(jack_uuid_t*)
2141 LIB_EXPORT
int jack_uuid_parse(
const char*, jack_uuid_t*)
2146 LIB_EXPORT
void jack_uuid_unparse(jack_uuid_t,
char buf[JACK_UUID_STRING_SIZE])
2150 LIB_EXPORT
int jack_uuid_empty(jack_uuid_t)