diff --git a/core/build.rs b/core/build.rs index dd16cc0f..e4aa1187 100644 --- a/core/build.rs +++ b/core/build.rs @@ -8,17 +8,14 @@ fn main() { flags.toggle(ConstantsFlags::REBUILD_ON_HEAD_CHANGE); generate_cargo_keys(ConstantsFlags::all()).expect("Unable to generate the cargo keys!"); - let build_id: String; - match env::var("SOURCE_DATE_EPOCH") { - Ok(val) => build_id = val, - Err(_) => { - build_id = rand::thread_rng() - .sample_iter(Alphanumeric) - .take(8) - .map(char::from) - .collect() - } - } + let build_id = match env::var("SOURCE_DATE_EPOCH") { + Ok(val) => val, + Err(_) => rand::thread_rng() + .sample_iter(Alphanumeric) + .take(8) + .map(char::from) + .collect(), + }; println!("cargo:rustc-env=LIBRESPOT_BUILD_ID={}", build_id); } diff --git a/discovery/Cargo.toml b/discovery/Cargo.toml index 4dccdc1e..aebaf4df 100644 --- a/discovery/Cargo.toml +++ b/discovery/Cargo.toml @@ -10,7 +10,6 @@ edition = "2018" [dependencies] aes-ctr = "0.6" base64 = "0.13" -cfg-if = "1.0" form_urlencoded = "1.0" futures-core = "0.3" hmac = "0.11" diff --git a/discovery/src/lib.rs b/discovery/src/lib.rs index b2e65586..ca403b16 100644 --- a/discovery/src/lib.rs +++ b/discovery/src/lib.rs @@ -16,7 +16,6 @@ use std::io; use std::pin::Pin; use std::task::{Context, Poll}; -use cfg_if::cfg_if; use futures_core::Stream; use librespot_core as core; use thiserror::Error; @@ -100,29 +99,24 @@ impl Builder { let name = self.server_config.name.clone().into_owned(); let server = DiscoveryServer::new(self.server_config, &mut port)?; - let svc; + #[cfg(feature = "with-dns-sd")] + let svc = dns_sd::DNSService::register( + Some(name.as_ref()), + "_spotify-connect._tcp", + None, + None, + port, + &["VERSION=1.0", "CPath=/"], + ) + .map_err(|e| Error::DnsSdError(io::Error::new(io::ErrorKind::Unsupported, e)))?; - cfg_if! { - if #[cfg(feature = "with-dns-sd")] { - svc = dns_sd::DNSService::register( - Some(name.as_ref()), - "_spotify-connect._tcp", - None, - None, - port, - &["VERSION=1.0", "CPath=/"], - ).map_err(|e| Error::DnsSdError(io::Error::new(io::ErrorKind::Unsupported, e)))?; - - } else { - let responder = libmdns::Responder::spawn(&tokio::runtime::Handle::current())?; - svc = responder.register( - "_spotify-connect._tcp".to_owned(), - name, - port, - &["VERSION=1.0", "CPath=/"], - ) - } - }; + #[cfg(not(feature = "with-dns-sd"))] + let svc = libmdns::Responder::spawn(&tokio::runtime::Handle::current())?.register( + "_spotify-connect._tcp".to_owned(), + name, + port, + &["VERSION=1.0", "CPath=/"], + ); Ok(Discovery { server, _svc: svc }) } diff --git a/playback/src/mixer/alsamixer.rs b/playback/src/mixer/alsamixer.rs index c04e6ee8..f03af958 100644 --- a/playback/src/mixer/alsamixer.rs +++ b/playback/src/mixer/alsamixer.rs @@ -191,7 +191,7 @@ impl Mixer for AlsaMixer { mapped_volume = LogMapping::linear_to_mapped(mapped_volume, self.db_range); } - self.config.volume_ctrl.from_mapped(mapped_volume) + self.config.volume_ctrl.to_unmapped(mapped_volume) } fn set_volume(&self, volume: u16) { diff --git a/playback/src/mixer/mappings.rs b/playback/src/mixer/mappings.rs index 04cef439..548d0648 100644 --- a/playback/src/mixer/mappings.rs +++ b/playback/src/mixer/mappings.rs @@ -3,7 +3,7 @@ use crate::player::db_to_ratio; pub trait MappedCtrl { fn to_mapped(&self, volume: u16) -> f64; - fn from_mapped(&self, mapped_volume: f64) -> u16; + fn to_unmapped(&self, mapped_volume: f64) -> u16; fn db_range(&self) -> f64; fn set_db_range(&mut self, new_db_range: f64); @@ -49,7 +49,7 @@ impl MappedCtrl for VolumeCtrl { mapped_volume } - fn from_mapped(&self, mapped_volume: f64) -> u16 { + fn to_unmapped(&self, mapped_volume: f64) -> u16 { // More than just an optimization, this ensures that zero mapped volume // is unmapped to non-negative real numbers (otherwise the log and cubic // equations would respectively return -inf and -1/9.) diff --git a/playback/src/mixer/softmixer.rs b/playback/src/mixer/softmixer.rs index 93da5fec..db72659d 100644 --- a/playback/src/mixer/softmixer.rs +++ b/playback/src/mixer/softmixer.rs @@ -26,7 +26,7 @@ impl Mixer for SoftMixer { fn volume(&self) -> u16 { let mapped_volume = f64::from_bits(self.volume.load(Ordering::Relaxed)); - self.volume_ctrl.from_mapped(mapped_volume) + self.volume_ctrl.to_unmapped(mapped_volume) } fn set_volume(&self, volume: u16) { diff --git a/src/main.rs b/src/main.rs index 55df381d..9a1427bc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -586,7 +586,7 @@ fn get_setup() -> Setup { let stripped_env_key = |k: &str| { k.trim_start_matches("LIBRESPOT_") - .replace("_", "-") + .replace('_', "-") .to_lowercase() };