fixes new clippy lints

This commit is contained in:
dvdsk 2024-06-17 13:22:37 +02:00
parent ae9eaedc22
commit 297bd99bc1
No known key found for this signature in database
GPG key ID: F687E89FC7894F98
2 changed files with 5 additions and 5 deletions

View file

@ -196,7 +196,7 @@ where
/// audiable when actually playing? /// audiable when actually playing?
fn f32_to_i16(f: f32) -> i16 { fn f32_to_i16(f: f32) -> i16 {
// prefer to clip the input rather than be excessively loud. // prefer to clip the input rather than be excessively loud.
(f.max(-1.0).min(1.0) * i16::max_value() as f32) as i16 (f.clamp(-1.0, 1.0) * i16::MAX as f32) as i16
} }
/// Returns an 8-bit WAV int as an i16. This scales the sample value by a factor /// Returns an 8-bit WAV int as an i16. This scales the sample value by a factor

View file

@ -272,7 +272,7 @@ impl CpalDeviceExt for cpal::Device {
*d = mixer_rx *d = mixer_rx
.next() .next()
.map(Sample::from_sample) .map(Sample::from_sample)
.unwrap_or(u8::max_value() / 2) .unwrap_or(u8::MAX / 2)
}) })
}, },
error_callback, error_callback,
@ -285,7 +285,7 @@ impl CpalDeviceExt for cpal::Device {
*d = mixer_rx *d = mixer_rx
.next() .next()
.map(Sample::from_sample) .map(Sample::from_sample)
.unwrap_or(u16::max_value() / 2) .unwrap_or(u16::MAX / 2)
}) })
}, },
error_callback, error_callback,
@ -298,7 +298,7 @@ impl CpalDeviceExt for cpal::Device {
*d = mixer_rx *d = mixer_rx
.next() .next()
.map(Sample::from_sample) .map(Sample::from_sample)
.unwrap_or(u32::max_value() / 2) .unwrap_or(u32::MAX / 2)
}) })
}, },
error_callback, error_callback,
@ -311,7 +311,7 @@ impl CpalDeviceExt for cpal::Device {
*d = mixer_rx *d = mixer_rx
.next() .next()
.map(Sample::from_sample) .map(Sample::from_sample)
.unwrap_or(u64::max_value() / 2) .unwrap_or(u64::MAX / 2)
}) })
}, },
error_callback, error_callback,