1#![allow(clippy::all)]
17#![warn(clippy::correctness, clippy::suspicious, clippy::perf)]
18#![no_std]
19
20#[cfg(feature = "std")]
21extern crate std;
22
23extern crate alsa_sys as alsa;
24extern crate alloc;
25extern crate libc;
26#[macro_use]
27extern crate bitflags;
28
29macro_rules! alsa_enum {
30 ($(#[$attr:meta])+ $name:ident, $static_name:ident [$count:expr], $( $a:ident = $b:ident),* ,) =>
31{
32#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
33$(#[$attr])*
34pub enum $name {
35$(
36 $a = alsa::$b as isize,
37)*
38}
39
40static $static_name: [$name; $count] =
41 [ $( $name::$a, )* ];
42
43impl $name {
44 pub fn all() -> &'static [$name] { &$static_name[..] }
46
47 #[allow(dead_code)]
48 fn from_c_int(c: ::libc::c_int, s: &'static str) -> Result<$name> {
49 Self::all().iter().find(|&&x| c == x as ::libc::c_int).map(|&x| x)
50 .ok_or_else(|| Error::unsupported(s))
51 }
52
53 #[allow(dead_code)]
54 fn to_c_int(&self) -> ::libc::c_int {
55 return *self as ::libc::c_int;
56 }
57}
58
59}
60}
61
62#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
65pub enum Direction {
66 Playback,
67 Capture
68}
69impl Direction {
70 #[inline]
71 pub fn input() -> Direction { Direction::Capture }
72 #[inline]
73 pub fn output() -> Direction { Direction::Playback }
74}
75
76#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
80pub enum ValueOr {
81 Less = -1,
83 Nearest = 0,
85 Greater = 1,
87}
88
89#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
91pub enum Round {
92 Floor = 0,
94 Ceil = 1,
96}
97
98mod error;
99pub use crate::error::{Error, Result};
100
101pub mod card;
102pub use crate::card::Card as Card;
103
104mod ctl_int;
105pub mod ctl {
106 pub use super::ctl_int::{Ctl, CardInfo, DeviceIter, ElemIface, ElemId, ElemList, ElemType, ElemValue, ElemInfo};
108}
109
110pub use crate::ctl::Ctl as Ctl;
111
112pub mod hctl;
113pub use crate::hctl::HCtl as HCtl;
114
115pub mod pcm;
116pub use crate::pcm::PCM as PCM;
117
118pub mod config;
119
120pub mod rawmidi;
121pub use crate::rawmidi::Rawmidi as Rawmidi;
122
123pub mod device_name;
124
125pub mod poll;
126pub use crate::poll::Descriptors as PollDescriptors;
127
128pub mod mixer;
129pub use crate::mixer::Mixer as Mixer;
130
131pub mod seq;
132pub use crate::seq::Seq as Seq;
133
134mod io;
135pub use crate::io::Output;
136
137mod chmap;
139
140pub mod direct;