cros_alsa: safe rust wrapper for alsa-lib
`cros_alsa` crate currently supports interacting with alsa
controls by using the control interface API of alsa-lib.
There are three major components exported in this commit:
1. The `Card` struct is the abstraction of a sound card, It's only used for
creating various `Control` struct now.
2. The `control` module is meant to provide easier to use and more type
safet abstractions for various alsa mixer controls. `Control` trait and
`ControlOps` trait are currently defined. Each mixer control should
implement the `Control` trait to allow itself to be created by `Card`.
Each mixer control could hold `Ctl` as handle and `ElemID` as id and
use `#[derive(ControlOps)]` macro to generate default load / save
implementations of the `ControlOps` trait which allows itself to read and
write the underlying hardware.
3. The `elem` module provides different types of `Elem` to read and
write alsa control elements. Users should use the provided
implementations of `Elem` to define the associated type in their owner
encapsulation of `Control`.
BUG=b:149437381
TEST=cargo build
Change-Id: I5519b2a209cec3534a3bdc76af54622d3644cc5e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2152264
Tested-by: Judy Hsiao <judyhsiao@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Commit-Queue: Judy Hsiao <judyhsiao@chromium.org>
12 files changed