Struct pnmixerlib::alsa_card::AlsaCard
[−]
[src]
pub struct AlsaCard { pub card: Card, pub mixer: Mixer, pub selem_id: SelemId, pub watch_ids: Cell<Vec<u32>>, pub cb: Rc<Fn(AlsaEvent)>, // some fields omitted }
A fairly high-level alsa card struct. We save some redundant information in order to access it more easily, in addition to some information that is not purely alsa related (like callbacks).
Fields
card: Card
The raw alsa card.
mixer: Mixer
The raw mixer.
selem_id: SelemId
The simple element ID. Selem
doesn't implement the Copy trait
so we save the ID instead and can get the Selem
by lookup.
watch_ids: Cell<Vec<u32>>
Watch IDs from polling the alsa card. We need them when we drop the card, so we can unregister the polling.
cb: Rc<Fn(AlsaEvent)>
Callback for the various AlsaEvent
s.
Methods
impl AlsaCard
[src]
fn new(
card_name: Option<String>,
elem_name: Option<String>,
cb: Rc<Fn(AlsaEvent)>
) -> Result<Box<AlsaCard>>
card_name: Option<String>,
elem_name: Option<String>,
cb: Rc<Fn(AlsaEvent)>
) -> Result<Box<AlsaCard>>
Create a new alsa card. Tries very hard to get a valid, playable card and mixer, so this is not a 'strict' function.
card_name
If a card name is provided, it will be tried. If None
is provided
or the given card name does not exist or is not playable, any other
playable card is tried.
elem_name
If an elem name is provided, it will be tried. If None
is provided
or the given elem name does not exist or is not playable, any other
playable elem is tried.
cb
Callback for the various AlsaEvent
s.
Returns
Ok(Box<AlsaCard>)
on success, Err(error)
otherwise.
fn card_name(&self) -> Result<String>
Get the name of the alsa card.
fn chan_name(&self) -> Result<String>
Get the name of the channel.
fn selem(&self) -> Selem
Get the Selem
, looked up by the SelemId
.
fn get_vol(&self) -> Result<i64>
Get the current volume. The returned value corresponds to the
volume range and might need to be interpreted (such as converting
to percentage). This always gets
the volume of the FrontRight
channel, because the seems to be
the safest bet.
fn set_vol(&self, new_vol: i64) -> Result<()>
Sets the volume of the current card configuration.
new_vol
The volume corresponding to the volume range of the Selem
. This
might need to be translated properly first from other formats
(like percentage).
fn get_volume_range(&self) -> (i64, i64)
fn has_mute(&self) -> bool
Whether the current card configuration can be muted.
fn get_mute(&self) -> Result<bool>
Get the mute state of the current card configuration.
fn set_mute(&self, mute: bool) -> Result<()>
Set the mute state of the current card configuration.
mute
Passing true
here means the card will be muted.
Trait Implementations
impl Drop for AlsaCard
[src]
fn drop(&mut self)
Destructs the watch IDs corresponding to the current poll descriptors.