1
0
Fork 0
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:
Ash 2020-07-25 09:38:08 +02:00 committed by GitHub
parent dc99cd73c0
commit f0b3b2c7e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 58 additions and 19 deletions

View file

@ -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
}
}