1#![allow(non_camel_case_types)]
2
3use std::os::raw::{
4    c_int,
5    c_uint,
6    c_long,
7    c_ulong,
8    c_void,
9    c_char,
10    c_uchar,
11};
12
13pub type snd_pcm_info_t = _snd_pcm_info;
14pub type _snd_pcm_format = c_int;
15pub use self::_snd_pcm_format as snd_pcm_format_t;
16pub type _snd_pcm_stream = c_uint;
17pub const SND_PCM_FORMAT_FLOAT_LE: _snd_pcm_format = 14;
18pub const SND_PCM_STREAM_PLAYBACK: _snd_pcm_stream = 0;
19pub const SND_PCM_STREAM_CAPTURE: _snd_pcm_stream = 1;
20pub type snd_pcm_hw_params_t = _snd_pcm_hw_params;
21pub type snd_pcm_t = _snd_pcm;
22pub use self::_snd_pcm_stream as snd_pcm_stream_t;
23pub type _snd_pcm_access = c_uint;
24pub use self::_snd_pcm_access as snd_pcm_access_t;
25pub const SND_PCM_ACCESS_RW_INTERLEAVED: _snd_pcm_access = 3;
26pub type snd_pcm_uframes_t = c_ulong;
27pub type snd_pcm_sframes_t = c_long;
28pub type snd_output_t = _snd_output;
29pub type snd_seq_t = _snd_seq;
30pub const SND_SEQ_OPEN_OUTPUT: i32 = 1;
31pub const SND_SEQ_OPEN_INPUT: i32 = 2; 
32pub const SND_SEQ_OPEN_DUPLEX: i32 = SND_SEQ_OPEN_OUTPUT | SND_SEQ_OPEN_INPUT;
33
34pub const SND_SEQ_PORT_CAP_READ: c_uint = 1 << 0;
35pub const SND_SEQ_PORT_CAP_WRITE: c_uint = 1 << 1;
36pub const SND_SEQ_PORT_CAP_SUBS_READ: c_uint = 1 << 5;
37pub const SND_SEQ_PORT_CAP_SUBS_WRITE: c_uint = 1 << 6;
38pub const SND_SEQ_PORT_CAP_NO_EXPORT: c_uint = 1 << 7;
39pub const SND_SEQ_PORT_TYPE_APPLICATION: c_uint = 1 << 20;
40pub const SND_SEQ_PORT_TYPE_MIDI_GENERIC:c_uint = 1 << 1;
41pub const SND_SEQ_CLIENT_SYSTEM: u8 = 0;
42pub const SND_SEQ_PORT_SYSTEM_ANNOUNCE: u8 = 1;
43pub const SND_SEQ_USER_CLIENT: snd_seq_client_type = 1;
44pub const SND_SEQ_KERNEL_CLIENT: snd_seq_client_type = 2;
45pub type snd_seq_client_type = c_uint;
46pub use self::snd_seq_client_type as snd_seq_client_type_t;
47
48pub const SND_SEQ_ADDRESS_SUBSCRIBERS: c_uint = 254;
49pub const SND_SEQ_ADDRESS_UNKNOWN: c_uint =	253;
50pub const SND_SEQ_QUEUE_DIRECT: c_uint =	253;
51
52pub type snd_seq_event_type = u8;
53pub const SND_SEQ_EVENT_NOTEON: snd_seq_event_type = 6;
54pub const SND_SEQ_EVENT_NOTEOFF: snd_seq_event_type = 7;
55pub const SND_SEQ_EVENT_KEYPRESS: snd_seq_event_type = 8;
56pub const SND_SEQ_EVENT_CONTROLLER: snd_seq_event_type = 10;
57pub const SND_SEQ_EVENT_PGMCHANGE: snd_seq_event_type = 11;
58pub const SND_SEQ_EVENT_CHANPRESS: snd_seq_event_type = 12;
59pub const SND_SEQ_EVENT_PITCHBEND: snd_seq_event_type = 13;
60
61pub const SND_SEQ_EVENT_CLIENT_START: snd_seq_event_type = 60;
62pub const SND_SEQ_EVENT_CLIENT_EXIT: snd_seq_event_type = 61;
63pub const SND_SEQ_EVENT_CLIENT_CHANGE: snd_seq_event_type = 62;
64pub const SND_SEQ_EVENT_PORT_START: snd_seq_event_type = 63;
65pub const SND_SEQ_EVENT_PORT_EXIT: snd_seq_event_type = 64;
66pub const SND_SEQ_EVENT_PORT_CHANGE: snd_seq_event_type = 65;
67pub const SND_SEQ_EVENT_PORT_SUBSCRIBED: snd_seq_event_type = 66;
68pub const SND_SEQ_EVENT_PORT_UNSUBSCRIBED: snd_seq_event_type = 67;
69
70pub type snd_seq_event_type_t = c_uchar;
71pub type snd_seq_tick_time_t = c_uint;
72pub type snd_seq_port_subscribe_t = _snd_seq_port_subscribe;
73
74#[repr(C)]
75#[derive(Debug, Copy, Clone)]
76pub struct snd_midi_event {
77    _unused: [u8; 0],
78}
79pub type snd_midi_event_t = snd_midi_event;
80
81#[repr(C)]
82#[derive(Debug, Copy, Clone)]
83pub struct _snd_seq_port_subscribe {
84    _unused: [u8; 0],
85}
86
87#[repr(C)]
88#[derive(Debug, Copy, Clone)]
89pub struct _snd_output {
90    _unused: [u8; 0],
91}
92
93#[repr(C)]
94#[derive(Debug, Copy, Clone)]
95pub struct _snd_pcm {
96    _unused: [u8; 0],
97}
98
99#[repr(C)]
100#[derive(Debug, Copy, Clone)]
101pub struct _snd_ctl {
102    _unused: [u8; 0],
103}
104pub type snd_ctl_t = _snd_ctl;
105
106#[repr(C)]
107#[derive(Debug, Copy, Clone)]
108pub struct _snd_pcm_info {
109    _unused: [u8; 0],
110}
111
112#[repr(C)]
113#[derive(Debug, Copy, Clone)]
114pub struct _snd_pcm_hw_params {
115    _unused: [u8; 0],
116}
117
118#[repr(C)]
119#[derive(Debug, Copy, Clone)]
120pub struct _snd_seq {
121    _unused: [u8; 0],
122}
123
124#[repr(C)]
125#[derive(Debug, Copy, Clone)]
126pub struct snd_seq_real_time {
127    pub tv_sec: c_uint,
128    pub tv_nsec: c_uint,
129}
130pub type snd_seq_real_time_t = snd_seq_real_time;
131
132#[repr(C)]
133#[derive(Copy, Clone)]
134pub union snd_seq_timestamp {
135    pub tick: snd_seq_tick_time_t,
136    pub time: snd_seq_real_time,
137    _bindgen_union_align: [u32; 2usize],
138}
139pub type snd_seq_timestamp_t = snd_seq_timestamp;
140
141#[repr(C)]
142#[derive(Debug, Copy, Clone)]
143pub struct snd_seq_addr {
144    pub client: c_uchar,
145    pub port: c_uchar,
146}
147pub type snd_seq_addr_t = snd_seq_addr;
148
149#[repr(C)]
150#[derive(Copy, Clone)]
151pub struct snd_seq_event {
152    pub type_: snd_seq_event_type_t,
153    pub flags: c_uchar,
154    pub tag: c_uchar,
155    pub queue: c_uchar,
156    pub time: snd_seq_timestamp_t,
157    pub source: snd_seq_addr_t,
158    pub dest: snd_seq_addr_t,
159    pub data: snd_seq_event__bindgen_ty_1,
160}
161
162#[repr(C)]
163#[derive(Debug, Copy, Clone)]
164pub struct snd_seq_ev_note {
165    pub channel: c_uchar,
166    pub note: c_uchar,
167    pub velocity: c_uchar,
168    pub off_velocity: c_uchar,
169    pub duration: c_uint,
170}
171pub type snd_seq_ev_note_t = snd_seq_ev_note;
172
173#[repr(C)]
174#[derive(Debug, Copy, Clone)]
175pub struct snd_seq_ev_ctrl {
176    pub channel: c_uchar,
177    pub unused: [c_uchar; 3usize],
178    pub param: c_uint,
179    pub value: c_int,
180}
181pub type snd_seq_ev_ctrl_t = snd_seq_ev_ctrl;
182
183#[repr(C)]
184#[derive(Debug, Copy, Clone)]
185pub struct snd_seq_ev_raw8 {
186    pub d: [c_uchar; 12usize],
187}
188pub type snd_seq_ev_raw8_t = snd_seq_ev_raw8;
189
190#[repr(C)]
191#[derive(Debug, Copy, Clone)]
192pub struct snd_seq_ev_raw32 {
193    pub d: [c_uint; 3usize],
194}
195pub type snd_seq_ev_raw32_t = snd_seq_ev_raw32;
196
197#[repr(C, packed)]
198#[derive(Debug, Copy, Clone)]
199pub struct snd_seq_ev_ext {
200    pub len: c_uint,
201    pub ptr: *mut c_void,
202}
203pub type snd_seq_ev_ext_t = snd_seq_ev_ext;
204
205#[repr(C)]
206#[derive(Copy, Clone)]
207pub struct snd_seq_ev_queue_control {
208    pub queue: c_uchar,
209    pub unused: [c_uchar; 3usize],
210    pub param: snd_seq_ev_queue_control__bindgen_ty_1,
211}
212
213#[repr(C)]
214#[derive(Debug, Copy, Clone)]
215pub struct snd_seq_queue_skew {
216    pub value: c_uint,
217    pub base: c_uint,
218}
219pub type snd_seq_queue_skew_t = snd_seq_queue_skew;
220
221#[repr(C)]
222#[derive(Copy, Clone)]
223pub union snd_seq_ev_queue_control__bindgen_ty_1 {
224    pub value: c_int,
225    pub time: snd_seq_timestamp_t,
226    pub position: c_uint,
227    pub skew: snd_seq_queue_skew_t,
228    pub d32: [c_uint; 2usize],
229    pub d8: [c_uchar; 8usize],
230    _bindgen_union_align: [u32; 2usize],
231}
232pub type snd_seq_ev_queue_control_t = snd_seq_ev_queue_control;
233
234#[repr(C)]
235#[derive(Debug, Copy, Clone)]
236pub struct snd_seq_connect {
237    pub sender: snd_seq_addr_t,
238    pub dest: snd_seq_addr_t,
239}
240pub type snd_seq_connect_t = snd_seq_connect;
241
242#[repr(C)]
243#[derive(Debug, Copy, Clone)]
244pub struct snd_seq_result {
245    pub event: c_int,
246    pub result: c_int,
247}
248pub type snd_seq_result_t = snd_seq_result;
249
250#[repr(C)]
251#[derive(Copy, Clone)]
252pub union snd_seq_event__bindgen_ty_1 {
253    pub note: snd_seq_ev_note_t,
254    pub control: snd_seq_ev_ctrl_t,
255    pub raw8: snd_seq_ev_raw8_t,
256    pub raw32: snd_seq_ev_raw32_t,
257    pub ext: snd_seq_ev_ext_t,
258    pub queue: snd_seq_ev_queue_control_t,
259    pub time: snd_seq_timestamp_t,
260    pub addr: snd_seq_addr_t,
261    pub connect: snd_seq_connect_t,
262    pub result: snd_seq_result_t,
263    _bindgen_union_align: [u32; 3usize],
264}
265
266pub type snd_seq_event_t = snd_seq_event;
267
268#[repr(C)]
269#[derive(Debug, Copy, Clone)]
270pub struct _snd_seq_client_info {
271    _unused: [u8; 0],
272}
273pub type snd_seq_client_info_t = _snd_seq_client_info;
274
275#[repr(C)]
276#[derive(Debug, Copy, Clone)]
277pub struct _snd_seq_port_info {
278    _unused: [u8; 0],
279}
280pub type snd_seq_port_info_t = _snd_seq_port_info;
281
282#[link(name = "asound")]
283extern "C" {
284    
285    pub fn snd_seq_open(
286        handle: *mut *mut snd_seq_t,
287        name: *const u8,
288        streams: c_int,
289        mode: c_int,
290    ) -> c_int;
291    
292    pub fn snd_card_next(card: *mut c_int) -> c_int;
293    
294    pub fn snd_strerror(errnum: c_int) -> *const c_char;
295    
296    pub fn snd_ctl_open(
297        ctl: *mut *mut snd_ctl_t,
298        name: *const u8,
299        mode: c_int,
300    ) -> c_int;
301    
302    pub fn snd_ctl_pcm_next_device(
303        ctl: *mut snd_ctl_t,
304        device: *mut c_int,
305    ) -> c_int;
306    
307    pub fn snd_device_name_hint(
308        card: c_int,
309        iface: *const u8,
310        hints: *mut *mut *mut c_void,
311    ) -> c_int;
312    
313    pub fn snd_device_name_get_hint(
314        hint: *const c_void,
315        id: *const u8,
316    ) -> *mut c_char;
317    
318    pub fn snd_pcm_open(
319        pcm: *mut *mut snd_pcm_t,
320        name: *const u8,
321        stream: snd_pcm_stream_t,
322        mode: c_int,
323    ) -> c_int;
324    
325    pub fn snd_pcm_hw_params_malloc(ptr: *mut *mut snd_pcm_hw_params_t) -> c_int;
326    
327    pub fn snd_pcm_hw_params_any(
328        pcm: *mut snd_pcm_t,
329        params: *mut snd_pcm_hw_params_t,
330    ) -> c_int;
331    
332    pub fn snd_pcm_hw_params_set_access(
333        pcm: *mut snd_pcm_t,
334        params: *mut snd_pcm_hw_params_t,
335        _access: snd_pcm_access_t,
336    ) -> c_int;
337    
338    pub fn snd_pcm_hw_params_set_format(
339        pcm: *mut snd_pcm_t,
340        params: *mut snd_pcm_hw_params_t,
341        val: snd_pcm_format_t,
342    ) -> c_int;
343    
344    pub fn snd_pcm_hw_params_set_rate_near(
345        pcm: *mut snd_pcm_t,
346        params: *mut snd_pcm_hw_params_t,
347        val: *mut c_uint,
348        dir: *mut c_int,
349    ) -> c_int;
350    
351    pub fn snd_pcm_hw_params_set_channels(
352        pcm: *mut snd_pcm_t,
353        params: *mut snd_pcm_hw_params_t,
354        val: c_uint,
355    ) -> c_int;
356    
357    pub fn snd_pcm_hw_params(
358        pcm: *mut snd_pcm_t,
359        params: *mut snd_pcm_hw_params_t,
360    ) -> c_int;
361    
362    pub fn snd_pcm_hw_params_set_rate_resample(
363        pcm: *mut snd_pcm_t,
364        params: *mut snd_pcm_hw_params_t,
365        val: c_uint,
366    ) -> c_int;
367    
368    pub fn snd_pcm_hw_params_get_buffer_size(
369        params: *const snd_pcm_hw_params_t,
370        val: *mut snd_pcm_uframes_t,
371    ) -> c_int;
372    
373    pub fn snd_pcm_hw_params_free(obj: *mut snd_pcm_hw_params_t);
374    
375    pub fn snd_pcm_prepare(pcm: *mut snd_pcm_t) -> c_int;
376    
377    pub fn snd_pcm_hw_params_get_channels(
378        params: *const snd_pcm_hw_params_t,
379        val: *mut c_uint,
380    ) -> c_int;
381    
382    pub fn snd_pcm_hw_params_get_rate(
383        params: *const snd_pcm_hw_params_t,
384        val: *mut c_uint,
385        dir: *mut c_int,
386    ) -> c_int;
387    
388    pub fn snd_pcm_hw_params_get_period_size(
389        params: *const snd_pcm_hw_params_t,
390        frames: *mut snd_pcm_uframes_t,
391        dir: *mut c_int,
392    ) -> c_int;
393    
394    pub fn snd_pcm_hw_params_get_period_time(
395        params: *const snd_pcm_hw_params_t,
396        val: *mut c_uint,
397        dir: *mut c_int,
398    ) -> c_int;
399    
400    pub fn snd_pcm_writei(
401        pcm: *mut snd_pcm_t,
402        buffer: *const c_void,
403        size: snd_pcm_uframes_t,
404    ) -> snd_pcm_sframes_t;
405    pub fn snd_pcm_hw_params_set_periods_near(
406        pcm: *mut snd_pcm_t,
407        params: *mut snd_pcm_hw_params_t,
408        val: *mut c_uint,
409        dir: *mut c_int,
410    ) -> c_int;
411    pub fn snd_pcm_hw_params_set_buffer_size_near(
412        pcm: *mut snd_pcm_t,
413        params: *mut snd_pcm_hw_params_t,
414        val: *mut snd_pcm_uframes_t,
415    ) -> c_int;
416    
417    pub fn snd_pcm_readi(
418        pcm: *mut snd_pcm_t,
419        buffer: *mut c_void,
420        size: snd_pcm_uframes_t,
421    ) -> snd_pcm_sframes_t;
422    
423    pub fn snd_seq_set_client_name(
424        seq: *mut snd_seq_t,
425        name: *const u8,
426    ) -> c_int;
427    
428    pub fn snd_seq_create_simple_port(
429        seq: *mut snd_seq_t,
430        name: *const u8,
431        caps: c_uint,
432        type_: c_uint,
433    ) -> c_int;
434    
435    pub fn snd_seq_port_subscribe_malloc(
436        ptr: *mut *mut snd_seq_port_subscribe_t,
437    ) -> c_int;
438    
439    
440    pub fn snd_seq_client_info_malloc(
441        ptr: *mut *mut snd_seq_client_info_t,
442    ) -> c_int;
443    
444    pub fn snd_seq_port_info_malloc(ptr: *mut *mut snd_seq_port_info_t) -> c_int;
445    
446    pub fn snd_seq_port_subscribe_set_sender(
447        info: *mut snd_seq_port_subscribe_t,
448        addr: *const snd_seq_addr_t,
449    );
450    
451    pub fn snd_seq_port_subscribe_set_dest(
452        info: *mut snd_seq_port_subscribe_t,
453        addr: *const snd_seq_addr_t,
454    );
455    
456    pub fn snd_seq_subscribe_port(
457        handle: *mut snd_seq_t,
458        sub: *mut snd_seq_port_subscribe_t,
459    ) -> c_int;
460    
461    pub fn snd_seq_client_id(handle: *mut snd_seq_t) -> c_int;
462    
463    pub fn snd_seq_client_info_set_client(
464        info: *mut snd_seq_client_info_t,
465        client: c_int,
466    );
467    
468    pub fn snd_seq_query_next_client(
469        handle: *mut snd_seq_t,
470        info: *mut snd_seq_client_info_t,
471    ) -> c_int;
472    
473    pub fn snd_seq_client_info_get_client(
474        info: *const snd_seq_client_info_t,
475    ) -> c_int;
476    
477    pub fn snd_seq_port_info_set_client(
478        info: *mut snd_seq_port_info_t,
479        client: c_int,
480    );
481    
482    pub fn snd_seq_port_info_set_port(info: *mut snd_seq_port_info_t, port: c_int);
483    
484    pub fn snd_seq_query_next_port(
485        handle: *mut snd_seq_t,
486        info: *mut snd_seq_port_info_t,
487    ) -> c_int;
488    
489    pub fn snd_seq_port_info_get_addr(info: *const snd_seq_port_info_t) -> *const snd_seq_addr_t;
490    
491    pub fn snd_seq_client_info_get_name(
492        info: *mut snd_seq_client_info_t,
493    ) -> *const c_char;
494    
495    pub fn snd_seq_client_info_get_type(
496        info: *const snd_seq_client_info_t,
497    ) -> snd_seq_client_type_t;
498    
499    pub fn snd_seq_port_info_get_capability(
500        info: *const snd_seq_port_info_t,
501    ) -> c_uint;
502    
503    pub fn snd_seq_port_info_get_name(
504        info: *const snd_seq_port_info_t,
505    ) -> *const c_char;
506    
507    pub fn snd_seq_unsubscribe_port(
508        handle: *mut snd_seq_t,
509        sub: *mut snd_seq_port_subscribe_t,
510    ) -> c_int;
511    
512    pub fn snd_seq_event_input(
513        handle: *mut snd_seq_t,
514        ev: *mut *mut snd_seq_event_t,
515    ) -> c_int;
516    pub fn snd_midi_event_new(
517        bufsize: usize,
518        rdev: *mut *mut snd_midi_event_t,
519    ) -> c_int;
520    pub fn snd_midi_event_free(dev: *mut snd_midi_event_t);
521    pub fn snd_midi_event_init(dev: *mut snd_midi_event_t);
522    pub fn snd_midi_event_reset_encode(dev: *mut snd_midi_event_t);
523    pub fn snd_midi_event_encode(
524        dev: *mut snd_midi_event_t,
525        buf: *const c_uchar,
526        count: c_long,
527        ev: *mut snd_seq_event_t,
528    ) -> c_long;
529    pub fn snd_seq_event_output_direct(
530        handle: *mut snd_seq_t,
531        ev: *mut snd_seq_event_t,
532    ) -> c_int;
533}
534