mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Merge pull request #1003 from roderickvd/fix-clippy-lints
Fix clippy lints
This commit is contained in:
commit
3e80eebf7a
7 changed files with 30 additions and 40 deletions
|
@ -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()
|
||||
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()
|
||||
}
|
||||
}
|
||||
.collect(),
|
||||
};
|
||||
|
||||
println!("cargo:rustc-env=LIBRESPOT_BUILD_ID={}", build_id);
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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_if! {
|
||||
if #[cfg(feature = "with-dns-sd")] {
|
||||
svc = dns_sd::DNSService::register(
|
||||
#[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)))?;
|
||||
)
|
||||
.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(
|
||||
#[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 })
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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.)
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -586,7 +586,7 @@ fn get_setup() -> Setup {
|
|||
|
||||
let stripped_env_key = |k: &str| {
|
||||
k.trim_start_matches("LIBRESPOT_")
|
||||
.replace("_", "-")
|
||||
.replace('_', "-")
|
||||
.to_lowercase()
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue