1 /// C declarations of JACK that libsoundio uses
2 module soundio.headers.jackheader;
3 
4 extern(C): @nogc: nothrow: __gshared:
5 
6 import core.stdc.config: c_long, c_ulong;
7 
8 enum JACK_DEFAULT_AUDIO_TYPE = "32 bit float mono audio";
9 
10 alias jack_nframes_t = uint;
11 alias jack_port_id_t = uint;
12 
13 struct jack_latency_range_t {
14     jack_nframes_t min;
15     jack_nframes_t max;
16 }
17 
18 struct jack_client_t;
19 struct jack_port_t;
20 
21 alias int function(jack_nframes_t nframes, void* arg) JackBufferSizeCallback;
22 alias int function(jack_nframes_t nframes, void* arg) JackSampleRateCallback;
23 alias void function(jack_port_id_t port, int, void* arg) JackPortRegistrationCallback;
24 alias void function(jack_port_id_t port, const(char)* old_name, const(char)* new_name, void* arg) JackPortRenameCallback;
25 alias void function(void* arg) JackShutdownCallback;
26 alias int function(jack_nframes_t nframes, void* arg) JackProcessCallback;
27 alias int function(void* arg) JackXRunCallback;
28 
29 alias jack_latency_callback_mode_t = int; // C enum; JackLatencyCallbackMode
30 enum {
31     JackCaptureLatency,
32     JackPlaybackLatency,
33 }
34 
35 // JackPortFlags
36 enum {
37     JackPortIsInput = 0x1,
38     JackPortIsOutput = 0x2,
39     JackPortIsPhysical = 0x4,
40     JackPortCanMonitor = 0x8,
41     JackPortIsTerminal = 0x10
42 }
43 
44 alias jack_status_t = int; // C enum
45 enum {
46     JackFailure = 0x01,
47     JackInvalidOption = 0x02,
48     JackNameNotUnique = 0x04,
49     JackServerStarted = 0x08,
50     JackServerFailed = 0x10,
51     JackServerError = 0x20,
52     JackNoSuchClient = 0x40,
53     JackLoadFailure = 0x80,
54     JackInitFailure = 0x100,
55     JackShmFailure = 0x200,
56     JackVersionError = 0x400,
57     JackBackendError = 0x800,
58     JackClientZombie = 0x1000
59 }
60 
61 alias jack_options_t = int;
62 enum {
63     JackNullOption = 0x00,
64     JackNoStartServer = 0x01,
65     JackUseExactName = 0x02,
66     JackServerName = 0x04,
67     JackLoadName = 0x08,
68     JackLoadInit = 0x10,
69     JackSessionID = 0x20
70 }
71 
72 void jack_free(void* ptr);
73 int jack_set_buffer_size_callback(jack_client_t* client, JackBufferSizeCallback bufsize_callback, void* arg);
74 int jack_set_sample_rate_callback(jack_client_t* client, JackSampleRateCallback srate_callback, void* arg);
75 jack_port_t* jack_port_by_name(jack_client_t*, const(char)* port_name);
76 int jack_port_flags(const(jack_port_t)* port);
77 const(char)* jack_port_type(const(jack_port_t)* port);
78 void jack_port_get_latency_range(jack_port_t* port, jack_latency_callback_mode_t mode, jack_latency_range_t* range);
79 const(char)** jack_get_ports(jack_client_t*, const(char)* port_name_pattern, const(char)* type_name_pattern, c_ulong flags);
80 jack_nframes_t jack_get_sample_rate(jack_client_t*);
81 jack_nframes_t jack_get_buffer_size(jack_client_t*);
82 int jack_activate(jack_client_t* client);
83 int jack_set_port_rename_callback(jack_client_t*, JackPortRenameCallback rename_callback, void* arg);
84 int jack_set_port_registration_callback(jack_client_t*, JackPortRegistrationCallback registration_callback, void* arg);
85 jack_client_t* jack_client_open(const(char)* client_name, jack_options_t options, jack_status_t* status, ...);
86 void jack_set_info_function(void function(const(char)*) func);
87 void jack_on_shutdown(jack_client_t* client, JackShutdownCallback function_, void* arg);
88 void jack_set_error_function(void function(const(char)*) func);
89 int jack_client_close(jack_client_t* client);
90 int jack_connect(jack_client_t*, const(char)* source_port, const(char)* destination_port);
91 const(char)* jack_port_name(const(jack_port_t)* port);
92 void* jack_port_get_buffer(jack_port_t*, jack_nframes_t);
93 int jack_set_process_callback(jack_client_t* client, JackProcessCallback process_callback, void* arg);
94 int jack_set_xrun_callback(jack_client_t*, JackXRunCallback xrun_callback, void* arg);
95 jack_port_t* jack_port_register(jack_client_t* client, const(char)* port_name, const(char)* port_type, c_ulong flags, c_ulong buffer_size);