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);
|
flags.toggle(ConstantsFlags::REBUILD_ON_HEAD_CHANGE);
|
||||||
generate_cargo_keys(ConstantsFlags::all()).expect("Unable to generate the cargo keys!");
|
generate_cargo_keys(ConstantsFlags::all()).expect("Unable to generate the cargo keys!");
|
||||||
|
|
||||||
let build_id: String;
|
let build_id = match env::var("SOURCE_DATE_EPOCH") {
|
||||||
match env::var("SOURCE_DATE_EPOCH") {
|
Ok(val) => val,
|
||||||
Ok(val) => build_id = val,
|
Err(_) => rand::thread_rng()
|
||||||
Err(_) => {
|
.sample_iter(Alphanumeric)
|
||||||
build_id = rand::thread_rng()
|
.take(8)
|
||||||
.sample_iter(Alphanumeric)
|
.map(char::from)
|
||||||
.take(8)
|
.collect(),
|
||||||
.map(char::from)
|
};
|
||||||
.collect()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
println!("cargo:rustc-env=LIBRESPOT_BUILD_ID={}", build_id);
|
println!("cargo:rustc-env=LIBRESPOT_BUILD_ID={}", build_id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ edition = "2018"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
aes-ctr = "0.6"
|
aes-ctr = "0.6"
|
||||||
base64 = "0.13"
|
base64 = "0.13"
|
||||||
cfg-if = "1.0"
|
|
||||||
form_urlencoded = "1.0"
|
form_urlencoded = "1.0"
|
||||||
futures-core = "0.3"
|
futures-core = "0.3"
|
||||||
hmac = "0.11"
|
hmac = "0.11"
|
||||||
|
|
|
@ -16,7 +16,6 @@ use std::io;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
|
|
||||||
use cfg_if::cfg_if;
|
|
||||||
use futures_core::Stream;
|
use futures_core::Stream;
|
||||||
use librespot_core as core;
|
use librespot_core as core;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
@ -100,29 +99,24 @@ impl Builder {
|
||||||
let name = self.server_config.name.clone().into_owned();
|
let name = self.server_config.name.clone().into_owned();
|
||||||
let server = DiscoveryServer::new(self.server_config, &mut port)?;
|
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! {
|
#[cfg(not(feature = "with-dns-sd"))]
|
||||||
if #[cfg(feature = "with-dns-sd")] {
|
let svc = libmdns::Responder::spawn(&tokio::runtime::Handle::current())?.register(
|
||||||
svc = dns_sd::DNSService::register(
|
"_spotify-connect._tcp".to_owned(),
|
||||||
Some(name.as_ref()),
|
name,
|
||||||
"_spotify-connect._tcp",
|
port,
|
||||||
None,
|
&["VERSION=1.0", "CPath=/"],
|
||||||
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=/"],
|
|
||||||
)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(Discovery { server, _svc: svc })
|
Ok(Discovery { server, _svc: svc })
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,7 +191,7 @@ impl Mixer for AlsaMixer {
|
||||||
mapped_volume = LogMapping::linear_to_mapped(mapped_volume, self.db_range);
|
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) {
|
fn set_volume(&self, volume: u16) {
|
||||||
|
|
|
@ -3,7 +3,7 @@ use crate::player::db_to_ratio;
|
||||||
|
|
||||||
pub trait MappedCtrl {
|
pub trait MappedCtrl {
|
||||||
fn to_mapped(&self, volume: u16) -> f64;
|
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 db_range(&self) -> f64;
|
||||||
fn set_db_range(&mut self, new_db_range: f64);
|
fn set_db_range(&mut self, new_db_range: f64);
|
||||||
|
@ -49,7 +49,7 @@ impl MappedCtrl for VolumeCtrl {
|
||||||
mapped_volume
|
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
|
// More than just an optimization, this ensures that zero mapped volume
|
||||||
// is unmapped to non-negative real numbers (otherwise the log and cubic
|
// is unmapped to non-negative real numbers (otherwise the log and cubic
|
||||||
// equations would respectively return -inf and -1/9.)
|
// equations would respectively return -inf and -1/9.)
|
||||||
|
|
|
@ -26,7 +26,7 @@ impl Mixer for SoftMixer {
|
||||||
|
|
||||||
fn volume(&self) -> u16 {
|
fn volume(&self) -> u16 {
|
||||||
let mapped_volume = f64::from_bits(self.volume.load(Ordering::Relaxed));
|
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) {
|
fn set_volume(&self, volume: u16) {
|
||||||
|
|
|
@ -586,7 +586,7 @@ fn get_setup() -> Setup {
|
||||||
|
|
||||||
let stripped_env_key = |k: &str| {
|
let stripped_env_key = |k: &str| {
|
||||||
k.trim_start_matches("LIBRESPOT_")
|
k.trim_start_matches("LIBRESPOT_")
|
||||||
.replace("_", "-")
|
.replace('_', "-")
|
||||||
.to_lowercase()
|
.to_lowercase()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue