Struct pnmixerlib::audio::Audio
[−]
[src]
pub struct Audio { pub acard: RefCell<Box<AlsaCard>>, pub last_action_timestamp: Rc<RefCell<i64>>, pub handlers: Handlers, pub scroll_step: Cell<u32>, // some fields omitted }
High-level Audio struct, which could theoretically be backend agnostic.
Fields
acard: RefCell<Box<AlsaCard>>
The alsa card.
last_action_timestamp: Rc<RefCell<i64>>
Last timestamp of an internal action we triggered, e.g. by setting the volume or the mute state.
handlers: Handlers
A set of handlers that react to audio signals. We can connect to these.
scroll_step: Cell<u32>
The step at which to increase/decrease the volume. This value is basically from the preferences.
Methods
impl Audio
[src]
fn new(card_name: Option<String>, elem_name: Option<String>) -> Result<Audio>
Create a new Audio instance. This tries very hard to get a working configuration from the backend.
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.
Returns
Ok(Audio)
on success, Err(error)
otherwise.
fn switch_acard(
&self,
card_name: Option<String>,
elem_name: Option<String>,
user: AudioUser
) -> Result<()>
&self,
card_name: Option<String>,
elem_name: Option<String>,
user: AudioUser
) -> Result<()>
Switches the current alsa card. Behaves the same way in regards to
card_name
and elem_name
as the Audio::new()
method.
user
Where the card switch originates from.
fn vol(&self) -> Result<f64>
Current volume.
fn vol_level(&self) -> VolLevel
Current volume level, nicely usable for e.g. selecting from a set of images.
fn set_vol(
&self,
new_vol: f64,
user: AudioUser,
dir: VolDir,
auto_unmute: bool
) -> Result<()>
&self,
new_vol: f64,
user: AudioUser,
dir: VolDir,
auto_unmute: bool
) -> Result<()>
Set the current volume.
new_vol
Set the volume to this value.
user
Where the card switch originates from.
dir
The "direction" of the volume change, e.g. is it a decrease or increase. This helps with rounding problems.
auto_unmute
Whether to automatically unmute if the volume changes.
fn increase_vol(&self, user: AudioUser, auto_unmute: bool) -> Result<()>
Increase the volume. The step to increasy by is taken from
self.scroll_step
.
user
Where the card switch originates from.
fn decrease_vol(&self, user: AudioUser, auto_unmute: bool) -> Result<()>
Decrease the volume. The step to decrease by is taken from
self.scroll_step
.
user
Where the card switch originates from.
fn has_mute(&self) -> bool
Whether the current audio configuration can be muted.
fn get_mute(&self) -> Result<bool>
Get the mute state of the current audio configuration.
fn set_mute(&self, mute: bool, user: AudioUser) -> Result<()>
Set the mute state of the current audio configuration.
fn toggle_mute(&self, user: AudioUser) -> Result<()>
Toggle the mute state of the current audio configuration.
fn connect_handler(&self, cb: Box<Fn(AudioSignal, AudioUser)>)
Connect a signal handler to the audio subsystem. This can be done from anywhere, e.g. in the UI code to react to certain signals. Multiple handlers for the same signals are fine, they will be executed in order.
fn card_name(&self) -> Result<String>
Get the current card name.
fn playable_chan_names(&self) -> Vec<String>
Get the currently playable channel names.
fn chan_name(&self) -> Result<String>
Get the current active channel name.