From 662debd4146fa090f144b1ec0c4dd83d977fc9a2 Mon Sep 17 00:00:00 2001 From: Kyle Simpson Date: Sun, 20 Nov 2022 17:59:28 +0000 Subject: [PATCH] Chore: Fix new(er) Clippy lints --- src/driver/tasks/disposal.rs | 2 +- src/driver/tasks/mixer/mix_logic.rs | 10 +++++----- src/driver/tasks/mixer/mod.rs | 5 ++--- src/input/adapters/cached/hint.rs | 2 +- src/input/adapters/cached/util.rs | 4 ++-- src/input/sources/file.rs | 2 +- src/input/sources/ytdl.rs | 2 +- 7 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/driver/tasks/disposal.rs b/src/driver/tasks/disposal.rs index 1e88026..448f4e5 100644 --- a/src/driver/tasks/disposal.rs +++ b/src/driver/tasks/disposal.rs @@ -24,7 +24,7 @@ impl DisposalThread { } pub(super) fn dispose(&self, message: DisposalMessage) { - drop(self.0.send(message)) + drop(self.0.send(message)); } } diff --git a/src/driver/tasks/mixer/mix_logic.rs b/src/driver/tasks/mixer/mix_logic.rs index da0cb37..9aa6fd2 100644 --- a/src/driver/tasks/mixer/mix_logic.rs +++ b/src/driver/tasks/mixer/mix_logic.rs @@ -307,7 +307,7 @@ where if source_mono { // mix this signal into *all* output channels at req'd volume. let source_plane = source_raw_planes[0]; - for d_plane in (&mut *target.planes_mut().planes()).iter_mut() { + for d_plane in (*target.planes_mut().planes()).iter_mut() { for (d, s) in d_plane[dest_pos..dest_pos + mix_ct] .iter_mut() .zip(source_plane[source_pos..source_pos + mix_ct].iter()) @@ -331,7 +331,7 @@ where } } else { // stereo -> stereo: don't change volume, map input -> output channels w/ no duplication - for (d_plane, s_plane) in (&mut *target.planes_mut().planes()) + for (d_plane, s_plane) in (*target.planes_mut().planes()) .iter_mut() .zip(source_raw_planes[..].iter()) { @@ -364,7 +364,7 @@ fn mix_resampled( // see `mix_symph_buffer` for explanations of stereo<->mono logic. if source_mono { let source_plane = &source[0]; - for d_plane in (&mut *target.planes_mut().planes()).iter_mut() { + for d_plane in (*target.planes_mut().planes()).iter_mut() { for (d, s) in d_plane[dest_pos..dest_pos + mix_ct] .iter_mut() .zip(source_plane) @@ -382,7 +382,7 @@ fn mix_resampled( } } } else { - for (d_plane, s_plane) in (&mut *target.planes_mut().planes()) + for (d_plane, s_plane) in (*target.planes_mut().planes()) .iter_mut() .zip(source[..].iter()) { @@ -428,7 +428,7 @@ fn copy_symph_buffer( where S: Sample + IntoSample, { - for (d_plane, s_plane) in (&mut *target.planes_mut().planes()) + for (d_plane, s_plane) in (*target.planes_mut().planes()) .iter_mut() .zip(source.planes().planes()[..].iter()) { diff --git a/src/driver/tasks/mixer/mod.rs b/src/driver/tasks/mixer/mod.rs index 04a8d88..2c5beae 100644 --- a/src/driver/tasks/mixer/mod.rs +++ b/src/driver/tasks/mixer/mod.rs @@ -635,8 +635,7 @@ impl Mixer { let payload = rtp.payload_mut(); - (&mut payload[TAG_SIZE..TAG_SIZE + SILENT_FRAME.len()]) - .copy_from_slice(&SILENT_FRAME[..]); + payload[TAG_SIZE..TAG_SIZE + SILENT_FRAME.len()].copy_from_slice(&SILENT_FRAME[..]); mix_len = MixType::Passthrough(SILENT_FRAME.len()); } else { @@ -680,7 +679,7 @@ impl Mixer { // for handing out audio data to the outside world. let samples_to_copy = self.config.mix_mode.channels() * n; - (&mut softclip_buffer[..samples_to_copy]) + softclip_buffer[..samples_to_copy] .copy_from_slice(&self.sample_buffer.samples()[..samples_to_copy]); } diff --git a/src/input/adapters/cached/hint.rs b/src/input/adapters/cached/hint.rs index b32fbce..7515378 100644 --- a/src/input/adapters/cached/hint.rs +++ b/src/input/adapters/cached/hint.rs @@ -33,7 +33,7 @@ where config.length_hint = Some(match hint.into() { LengthHint::Bytes(a) => a, LengthHint::Time(t) => { - let s = t.as_secs() + if t.subsec_millis() > 0 { 1 } else { 0 }; + let s = t.as_secs() + u64::from(t.subsec_millis() > 0); (s as usize) * cost_per_sec }, }); diff --git a/src/input/adapters/cached/util.rs b/src/input/adapters/cached/util.rs index 7167546..53fde40 100644 --- a/src/input/adapters/cached/util.rs +++ b/src/input/adapters/cached/util.rs @@ -386,7 +386,7 @@ where let to_write = remaining.min(interleaved_space); let need_spill = non_contiguous_end && to_write < remaining; - let samples_used = to_write + if need_spill { 1 } else { 0 }; + let samples_used = to_write + usize::from(need_spill); let last_sample = source_pos.start + to_write; if need_spill { @@ -430,7 +430,7 @@ fn write_resample_buffer( let to_write = remaining.min(interleaved_space); let need_spill = non_contiguous_end && to_write < remaining; - let samples_used = to_write + if need_spill { 1 } else { 0 }; + let samples_used = to_write + usize::from(need_spill); let last_sample = source_pos.start + to_write; if need_spill { diff --git a/src/input/sources/file.rs b/src/input/sources/file.rs index 5597f1f..fade69d 100644 --- a/src/input/sources/file.rs +++ b/src/input/sources/file.rs @@ -69,7 +69,7 @@ impl + Send + Sync> Compose for File

{ ]; let mut output = Command::new("ffprobe") - .args(&args) + .args(args) .output() .await .map_err(|e| AudioStreamError::Fail(Box::new(e)))?; diff --git a/src/input/sources/ytdl.rs b/src/input/sources/ytdl.rs index 6f032ff..f34eb69 100644 --- a/src/input/sources/ytdl.rs +++ b/src/input/sources/ytdl.rs @@ -60,7 +60,7 @@ impl YoutubeDl { let ytdl_args = ["-j", &self.url, "-f", "ba[abr>0][vcodec=none]/best"]; let mut output = Command::new(self.program) - .args(&ytdl_args) + .args(ytdl_args) .output() .await .map_err(|e| AudioStreamError::Fail(Box::new(e)))?;