mirror of
https://github.com/librespot-org/librespot.git
synced 2025-10-05 02:39:53 +02:00
Refactor Volume control, allow for a fixed volume option (#447)
Refactored the old `--linear-volume` flag to a more generic `--volume-ctrl` flag that takes the options of `[linear, log, fixed]`. It defaults as previously to log.
This commit is contained in:
parent
dc99cd73c0
commit
f0b3b2c7e8
3 changed files with 58 additions and 19 deletions
|
@ -84,6 +84,32 @@ pub struct ConnectConfig {
|
|||
pub name: String,
|
||||
pub device_type: DeviceType,
|
||||
pub volume: u16,
|
||||
pub linear_volume: bool,
|
||||
pub volume_ctrl: VolumeCtrl,
|
||||
pub autoplay: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum VolumeCtrl {
|
||||
Linear,
|
||||
Log,
|
||||
Fixed,
|
||||
}
|
||||
|
||||
impl FromStr for VolumeCtrl {
|
||||
type Err = ();
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
use self::VolumeCtrl::*;
|
||||
match s.to_lowercase().as_ref() {
|
||||
"linear" => Ok(Linear),
|
||||
"log" => Ok(Log),
|
||||
"fixed" => Ok(Fixed),
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for VolumeCtrl {
|
||||
fn default() -> VolumeCtrl {
|
||||
VolumeCtrl::Linear
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue