#ALSA #audio #sound

alsa

Thin but safe wrappers for ALSA (Linux sound API)

20 releases

✓ Uses Rust 2018 edition

0.3.0 Jul 18, 2019
0.2.1 Sep 17, 2018
0.2.0 Oct 11, 2017
0.1.8 Apr 4, 2017
0.0.5 Jun 21, 2015

#19 in Audio

Download history 401/week @ 2019-04-04 547/week @ 2019-04-11 399/week @ 2019-04-18 402/week @ 2019-04-25 400/week @ 2019-05-02 306/week @ 2019-05-09 358/week @ 2019-05-16 451/week @ 2019-05-23 452/week @ 2019-05-30 339/week @ 2019-06-06 369/week @ 2019-06-13 653/week @ 2019-06-20 645/week @ 2019-06-27 458/week @ 2019-07-04 559/week @ 2019-07-11

1,874 downloads per month
Used in 9 crates (7 directly)

Apache-2.0/MIT

188KB
3.5K 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

~1.5MB
~25K SLoC