#ALSA #audio #sound

alsa

Thin but safe wrappers for ALSA (Linux sound API)

21 releases

✓ Uses Rust 2018 edition

0.4.0 Oct 28, 2019
0.3.0 Jul 18, 2019
0.2.2 May 14, 2019
0.2.1 Sep 17, 2018
0.0.5 Jun 21, 2015

#6 in Audio

Download history 531/week @ 2019-07-15 491/week @ 2019-07-22 406/week @ 2019-07-29 404/week @ 2019-08-05 353/week @ 2019-08-12 457/week @ 2019-08-19 488/week @ 2019-08-26 567/week @ 2019-09-02 408/week @ 2019-09-09 620/week @ 2019-09-16 632/week @ 2019-09-23 456/week @ 2019-09-30 853/week @ 2019-10-07 644/week @ 2019-10-14 716/week @ 2019-10-21

2,302 downloads per month
Used in 13 crates (8 directly)

Apache-2.0/MIT

205KB
4K SLoC

Thin but safe wrappers for ALSA.

API Documentation

Crates.io

Expect the following to work:

  • Audio Playback

  • Audio Recording

  • Mixer controls

  • HCtl API (for jack detection)

  • Raw midi

  • Midi sequencer API (most of it)

  • Enumerations of all of the above

  • Poll and/or wait for all of the above

The following is not yet implemented (mostly because nobody asked for them) :

  • Separate timer API (snd_timer_*)

  • Config API (snd_config_*)

  • Plug-in API

Quickstart guide / API design:

  • Most functions map 1-to-1 to alsa-lib functions, e g, ctl::CardInfo::get_id() is a wrapper around snd_ctl_card_info_get_id and the alsa-lib documentation can be consulted for additional information.

  • Structs are RAII and closed/freed on drop, e g, when a PCM struct is dropped, snd_pcm_close is called.

  • To read and write buffers, call the io_* methods. It will return a separate struct from which you can read or write, and which can also be used for mmap (if supported by the driver).

  • Error handling - most alsa-lib functions can return errors, so the return value from these is a Result.

  • Enumeration of cards, devices etc is done through structs implementing Iterator.

  • Many structs implement Polldescriptors, to combine with poll or mio. (Or just use wait if you don't need that functionality.)

Dependencies

~1MB
~21K SLoC