Start 'katia', more jacklib functions, some fixes
[klaudia.git] / src / jacklib.py
blob05443074abd2b7d1eb57dce981b130d4c00230fd
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
5 # Imports
6 from ctypes import *
9 # Load Jack shared library
10 jacklib = cdll.LoadLibrary("libjack.so.0")
13 # Functions
15 def get_version_string():
16 jacklib.jack_get_version_string.restype = c_char_p
17 return jacklib.jack_get_version_string()
19 def client_open(client_name, options, status):
20 return jacklib.jack_client_open(client_name, options, status)
22 def client_close(client):
23 jacklib.jack_client_close.restype = c_int
24 return jacklib.jack_client_close(client)
26 def client_name_size():
27 jacklib.jack_client_name_size.restype = c_int
28 return jacklib.jack_client_name_size()
30 def client_name(client):
31 jacklib.jack_get_client_name.restype = c_char_p
32 return jacklib.jack_get_client_name(client)
34 def activate(client):
35 jacklib.jack_activate.restype = c_int
36 return jacklib.jack_activate(client)
38 def deactivate(client):
39 jacklib.jack_deactivate.restype = c_int
40 return jacklib.jack_deactivate(client)
42 def get_client_pid(client):
43 jacklib.jack_get_client_pid.restype = c_int
44 return jacklib.jack_get_client_pid(client)
46 def get_client_thread_id(client):
47 return jacklib.jack_get_client_thread_id(client)
49 def is_realtime(client):
50 jacklib.jack_is_realtime.restype = c_bool
51 return jacklib.jack_is_realtime(client)
55 # NOTE - NonCallbackAPI functions were skipped, not really useful here
59 # ClientCallbacks
61 def set_thread_init_callback(client, thread_init_callback, arg=None):
62 jacklib.jack_set_thread_init_callback.restype = c_int
63 return jacklib.jack_set_thread_init_callback(client, thread_init_callback, arg)
65 def on_shutdown(client, shutdown_callback, arg=None):
66 jacklib.jack_on_shutdown(client, shutdown_callback, arg)
68 def on_info_shutdown(client, shutdown_callback, arg=None):
69 jacklib.jack_on_info_shutdown(client, shutdown_callback, arg)
71 def set_process_callback(client, process_callback, arg=None):
72 jacklib.jack_set_process_callback.restype = c_int
73 return jacklib.jack_set_(client, process_callback, arg)
75 def set_freewheel_callback(client, freewheel_callback, arg=None):
76 jacklib.jack_set_freewheel_callback.restype = c_int
77 return jacklib.jack_set_(client, freewheel_callback, arg)
79 def set_buffer_size_callback(client, buffer_size_callback, arg=None):
80 jacklib.jack_set_buffer_size_callback.restype = c_int
81 return jacklib.jack_set_(client, buffer_size_callback, arg)
83 def set_sample_rate_callback(client, srate_callback, arg=None):
84 jacklib.jack_set_sample_rate_callback.restype = c_int
85 return jacklib.jack_set_sample_rate_callback(client, srate_callback, arg)
87 def set_client_registration_callback(client, registration_callback, arg=None):
88 jacklib.jack_set_client_registration_callback.restype = c_int
89 return jacklib.jack_set_client_registration_callback(client, registration_callback, arg)
91 def set_port_registration_callback(client, registration_callback, arg=None):
92 jacklib.jack_set_port_registration_callback.restype = c_int
93 return jacklib.jack_set_port_registration_callback(client, registration_callback, arg)
95 def set_port_connect_callback(client, connect_callback, arg=None):
96 jacklib.jack_set_port_connect_callback.restype = c_int
97 return jacklib.jack_set_port_connect_callback(client, connect_callback, arg)
99 def set_port_rename_callback(client, rename_callback, arg=None):
100 jacklib.jack_set_port_rename_callback.restype = c_int
101 return jacklib.jack_set_port_rename_callback(client, rename_callback, arg)
103 def set_graph_order_callback(client, graph_callback, arg=None):
104 jacklib.jack_set_graph_order_callback.restype = c_int
105 return jacklib.jack_set_graph_order_callback(client, graph_callback, arg)
107 def set_xrun_callback(client, xrun_callback, arg=None):
108 jacklib.jack_set_xrun_callback.restype = c_int
109 return jacklib.jack_set_(client, xrun_callback, arg)
113 # ServerClientControl
115 def set_freewheel(client, onoff):
116 jacklib.jack_set_freewheel.restype = c_int
117 return jacklib.jack_set_freewheel(onoff)
119 def set_buffer_size(client, nframes):
120 jacklib.jack_set_buffer_size.restype = c_int
121 return jacklib.jack_set_buffer_size(nframes)
123 def get_sample_rate(client):
124 return jacklib.jack_get_sample_rate(client)
126 def get_buffer_size(client):
127 return jacklib.jack_get_buffer_size(client)
129 def cpu_load(client):
130 jacklib.jack_cpu_load.restype = c_float
131 return jacklib.jack_cpu_load(client)
135 # PortFunctions
137 def port_register(client, port_name, port_type, flags, buffer_size):
138 return jacklib.jack_port_register(client, port_name, port_type, flags, buffer_size)
140 def port_unregister(client, port):
141 jacklib.jack_port_unregister.restype = c_int
142 return jacklib.jack_port_unregister(client, port)
144 def port_name(port):
145 jacklib.jack_port_name.restype = c_char_p
146 return jacklib.jack_port_name(port)
148 def port_short_name(port):
149 jacklib.jack_port_short_name.restype = c_char_p
150 return jacklib.jack_port_short_name(port)
152 def port_flags(port):
153 jacklib.jack_port_flags.restype = c_int
154 return jacklib.jack_port_flags(port)
156 def port_type(port):
157 jacklib.jack_port_type.restype = c_char_p
158 return jacklib.jack_port_type(port)
160 def port_type_id(port):
161 return jacklib.jack_port_type_id(port)
163 def port_is_mine(client, port):
164 jacklib.jack_port_is_mine.restype = c_int
165 return jacklib.jack_port_is_mine(client, port)
167 def port_connected(port):
168 jacklib.jack_port_connected.restype = c_int
169 return jacklib.jack_port_connected(port)
171 def port_connected_to(port, port_name):
172 jacklib.jack_port_connected_to.restype = c_int
173 return jacklib.jack_port_connected_to(port, port_name)
175 def port_get_connections(port): # TODO - char**
176 return jacklib.jack_port_get_connections(client, port)
178 def port_get_all_connections(client, port): # TODO - char**
179 return jacklib.jack_port_get_all_connections(client, port)
181 def port_get_latency(port):
182 return jacklib.jack_port_get_latency(port)
184 def port_get_total_latency(client, port):
185 return jacklib.jack_port_get_total_latency(client, port)
187 def port_set_latency(port, nframes):
188 jacklib.jack_port_set_latency(port, nframes)
190 def recompute_total_latency(client, port):
191 jacklib.jack_recompute_total_latency.restype = c_int
192 return jacklib.jack_recompute_total_latency(client, port)
194 def jack_recompute_total_latencies():
195 jacklib.jack_recompute_total_latencies.restype = c_int
196 return jacklib.jack_jack_recompute_total_latencies()
198 def port_set_name(port, port_name):
199 jacklib.jack_port_set_name.restype = c_int
200 return jacklib.jack_port_set_name(port, port_name)
202 def port_set_alias(port, alias):
203 jacklib.jack_port_set_alias.restype = c_int
204 return jacklib.jack_port_set_alias(port, alias)
206 def port_unset_alias(port, alias):
207 jacklib.jack_port_unset_alias.restype = c_int
208 return jacklib.jack_port_unset_alias(port, alias)
210 def port_get_aliases(port, aliases):
211 jacklib.jack_port_get_aliases.restype = c_int
212 return jacklib.jack_port_get_aliases(port, aliases)
214 def port_request_monitor(port, onoff):
215 jacklib.jack_port_request_monitor.restype = c_int
216 return jacklib.jack_port_request_monitor(port, onoff)
218 def port_request_monitor_by_name(client, port_name, onoff):
219 jacklib.jack_port_request_monitor_by_name.restype = c_int
220 return jacklib.jack_port_request_monitor_by_name(client, port_name, onoff)
222 def port_ensure_monitor(port, onoff):
223 jacklib.jack_port_ensure_monitor.restype = c_int
224 return jacklib.jack_port_ensure_monitor(port, onoff)
226 def port_monitoring_input(port):
227 jacklib.jack_port_monitoring_input.restype = c_int
228 return jacklib.jack_port_monitoring_input(port)
230 def jack_connect(client, source_port, destination_port):
231 jacklib.jack_connect.restype = c_int
232 return jacklib.jack_jack_connect(client, source_port, destination_port)
234 def disconnect(client, source_port, destination_port):
235 jacklib.jack_disconnect.restype = c_int
236 return jacklib.jack_disconnect(client, source_port, destination_port)
238 def port_disconnect(client, port):
239 jacklib.jack_port_disconnect.restype = c_int
240 return jacklib.jack_port_disconnect(client, port)
242 def port_name_size():
243 jacklib.jack_port_name_size.restype = c_int
244 return jacklib.jack_port_name_size()
246 def port_type_size():
247 jacklib.jack_port_type_size.restype = c_int
248 return jacklib.jack_port_type_size()
252 # PortSearching
254 def get_ports(client, port_name_pattern=None, type_name_pattern=None, flags=None): # TODO - char**
255 #jacklib.jack_get_ports.restype = ???
256 return jacklib.jack_get_ports(client, port_name_pattern, type_name_pattern, flags)
258 def port_by_name(client, port_name):
259 return jacklib.jack_port_by_name(client, port_name)
261 def port_by_id(client, port_id):
262 return jacklib.jack_port_by_id(client, port_id)
266 # TimeFunctions
268 # TODO - write the rest of the stuff...