1#![allow(non_camel_case_types)]
2#![allow(non_snake_case)]
3
4use self::super::libc_sys::timeval;
5use std::os::raw::{
6 c_void,
7 c_uint,
8 c_char,
9 c_int,
10 };
11
12pub type pa_io_event_flags = c_uint;
13pub use self::pa_io_event_flags as pa_io_event_flags_t;
14pub type pa_context_flags = c_uint;
15pub use self::pa_context_flags as pa_context_flags_t;
16pub type pa_context_state = c_uint;
17pub use self::pa_context_state as pa_context_state_t;
18pub type pa_source_state = c_int;
19pub use self::pa_source_state as pa_source_state_t;
20pub type pa_sample_format = c_int;
21pub use self::pa_sample_format as pa_sample_format_t;
22pub type pa_channel_map_def = c_uint;
23pub use self::pa_channel_map_def as pa_channel_map_def_t;
24pub type pa_channel_position = c_int;
25pub use self::pa_channel_position as pa_channel_position_t;
26pub type pa_volume_t = u32;
27pub type pa_usec_t = u64;
28pub type pa_sink_flags = c_uint;
29pub use self::pa_sink_flags as pa_sink_flags_t;
30pub type pa_sink_state = c_int;
31pub use self::pa_sink_state as pa_sink_state_t;
32pub type pa_encoding = c_int;
33pub use self::pa_encoding as pa_encoding_t;
34pub type pa_source_flags = c_uint;
35pub use self::pa_source_flags as pa_source_flags_t;
36pub type pa_operation_state = c_uint;
37pub use self::pa_operation_state as pa_operation_state_t;
38pub type pa_subscription_event_type = c_uint;
39pub use self::pa_subscription_event_type as pa_subscription_event_type_t;
40pub type pa_stream_state = c_uint;
41pub use self::pa_stream_state as pa_stream_state_t;
42pub type pa_seek_mode = c_uint;
43pub use self::pa_seek_mode as pa_seek_mode_t;
44pub type pa_stream_flags = c_uint;
45pub use self::pa_stream_flags as pa_stream_flags_t;
46
47pub const PA_OPERATION_RUNNING: pa_operation_state = 0;
48pub const PA_OPERATION_DONE: pa_operation_state = 1;
49pub const PA_OPERATION_CANCELLED: pa_operation_state = 2;
50
51pub const PA_CONTEXT_UNCONNECTED: pa_context_state = 0;
52pub const PA_CONTEXT_CONNECTING: pa_context_state = 1;
53pub const PA_CONTEXT_AUTHORIZING: pa_context_state = 2;
54pub const PA_CONTEXT_SETTING_NAME: pa_context_state = 3;
55pub const PA_CONTEXT_READY: pa_context_state = 4;
56pub const PA_CONTEXT_FAILED: pa_context_state = 5;
57pub const PA_CONTEXT_TERMINATED: pa_context_state = 6;
58
59pub const PA_SAMPLE_FLOAT32LE: pa_sample_format = 5;
60
61pub const PA_CHANNEL_POSITION_INVALID: pa_channel_position = -1;
62pub const PA_CHANNEL_POSITION_LEFT: pa_channel_position = 1;
63pub const PA_CHANNEL_POSITION_RIGHT: pa_channel_position = 2;
64
65pub const PA_STREAM_UNCONNECTED: pa_stream_state = 0;
66pub const PA_STREAM_CREATING: pa_stream_state = 1;
67pub const PA_STREAM_READY: pa_stream_state = 2;
68pub const PA_STREAM_FAILED: pa_stream_state = 3;
69pub const PA_STREAM_TERMINATED: pa_stream_state = 4;
70
71pub const PA_SEEK_RELATIVE: pa_seek_mode = 0;
72pub const PA_SEEK_RELATIVE_ON_READ: pa_seek_mode = 2;
73
74pub const PA_STREAM_START_CORKED: pa_stream_flags = 1;
75pub const PA_STREAM_INTERPOLATE_TIMING: pa_stream_flags = 2;
76pub const PA_STREAM_AUTO_TIMING_UPDATE: pa_stream_flags = 8;
77pub const PA_STREAM_ADJUST_LATENCY: pa_stream_flags = 8192;
78pub const PA_STREAM_START_UNMUTED: pa_stream_flags = 65536;
79
80pub const PA_CHANNEL_MAP_DEFAULT: pa_channel_map_def = 0;
81
82
83#[repr(C)]
84#[derive(Debug, Copy, Clone)]
85pub struct pa_time_event {
86 _unused: [u8; 0],
87}
88
89#[repr(C)]
90#[derive(Debug, Copy, Clone)]
91pub struct pa_defer_event {
92 _unused: [u8; 0],
93}
94
95#[repr(C)]
96#[derive(Debug, Copy, Clone)]
97pub struct pa_context {
98 _unused: [u8; 0],
99}
100
101pub type pa_context_notify_cb_t = ::std::option::Option<
102unsafe extern "C" fn(c: *mut pa_context, userdata: *mut c_void),
103>;
104
105pub type pa_defer_event_destroy_cb_t = ::std::option::Option<
106unsafe extern "C" fn(
107 a: *mut pa_mainloop_api,
108 e: *mut pa_defer_event,
109 userdata: *mut c_void,
110),
111>;
112
113pub type pa_defer_event_cb_t = ::std::option::Option<
114unsafe extern "C" fn(
115 a: *mut pa_mainloop_api,
116 e: *mut pa_defer_event,
117 userdata: *mut c_void,
118),
119>;
120
121pub type pa_time_event_destroy_cb_t = ::std::option::Option<
122unsafe extern "C" fn(
123 a: *mut pa_mainloop_api,
124 e: *mut pa_time_event,
125 userdata: *mut c_void,
126),
127>;
128
129pub type pa_time_event_cb_t = ::std::option::Option<
130unsafe extern "C" fn(
131 a: *mut pa_mainloop_api,
132 e: *mut pa_time_event,
133 tv: *const timeval,
134 userdata: *mut c_void,
135),
136>;
137
138pub type pa_io_event_cb_t = ::std::option::Option<
139unsafe extern "C" fn(
140 ea: *mut pa_mainloop_api,
141 e: *mut pa_io_event,
142 fd: c_int,
143 events: pa_io_event_flags_t,
144 userdata: *mut c_void,
145),
146>;
147
148pub type pa_io_event_destroy_cb_t = ::std::option::Option<
149unsafe extern "C" fn(
150 a: *mut pa_mainloop_api,
151 e: *mut pa_io_event,
152 userdata: *mut c_void,
153),
154>;
155
156pub type pa_sink_info_cb_t = ::std::option::Option<
157unsafe extern "C" fn(
158 c: *mut pa_context,
159 i: *const pa_sink_info,
160 eol: c_int,
161 userdata: *mut c_void,
162),
163>;
164
165pub type pa_source_info_cb_t = ::std::option::Option<
166 unsafe extern "C" fn(
167 c: *mut pa_context,
168 i: *const pa_source_info,
169 eol: c_int,
170 userdata: *mut c_void,
171 ),
172>;
173
174pub type pa_context_subscribe_cb_t = ::std::option::Option<
175 unsafe extern "C" fn(
176 c: *mut pa_context,
177 t: pa_subscription_event_type_t,
178 idx: u32,
179 userdata: *mut c_void,
180 ),
181>;
182
183pub type pa_server_info_cb_t = ::std::option::Option<
184 unsafe extern "C" fn(
185 c: *mut pa_context,
186 i: *const pa_server_info,
187 userdata: *mut c_void,
188 ),
189>;
190
191pub type pa_stream_notify_cb_t = ::std::option::Option<
192 unsafe extern "C" fn(p: *mut pa_stream, userdata: *mut c_void),
193>;
194
195pub type pa_stream_success_cb_t = ::std::option::Option<
196 unsafe extern "C" fn(
197 s: *mut pa_stream,
198 success: c_int,
199 userdata: *mut c_void,
200 ),
201>;
202
203pub type pa_stream_request_cb_t = ::std::option::Option<
204 unsafe extern "C" fn(p: *mut pa_stream, nbytes: usize, userdata: *mut c_void),
205>;
206
207pub type pa_free_cb_t = ::std::option::Option<unsafe extern "C" fn(p: *mut ::std::os::raw::c_void)>;
208
209#[repr(C)]
210#[derive(Debug, Copy, Clone)]
211pub struct pa_cvolume {
212 pub channels: u8,
213 pub values: [pa_volume_t; 32usize],
214}
215
216#[repr(C)]
217#[derive(Debug, Copy, Clone)]
218pub struct pa_channel_map {
219 pub channels: u8,
220 pub map: [pa_channel_position_t; 32usize],
221}
222
223#[repr(C)]
224#[derive(Debug, Copy, Clone)]
225pub struct pa_sample_spec {
226 pub format: pa_sample_format_t,
227 pub rate: u32,
228 pub channels: u8,
229}
230
231#[repr(C)]
232#[derive(Debug, Copy, Clone)]
233pub struct pa_proplist {
234 _unused: [u8; 0],
235}
236
237#[repr(C)]
238#[derive(Debug, Copy, Clone)]
239pub struct pa_format_info {
240 pub encoding: pa_encoding_t,
241 pub plist: *mut pa_proplist,
242}
243
244#[repr(C)]
245#[derive(Debug, Copy, Clone)]
246pub struct pa_sink_port_info {
247 pub name: *const c_char,
248 pub description: *const c_char,
249 pub priority: u32,
250 pub available: c_int,
251 pub availability_group: *const c_char,
252 pub type_: u32,
253}
254
255#[repr(C)]
256#[derive(Debug, Copy, Clone)]
257pub struct pa_sink_info {
258 pub name: *const c_char,
259 pub index: u32,
260 pub description: *const c_char,
261 pub sample_spec: pa_sample_spec,
262 pub channel_map: pa_channel_map,
263 pub owner_module: u32,
264 pub volume: pa_cvolume,
265 pub mute: c_int,
266 pub monitor_source: u32,
267 pub monitor_source_name: *const c_char,
268 pub latency: pa_usec_t,
269 pub driver: *const c_char,
270 pub flags: pa_sink_flags_t,
271 pub proplist: *mut pa_proplist,
272 pub configured_latency: pa_usec_t,
273 pub base_volume: pa_volume_t,
274 pub state: pa_sink_state_t,
275 pub n_volume_steps: u32,
276 pub card: u32,
277 pub n_ports: u32,
278 pub ports: *mut *mut pa_sink_port_info,
279 pub active_port: *mut pa_sink_port_info,
280 pub n_formats: u8,
281 pub formats: *mut *mut pa_format_info,
282}
283
284#[repr(C)]
285#[derive(Debug, Copy, Clone)]
286pub struct pa_source_info {
287 pub name: *const c_char,
288 pub index: u32,
289 pub description: *const c_char,
290 pub sample_spec: pa_sample_spec,
291 pub channel_map: pa_channel_map,
292 pub owner_module: u32,
293 pub volume: pa_cvolume,
294 pub mute: c_int,
295 pub monitor_of_sink: u32,
296 pub monitor_of_sink_name: *const c_char,
297 pub latency: pa_usec_t,
298 pub driver: *const c_char,
299 pub flags: pa_source_flags_t,
300 pub proplist: *mut pa_proplist,
301 pub configured_latency: pa_usec_t,
302 pub base_volume: pa_volume_t,
303 pub state: pa_source_state_t,
304 pub n_volume_steps: u32,
305 pub card: u32,
306 pub n_ports: u32,
307 pub ports: *mut *mut pa_source_port_info,
308 pub active_port: *mut pa_source_port_info,
309 pub n_formats: u8,
310 pub formats: *mut *mut pa_format_info,
311}
312
313#[repr(C)]
314#[derive(Debug, Copy, Clone)]
315pub struct pa_source_port_info {
316 pub name: *const c_char,
317 pub description: *const c_char,
318 pub priority: u32,
319 pub available: c_int,
320 pub availability_group: *const c_char,
321 pub type_: u32,
322}
323
324#[repr(C)]
325#[derive(Debug, Copy, Clone)]
326pub struct pa_io_event {
327 _unused: [u8; 0],
328}
329
330#[repr(C)]
331#[derive(Debug, Copy, Clone)]
332pub struct pa_threaded_mainloop {
333 _unused: [u8; 0],
334}
335
336#[repr(C)]
337#[derive(Debug, Copy, Clone)]
338pub struct pa_spawn_api {
339 pub prefork: ::std::option::Option<unsafe extern "C" fn()>,
340 pub postfork: ::std::option::Option<unsafe extern "C" fn()>,
341 pub atfork: ::std::option::Option<unsafe extern "C" fn()>,
342}
343
344#[repr(C)]
345#[derive(Debug, Copy, Clone)]
346pub struct pa_operation {
347 _unused: [u8; 0],
348}
349
350
351
352#[repr(C)]
353#[derive(Debug, Copy, Clone)]
354pub struct pa_server_info {
355 pub user_name: *const ::std::os::raw::c_char,
356 pub host_name: *const ::std::os::raw::c_char,
357 pub server_version: *const ::std::os::raw::c_char,
358 pub server_name: *const ::std::os::raw::c_char,
359 pub sample_spec: pa_sample_spec,
360 pub default_sink_name: *const ::std::os::raw::c_char,
361 pub default_source_name: *const ::std::os::raw::c_char,
362 pub cookie: u32,
363 pub channel_map: pa_channel_map,
364}
365
366#[repr(C)]
367#[derive(Debug, Copy, Clone)]
368pub struct pa_stream {
369 _unused: [u8; 0],
370}
371
372#[repr(C)]
373#[derive(Debug, Copy, Clone)]
374pub struct pa_buffer_attr {
375 pub maxlength: u32,
376 pub tlength: u32,
377 pub prebuf: u32,
378 pub minreq: u32,
379 pub fragsize: u32,
380}
381
382#[repr(C)]
383#[derive(Debug, Copy, Clone)]
384pub struct pa_mainloop_api {
385 pub userdata: *mut c_void,
386 pub io_new: ::std::option::Option<
387 unsafe extern "C" fn(
388 a: *mut pa_mainloop_api,
389 fd: c_int,
390 events: pa_io_event_flags_t,
391 cb: pa_io_event_cb_t,
392 userdata: *mut c_void,
393 ) -> *mut pa_io_event,
394 >,
395 pub io_enable: ::std::option::Option<
396 unsafe extern "C" fn(e: *mut pa_io_event, events: pa_io_event_flags_t),
397 >,
398 pub io_free: ::std::option::Option<unsafe extern "C" fn(e: *mut pa_io_event)>,
399 pub io_set_destroy: ::std::option::Option<
400 unsafe extern "C" fn(e: *mut pa_io_event, cb: pa_io_event_destroy_cb_t),
401 >,
402 pub time_new: ::std::option::Option<
403 unsafe extern "C" fn(
404 a: *mut pa_mainloop_api,
405 tv: *const timeval,
406 cb: pa_time_event_cb_t,
407 userdata: *mut c_void,
408 ) -> *mut pa_time_event,
409 >,
410 pub time_restart:
411 ::std::option::Option<unsafe extern "C" fn(e: *mut pa_time_event, tv: *const timeval)>,
412 pub time_free: ::std::option::Option<unsafe extern "C" fn(e: *mut pa_time_event)>,
413 pub time_set_destroy: ::std::option::Option<
414 unsafe extern "C" fn(e: *mut pa_time_event, cb: pa_time_event_destroy_cb_t),
415 >,
416 pub defer_new: ::std::option::Option<
417 unsafe extern "C" fn(
418 a: *mut pa_mainloop_api,
419 cb: pa_defer_event_cb_t,
420 userdata: *mut c_void,
421 ) -> *mut pa_defer_event,
422 >,
423 pub defer_enable: ::std::option::Option<
424 unsafe extern "C" fn(e: *mut pa_defer_event, b: c_int),
425 >,
426 pub defer_free: ::std::option::Option<unsafe extern "C" fn(e: *mut pa_defer_event)>,
427 pub defer_set_destroy: ::std::option::Option<
428 unsafe extern "C" fn(e: *mut pa_defer_event, cb: pa_defer_event_destroy_cb_t),
429 >,
430 pub quit: ::std::option::Option<
431 unsafe extern "C" fn(a: *mut pa_mainloop_api, retval: c_int),
432 >,
433}
434
435
436#[link(name = "pulse")]
437extern "C" {
438 pub fn pa_context_connect(
439 c: *mut pa_context,
440 server: *const c_char,
441 flags: pa_context_flags_t,
442 api: *const pa_spawn_api,
443 ) -> c_int;
444
445 pub fn pa_context_new(
446 mainloop: *mut pa_mainloop_api,
447 name: *const c_char,
448 ) -> *mut pa_context;
449
450 pub fn pa_context_set_state_callback(
451 c: *mut pa_context,
452 cb: pa_context_notify_cb_t,
453 userdata: *mut c_void,
454 );
455 pub fn pa_context_get_state(c: *const pa_context) -> pa_context_state_t;
456
457 pub fn pa_context_disconnect(c: *mut pa_context);
458
459 pub fn pa_context_unref(c: *mut pa_context);
460
461 pub fn pa_context_get_sink_info_list(
462 c: *mut pa_context,
463 cb: pa_sink_info_cb_t,
464 userdata: *mut c_void,
465 ) -> *mut pa_operation;
466
467 pub fn pa_operation_get_state(o: *const pa_operation) -> pa_operation_state_t;
468 pub fn pa_operation_unref(o: *mut pa_operation);
469
470 pub fn pa_context_get_source_info_list(
471 c: *mut pa_context,
472 cb: pa_source_info_cb_t,
473 userdata: *mut c_void,
474 ) -> *mut pa_operation;
475
476 pub fn pa_threaded_mainloop_get_api(m: *mut pa_threaded_mainloop) -> *mut pa_mainloop_api;
477
478 pub fn pa_threaded_mainloop_new() -> *mut pa_threaded_mainloop;
479
480 pub fn pa_threaded_mainloop_signal(
481 m: *mut pa_threaded_mainloop,
482 wait_for_accept:c_int,
483 );
484
485 pub fn pa_threaded_mainloop_start(m: *mut pa_threaded_mainloop) -> c_int;
486 pub fn pa_threaded_mainloop_lock(m: *mut pa_threaded_mainloop);
487 pub fn pa_threaded_mainloop_unlock(m: *mut pa_threaded_mainloop);
488 pub fn pa_threaded_mainloop_wait(m: *mut pa_threaded_mainloop);
489 pub fn pa_threaded_mainloop_stop(m: *mut pa_threaded_mainloop);
490 pub fn pa_threaded_mainloop_free(m: *mut pa_threaded_mainloop);
491 pub fn pa_context_get_server_info(
492 c: *mut pa_context,
493 cb: pa_server_info_cb_t,
494 userdata: *mut c_void,
495 ) -> *mut pa_operation;
496 pub fn pa_proplist_new() -> *mut pa_proplist;
497 pub fn pa_context_new_with_proplist(
498 mainloop: *mut pa_mainloop_api,
499 name: *const u8,
500 proplist: *const pa_proplist,
501 ) -> *mut pa_context;
502
503 pub fn pa_stream_new(
504 c: *mut pa_context,
505 name: *const u8,
506 ss: *const pa_sample_spec,
507 map: *const pa_channel_map,
508 ) -> *mut pa_stream;
509
510 pub fn pa_stream_set_state_callback(
511 s: *mut pa_stream,
512 cb: pa_stream_notify_cb_t,
513 userdata: *mut c_void,
514 );
515
516 pub fn pa_stream_get_state(p: *const pa_stream) -> pa_stream_state_t;
517
518 pub fn pa_stream_cork(
519 s: *mut pa_stream,
520 b: c_int,
521 cb: pa_stream_success_cb_t,
522 userdata: *mut c_void,
523 ) -> *mut pa_operation;
524
525 pub fn pa_stream_set_write_callback(
526 p: *mut pa_stream,
527 cb: pa_stream_request_cb_t,
528 userdata: *mut ::std::os::raw::c_void,
529 );
530 pub fn pa_stream_disconnect(s: *mut pa_stream) -> ::std::os::raw::c_int;
531 pub fn pa_stream_unref(s: *mut pa_stream);
532 pub fn pa_stream_begin_write(
533 p: *mut pa_stream,
534 data: *mut *mut c_void,
535 nbytes: *mut usize,
536 ) -> c_int;
537 pub fn pa_stream_write(
538 p: *mut pa_stream,
539 data: *const c_void,
540 nbytes: usize,
541 free_cb: pa_free_cb_t,
542 offset: i64,
543 seek: pa_seek_mode_t,
544 ) -> c_int;
545
546 pub fn pa_stream_connect_playback(
547 s: *mut pa_stream,
548 dev: *const u8,
549 attr: *const pa_buffer_attr,
550 flags: pa_stream_flags_t,
551 volume: *const pa_cvolume,
552 sync_stream: *mut pa_stream,
553 ) -> c_int;
554 pub fn pa_stream_writable_size(p: *const pa_stream) -> usize;
555
556 pub fn pa_stream_set_read_callback(
557 p: *mut pa_stream,
558 cb: pa_stream_request_cb_t,
559 userdata: *mut c_void,
560 );
561
562 pub fn pa_stream_connect_record(
563 s: *mut pa_stream,
564 dev: *const u8,
565 attr: *const pa_buffer_attr,
566 flags: pa_stream_flags_t,
567 ) -> c_int;
568
569 pub fn pa_stream_peek(
570 p: *mut pa_stream,
571 data: *mut *const c_void,
572 nbytes: *mut usize,
573 ) -> c_int;
574
575 pub fn pa_stream_drop(p: *mut pa_stream) -> c_int;
576
577}