Debian Codegraph @

third_party/rust/alsa/README.md

raw
1 ALSA bindings for Rust
2 =======================
3
4 Thin but safe wrappers for [ALSA](https://alsa-project.org), the most
5 common API for accessing audio devices on Linux.
6
7 [![crates.io](https://img.shields.io/crates/v/alsa.svg)](https://crates.io/crates/alsa)
8 [![API documentation](https://docs.rs/alsa/badge.svg)](https://docs.rs/alsa)
9 [![license](https://img.shields.io/crates/l/alsa.svg)](https://crates.io/crates/alsa)
10
11 The ALSA API is rather big, so everything is not covered yet, but expect the following to work:
12
13 * Audio Playback (example in `pcm` module docs)
14
15 * Audio Recording
16
17 * Mixer controls
18
19 * HCtl API (jack detection example in `hctl` module docs)
20
21 * Raw midi
22
23 * Midi sequencer (most of it)
24
25 * Ctl API
26
27 * Device name hints (example in `device_name` module docs)
28
29 * Enumerations of all of the above
30
31 * Poll and/or wait for all of the above
32
33 The following is not yet implemented (mostly because nobody asked for them) :
34
35 * Separate timer API (snd_timer_*)
36
37 * Config API (snd_config_*)
38
39 * Plug-in API
40
41 Quickstart guide / API design:
42
43 * Most functions map 1-to-1 to alsa-lib functions, e g, `ctl::CardInfo::get_id()` is a wrapper around
44 `snd_ctl_card_info_get_id` and the [alsa-lib documentation](https://www.alsa-project.org/alsa-doc/alsa-lib/)
45 can be consulted for additional information.
46
47 * Structs are RAII and closed/freed on drop, e g, when a `PCM` struct is dropped, `snd_pcm_close` is called.
48
49 * To read and write buffers, call the `io_*` methods. It will return a separate struct from which you can
50 read or write, and which can also be used for mmap (if supported by the driver).
51
52 * Error handling - most alsa-lib functions can return errors, so the return value from these is a `Result`.
53
54 * Enumeration of cards, devices etc is done through structs implementing `Iterator`.
55
56 * Many structs implement `poll::Descriptors`, to combine with poll or mio.
57 Or just use `wait` if you don't need non-blocking functionality.
58
59 Notes:
60
61 * To run the tests successfully, there must be a "default" sound card configured. This is usually not a problem when running on normal hardware, but some CI systems, docker images etc, might not have that configured by default.
62