1 /// C declarations of PulseAudio that libsoundio uses
2 module soundio.headers.pulseheader;
3 @nogc nothrow:
4 extern(C): __gshared:
5 
6 
7 // mainloop-api.h
8 struct pa_mainloop_api;
9 
10 // operation.h
11 struct pa_operation;
12 pa_operation_state_t pa_operation_get_state(pa_operation* o);
13 void pa_operation_unref(pa_operation* o);
14 
15 // proplist.h
16 struct pa_proplist;
17 pa_proplist* pa_proplist_new();
18 void pa_proplist_free(pa_proplist* p);
19 
20 //stream.h
21 struct pa_stream;
22 alias void function(pa_stream* s, int success, void* userdata) pa_stream_success_cb_t;
23 alias void function(pa_stream* p, size_t nbytes, void* userdata) pa_stream_request_cb_t;
24 alias void function(pa_stream* p, void* userdata) pa_stream_notify_cb_t;
25 
26 int pa_stream_begin_write(pa_stream* p, void** data, size_t* nbytes);
27 int pa_stream_connect_playback(pa_stream* s, const(char)* dev, const(pa_buffer_attr)* attr, pa_stream_flags_t flags, const(pa_cvolume)* volume, pa_stream* sync_stream);
28 int pa_stream_connect_record(pa_stream* s, const(char)* dev, const(pa_buffer_attr)* attr, pa_stream_flags_t flags);
29 pa_operation* pa_stream_cork(pa_stream* s, int b, pa_stream_success_cb_t cb, void* userdata);
30 int pa_stream_disconnect(pa_stream* s);
31 int pa_stream_drop(pa_stream* p);
32 int pa_stream_get_latency(pa_stream* s, pa_usec_t* r_usec, int* negative);
33 pa_stream_state_t pa_stream_get_state(pa_stream* p);
34 int pa_stream_is_corked(pa_stream* s);
35 pa_stream* pa_stream_new(pa_context* c, const(char)* name, const(pa_sample_spec)* ss, const(pa_channel_map)* map);
36 int pa_stream_peek(pa_stream* p, const(void)** data, size_t* nbytes);
37 void pa_stream_set_overflow_callback(pa_stream* p, pa_stream_notify_cb_t cb, void* userdata);
38 void pa_stream_set_read_callback(pa_stream* p, pa_stream_request_cb_t cb, void* userdata);
39 void pa_stream_set_state_callback(pa_stream* s, pa_stream_notify_cb_t cb, void* userdata);
40 void pa_stream_set_underflow_callback(pa_stream* p, pa_stream_notify_cb_t cb, void* userdata);
41 void pa_stream_set_write_callback(pa_stream* p, pa_stream_request_cb_t cb, void* userdata);
42 void pa_stream_unref(pa_stream* s);
43 pa_operation* pa_stream_update_timing_info(pa_stream* p, pa_stream_success_cb_t cb, void* userdata);
44 size_t pa_stream_writable_size(pa_stream* p);
45 int pa_stream_write(pa_stream* p, const(void)* data, size_t nbytes, pa_free_cb_t free_cb, long offset, pa_seek_mode_t seek);
46 
47 // def.h
48 alias void function(void* p) pa_free_cb_t;
49 
50 alias pa_stream_flags_t = int; // C enum
51 enum {
52     PA_STREAM_NOFLAGS = 0x0000U,
53     PA_STREAM_START_CORKED = 0x0001U,
54     PA_STREAM_INTERPOLATE_TIMING = 0x0002U,
55     PA_STREAM_NOT_MONOTONIC = 0x0004U,
56     PA_STREAM_AUTO_TIMING_UPDATE = 0x0008U,
57     PA_STREAM_NO_REMAP_CHANNELS = 0x0010U,
58     PA_STREAM_NO_REMIX_CHANNELS = 0x0020U,
59     PA_STREAM_FIX_FORMAT = 0x0040U,
60     PA_STREAM_FIX_RATE = 0x0080U,
61     PA_STREAM_FIX_CHANNELS = 0x0100,
62     PA_STREAM_DONT_MOVE = 0x0200U,
63     PA_STREAM_VARIABLE_RATE = 0x0400U,
64     PA_STREAM_PEAK_DETECT = 0x0800U,
65     PA_STREAM_START_MUTED = 0x1000U,
66     PA_STREAM_ADJUST_LATENCY = 0x2000U,
67     PA_STREAM_EARLY_REQUESTS = 0x4000U,
68     PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND = 0x8000U,
69     PA_STREAM_START_UNMUTED = 0x10000U,
70     PA_STREAM_FAIL_ON_SUSPEND = 0x20000U,
71     PA_STREAM_RELATIVE_VOLUME = 0x40000U,
72     PA_STREAM_PASSTHROUGH = 0x80000U
73 }
74 
75 struct pa_spawn_api {
76 	extern(C): @nogc: nothrow:
77     void function() prefork;
78     void function() postfork;
79     void function() atfork;
80 }
81 
82 // thread-mainloop.h
83 struct pa_threaded_mainloop;
84 pa_threaded_mainloop *pa_threaded_mainloop_new();
85 void pa_threaded_mainloop_free(pa_threaded_mainloop* m);
86 int pa_threaded_mainloop_start(pa_threaded_mainloop* m);
87 void pa_threaded_mainloop_stop(pa_threaded_mainloop* m);
88 void pa_threaded_mainloop_lock(pa_threaded_mainloop* m);
89 void pa_threaded_mainloop_unlock(pa_threaded_mainloop* m);
90 void pa_threaded_mainloop_wait(pa_threaded_mainloop* m);
91 void pa_threaded_mainloop_signal(pa_threaded_mainloop* m, int wait_for_accept);
92 pa_mainloop_api* pa_threaded_mainloop_get_api(pa_threaded_mainloop* m);
93 int pa_threaded_mainloop_in_thread(pa_threaded_mainloop* m);
94 
95 // context.h
96 struct pa_context;
97 alias void function(pa_context* c, void* userdata) pa_context_notify_cb_t;
98 alias void function(pa_context* c, int success, void* userdata) pa_context_success_cb_t;
99 
100 alias pa_context_flags_t = int; // C enum
101 int pa_context_connect(pa_context* c, const(char)* server, pa_context_flags_t flags, const(pa_spawn_api)* api);
102 void pa_context_disconnect(pa_context* c);
103 pa_context_state_t pa_context_get_state(pa_context* c);
104 pa_context* pa_context_new_with_proplist(pa_mainloop_api* mainloop, const(char)* name, pa_proplist* proplist);
105 void pa_context_set_state_callback(pa_context* c, pa_context_notify_cb_t cb, void* userdata);
106 void pa_context_unref(pa_context* c);
107 
108 // subscribe.h
109 alias pa_subscription_mask_t = int; // C enum
110 enum {
111     PA_SUBSCRIPTION_MASK_NULL = 0x0000U,
112     PA_SUBSCRIPTION_MASK_SINK = 0x0001U,
113     PA_SUBSCRIPTION_MASK_SOURCE = 0x0002U,
114     PA_SUBSCRIPTION_MASK_SINK_INPUT = 0x0004U,
115     PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT = 0x0008U,
116     PA_SUBSCRIPTION_MASK_MODULE = 0x0010U,
117     PA_SUBSCRIPTION_MASK_CLIENT = 0x0020U,
118     PA_SUBSCRIPTION_MASK_SAMPLE_CACHE = 0x0040U,
119     PA_SUBSCRIPTION_MASK_SERVER = 0x0080U,
120     PA_SUBSCRIPTION_MASK_AUTOLOAD = 0x0100U,
121     PA_SUBSCRIPTION_MASK_CARD = 0x0200U,
122     PA_SUBSCRIPTION_MASK_ALL = 0x02ffU
123 }
124 
125 alias void function(pa_context* c, pa_subscription_event_type_t t, uint idx, void* userdata) pa_context_subscribe_cb_t;
126 pa_operation* pa_context_subscribe(pa_context* c, pa_subscription_mask_t m, pa_context_success_cb_t cb, void* userdata);
127 void pa_context_set_subscribe_callback(pa_context* c, pa_context_subscribe_cb_t cb, void* userdata);
128 
129 // introspect.h
130 alias void function(pa_context* c, const(pa_server_info)* i, void* userdata) pa_server_info_cb_t;
131 pa_operation* pa_context_get_server_info(pa_context* c, pa_server_info_cb_t cb, void* userdata);
132 alias void function(pa_context* c, const(pa_sink_info)* i, int eol, void* userdata) pa_sink_info_cb_t;
133 pa_operation* pa_context_get_sink_info_list(pa_context* c, pa_sink_info_cb_t cb, void* userdata);
134 alias void function(pa_context* c, const(pa_source_info)* i, int eol, void* userdata) pa_source_info_cb_t;
135 pa_operation* pa_context_get_source_info_list(pa_context* c, pa_source_info_cb_t cb, void* userdata);
136 
137 alias pa_volume_t = uint;
138 alias pa_usec_t = ulong;
139 
140 alias pa_sink_flags_t = int; // C enum
141 alias pa_sink_state_t = int; // C enum
142 alias pa_source_flags_t = int; // C enum
143 alias pa_source_state_t = int; // C enum
144 
145 struct pa_cvolume {
146     ubyte channels;
147     pa_volume_t[PA_CHANNELS_MAX] values;
148 }
149 
150 alias pa_encoding_t = int; // C enum
151 struct pa_format_info {
152     pa_encoding_t encoding;
153     pa_proplist *plist;
154 }
155 
156 struct pa_sink_port_info {
157     const(char)* name;
158     const(char)* description;
159     uint priority;
160     int available;
161 }
162 
163 struct pa_source_port_info {
164     const(char)* name;
165     const(char)* description;
166     uint priority;
167     int available;
168 }
169 
170 struct pa_server_info {
171     const(char)* user_name;
172     const(char)* host_name;
173     const(char)* server_version;
174     const(char)* server_name;
175     pa_sample_spec sample_spec;
176     const(char)* default_sink_name;
177     const(char)* default_source_name;
178     uint cookie;
179     pa_channel_map channel_map;
180 }
181 
182 struct pa_sink_info {
183     const(char)* name;
184     uint index;
185     const(char)* description;
186     pa_sample_spec sample_spec;
187     pa_channel_map channel_map;
188     uint owner_module;
189     pa_cvolume volume;
190     int mute;
191     uint monitor_source;
192     const(char)* monitor_source_name;
193     pa_usec_t latency;
194     const(char)* driver;
195     pa_sink_flags_t flags;
196     pa_proplist* proplist;
197     pa_usec_t configured_latency;
198     pa_volume_t base_volume;
199     pa_sink_state_t state;
200     uint n_volume_steps;
201     uint card;
202     uint n_ports;
203     pa_sink_port_info** ports;
204     pa_sink_port_info* active_port;
205     ubyte n_formats;
206     pa_format_info** formats;
207 }
208 
209 struct pa_source_info {
210     const(char)* name;
211     uint index;
212     const(char)* description;
213     pa_sample_spec sample_spec;
214     pa_channel_map channel_map;
215     uint owner_module;
216     pa_cvolume volume;
217     int mute;
218     uint monitor_of_sink;
219     const(char)* monitor_of_sink_name;
220     pa_usec_t latency;
221     const(char)* driver;
222     pa_source_flags_t flags;
223     pa_proplist* proplist;
224     pa_usec_t configured_latency;
225     pa_volume_t base_volume;
226     pa_source_state_t state;
227     uint n_volume_steps;
228     uint card;
229     uint n_ports;
230     pa_source_port_info** ports;
231     pa_source_port_info* active_port;
232     ubyte n_formats;
233     pa_format_info** formats;
234 }
235 
236 struct pa_buffer_attr {
237     uint maxlength;
238     uint tlength;
239     uint prebuf;
240     uint minreq;
241     uint fragsize;
242 }
243 
244 enum PA_CHANNELS_MAX = 32;
245 struct pa_channel_map {
246 	ubyte channels;
247 	pa_channel_position_t[PA_CHANNELS_MAX] map;
248 }
249 struct pa_sample_spec {
250 	pa_sample_format_t format;
251 	uint rate;
252 	ubyte channels;
253 }
254 
255 alias pa_context_state_t = int; // C enum
256 enum {
257 	PA_CONTEXT_UNCONNECTED,
258 	PA_CONTEXT_CONNECTING,
259 	PA_CONTEXT_AUTHORIZING,
260 	PA_CONTEXT_SETTING_NAME,
261 	PA_CONTEXT_READY,
262 	PA_CONTEXT_FAILED,
263 	PA_CONTEXT_TERMINATED
264 }
265 
266 alias pa_operation_state_t = int; // C enum
267 enum {
268 	PA_OPERATION_RUNNING,
269 	PA_OPERATION_DONE,
270 	PA_OPERATION_CANCELLED
271 }
272 
273 alias pa_seek_mode_t = int;
274 enum {
275     PA_SEEK_RELATIVE = 0,
276     PA_SEEK_ABSOLUTE = 1,
277     PA_SEEK_RELATIVE_ON_READ = 2,
278     PA_SEEK_RELATIVE_END = 3
279 }
280 
281 alias pa_stream_state_t = int; // C enum
282 enum {
283 	PA_STREAM_UNCONNECTED,
284 	PA_STREAM_CREATING,
285 	PA_STREAM_READY,
286 	PA_STREAM_FAILED,
287 	PA_STREAM_TERMINATED
288 }
289 
290 alias pa_channel_position_t = int; // C enum
291 enum {
292 	PA_CHANNEL_POSITION_INVALID = -1,
293 	PA_CHANNEL_POSITION_MONO = 0,
294 	PA_CHANNEL_POSITION_FRONT_LEFT,
295 	PA_CHANNEL_POSITION_FRONT_RIGHT,
296 	PA_CHANNEL_POSITION_FRONT_CENTER,
297 	PA_CHANNEL_POSITION_LEFT = PA_CHANNEL_POSITION_FRONT_LEFT,
298 	PA_CHANNEL_POSITION_RIGHT = PA_CHANNEL_POSITION_FRONT_RIGHT,
299 	PA_CHANNEL_POSITION_CENTER = PA_CHANNEL_POSITION_FRONT_CENTER,
300 	PA_CHANNEL_POSITION_REAR_CENTER,
301 	PA_CHANNEL_POSITION_REAR_LEFT,
302 	PA_CHANNEL_POSITION_REAR_RIGHT,
303 	PA_CHANNEL_POSITION_LFE,
304 	PA_CHANNEL_POSITION_SUBWOOFER = PA_CHANNEL_POSITION_LFE,
305 	PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER,
306 	PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER,
307 	PA_CHANNEL_POSITION_SIDE_LEFT,
308 	PA_CHANNEL_POSITION_SIDE_RIGHT,
309 	PA_CHANNEL_POSITION_AUX0,
310 	PA_CHANNEL_POSITION_AUX1,
311 	PA_CHANNEL_POSITION_AUX2,
312 	PA_CHANNEL_POSITION_AUX3,
313 	PA_CHANNEL_POSITION_AUX4,
314 	PA_CHANNEL_POSITION_AUX5,
315 	PA_CHANNEL_POSITION_AUX6,
316 	PA_CHANNEL_POSITION_AUX7,
317 	PA_CHANNEL_POSITION_AUX8,
318 	PA_CHANNEL_POSITION_AUX9,
319 	PA_CHANNEL_POSITION_AUX10,
320 	PA_CHANNEL_POSITION_AUX11,
321 	PA_CHANNEL_POSITION_AUX12,
322 	PA_CHANNEL_POSITION_AUX13,
323 	PA_CHANNEL_POSITION_AUX14,
324 	PA_CHANNEL_POSITION_AUX15,
325 	PA_CHANNEL_POSITION_AUX16,
326 	PA_CHANNEL_POSITION_AUX17,
327 	PA_CHANNEL_POSITION_AUX18,
328 	PA_CHANNEL_POSITION_AUX19,
329 	PA_CHANNEL_POSITION_AUX20,
330 	PA_CHANNEL_POSITION_AUX21,
331 	PA_CHANNEL_POSITION_AUX22,
332 	PA_CHANNEL_POSITION_AUX23,
333 	PA_CHANNEL_POSITION_AUX24,
334 	PA_CHANNEL_POSITION_AUX25,
335 	PA_CHANNEL_POSITION_AUX26,
336 	PA_CHANNEL_POSITION_AUX27,
337 	PA_CHANNEL_POSITION_AUX28,
338 	PA_CHANNEL_POSITION_AUX29,
339 	PA_CHANNEL_POSITION_AUX30,
340 	PA_CHANNEL_POSITION_AUX31,
341 	PA_CHANNEL_POSITION_TOP_CENTER,
342 	PA_CHANNEL_POSITION_TOP_FRONT_LEFT,
343 	PA_CHANNEL_POSITION_TOP_FRONT_RIGHT,
344 	PA_CHANNEL_POSITION_TOP_FRONT_CENTER,
345 	PA_CHANNEL_POSITION_TOP_REAR_LEFT,
346 	PA_CHANNEL_POSITION_TOP_REAR_RIGHT,
347 	PA_CHANNEL_POSITION_TOP_REAR_CENTER,
348 	PA_CHANNEL_POSITION_MAX
349 }
350 alias pa_subscription_event_type_t = int;
351 enum {
352 	PA_SUBSCRIPTION_EVENT_SINK = 0x0000U,
353 	PA_SUBSCRIPTION_EVENT_SOURCE = 0x0001U,
354 	PA_SUBSCRIPTION_EVENT_SINK_INPUT = 0x0002U,
355 	PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT = 0x0003U,
356 	PA_SUBSCRIPTION_EVENT_MODULE = 0x0004U,
357 	PA_SUBSCRIPTION_EVENT_CLIENT = 0x0005U,
358 	PA_SUBSCRIPTION_EVENT_SAMPLE_CACHE = 0x0006U,
359 	PA_SUBSCRIPTION_EVENT_SERVER = 0x0007U,
360 	PA_SUBSCRIPTION_EVENT_AUTOLOAD = 0x0008U,
361 	PA_SUBSCRIPTION_EVENT_CARD = 0x0009U,
362 	PA_SUBSCRIPTION_EVENT_FACILITY_MASK = 0x000FU,
363 	PA_SUBSCRIPTION_EVENT_NEW = 0x0000U,
364 	PA_SUBSCRIPTION_EVENT_CHANGE = 0x0010U,
365 	PA_SUBSCRIPTION_EVENT_REMOVE = 0x0020U,
366 	PA_SUBSCRIPTION_EVENT_TYPE_MASK = 0x0030U
367 }
368 alias pa_sample_format_t = int;
369 enum {
370 	PA_SAMPLE_U8,
371 	PA_SAMPLE_ALAW,
372 	PA_SAMPLE_ULAW,
373 	PA_SAMPLE_S16LE,
374 	PA_SAMPLE_S16BE,
375 	PA_SAMPLE_FLOAT32LE,
376 	PA_SAMPLE_FLOAT32BE,
377 	PA_SAMPLE_S32LE,
378 	PA_SAMPLE_S32BE,
379 	PA_SAMPLE_S24LE,
380 	PA_SAMPLE_S24BE,
381 	PA_SAMPLE_S24_32LE,
382 	PA_SAMPLE_S24_32BE,
383 	PA_SAMPLE_MAX,
384 	PA_SAMPLE_INVALID = -1
385 }