Skip to content

Commit 8dcee4a

Browse files
committed
refactor: clippy fixes for ALSA backend
- Use Rust format string syntax for error messages - Remove redundant reference in DeviceHandles::open call - Simplify timespec_to_nanos calculation
1 parent 42e254c commit 8dcee4a

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

src/host/alsa/enumerate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ unsafe impl Sync for Devices {}
3131

3232
fn open_device(pcm_id: &str, desc: Option<String>) -> Device {
3333
// Try to open handles during enumeration
34-
let handles = DeviceHandles::open(&pcm_id).unwrap_or_else(|_| {
34+
let handles = DeviceHandles::open(pcm_id).unwrap_or_else(|_| {
3535
// If opening fails during enumeration, create default handles
3636
// The actual opening will be attempted when the device is used
3737
DeviceHandles::default()

src/host/alsa/mod.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -889,9 +889,8 @@ fn process_output(
889889
}
890890
Ok(result) if result != available_frames => {
891891
let description = format!(
892-
"unexpected number of frames written: expected {}, \
893-
result {} (this should never happen)",
894-
available_frames, result,
892+
"unexpected number of frames written: expected {available_frames}, \
893+
result {result} (this should never happen)"
895894
);
896895
error_callback(BackendSpecificError { description }.into());
897896
continue;
@@ -941,7 +940,7 @@ fn stream_timestamp(
941940
// Adapted from `timestamp2ns` here:
942941
// https://fossies.org/linux/alsa-lib/test/audio_time.c
943942
fn timespec_to_nanos(ts: libc::timespec) -> i64 {
944-
ts.tv_sec as i64 * 1_000_000_000 + ts.tv_nsec as i64
943+
(ts.tv_sec * 1_000_000_000 + ts.tv_nsec).into()
945944
}
946945

947946
// Adapted from `timediff` here:
@@ -1099,8 +1098,7 @@ fn set_hw_params_from_format(
10991098
sample_format => {
11001099
return Err(BackendSpecificError {
11011100
description: format!(
1102-
"Sample format '{}' is not supported by this backend",
1103-
sample_format
1101+
"Sample format '{sample_format}' is not supported by this backend"
11041102
),
11051103
})
11061104
}
@@ -1124,8 +1122,7 @@ fn set_hw_params_from_format(
11241122
sample_format => {
11251123
return Err(BackendSpecificError {
11261124
description: format!(
1127-
"Sample format '{}' is not supported by this backend",
1128-
sample_format
1125+
"Sample format '{sample_format}' is not supported by this backend"
11291126
),
11301127
})
11311128
}

0 commit comments

Comments
 (0)