From e5261cb3239c92f13efd68b7c247599a64de52fd Mon Sep 17 00:00:00 2001 From: Brad Stein Date: Sat, 16 May 2026 17:47:58 -0300 Subject: [PATCH] ci: satisfy rust 1.92 clippy gate --- .../src/app/uplink_media/webcam_media_loop.rs | 3 --- client/src/input/audio_codec.rs | 2 +- client/src/input/camera/capture_pipeline.rs | 18 ++++++------------ client/src/launcher/preview/status_pipeline.rs | 10 +++++----- server/src/audio/ear_capture.rs | 15 +++++++-------- server/src/audio/opus_decode.rs | 2 +- server/src/bin/lesavka-synthetic-uplink.rs | 16 ++++++---------- server/src/bin/lesavka-uvc.real.inc | 15 +++++++-------- server/src/main/eye_hub.rs | 11 +++++------ .../main/relay_service/upstream_media_rpc.rs | 16 ++++++++-------- server/src/video_sinks/mjpeg_spool.rs | 2 +- server/src/video_sinks/webcam_sink.rs | 5 ++--- 12 files changed, 49 insertions(+), 66 deletions(-) diff --git a/client/src/app/uplink_media/webcam_media_loop.rs b/client/src/app/uplink_media/webcam_media_loop.rs index d4dcbcd..0188c23 100644 --- a/client/src/app/uplink_media/webcam_media_loop.rs +++ b/client/src/app/uplink_media/webcam_media_loop.rs @@ -212,7 +212,6 @@ impl LesavkaClientApp { let initial_camera_profile = initial_camera_profile.clone(); let active_camera_source = active_camera_source.clone(); let active_camera_profile = active_camera_profile.clone(); - let active_camera_codec = active_camera_codec; std::thread::spawn(move || { let mut waiting_for_hevc_keyframe = false; while !stop.load(Ordering::Relaxed) { @@ -273,8 +272,6 @@ impl LesavkaClientApp { let media_controls = media_controls.clone(); let initial_microphone_source = initial_microphone_source.clone(); let active_microphone_source = active_microphone_source.clone(); - let active_audio_codec = active_audio_codec; - let active_noise_suppression = active_noise_suppression; let active_camera_requested = camera_requested; std::thread::spawn(move || { while !stop.load(Ordering::Relaxed) { diff --git a/client/src/input/audio_codec.rs b/client/src/input/audio_codec.rs index 9abe3fd..5474409 100644 --- a/client/src/input/audio_codec.rs +++ b/client/src/input/audio_codec.rs @@ -153,7 +153,7 @@ impl OpusPacketEncoder { .iter() .position(|packet| packet.pts == pts_us) { - return self.pending_packets.drain(..=index).last(); + return self.pending_packets.drain(..=index).next_back(); } self.pending_packets.pop_front() } diff --git a/client/src/input/camera/capture_pipeline.rs b/client/src/input/camera/capture_pipeline.rs index 1b958dd..aa92bc1 100644 --- a/client/src/input/camera/capture_pipeline.rs +++ b/client/src/input/camera/capture_pipeline.rs @@ -73,12 +73,8 @@ impl CameraCapture { return Self::new_ffmpeg_hevc_nvenc( &dev_label, source_profile, - capture_width, - capture_height, - capture_fps, - width, - height, - fps, + (capture_width, capture_height, capture_fps), + (width, height, fps), keyframe_interval, camera_preview_tap_path(), ); @@ -301,16 +297,14 @@ impl CameraCapture { fn new_ffmpeg_hevc_nvenc( dev_label: &str, source_profile: CameraSourceProfile, - capture_width: u32, - capture_height: u32, - capture_fps: u32, - width: u32, - height: u32, - fps: u32, + capture_profile: (u32, u32, u32), + output_profile: (u32, u32, u32), keyframe_interval: u32, preview_tap_path: Option, ) -> anyhow::Result { let bitrate_kbit = env_u32("LESAVKA_CAM_HEVC_KBIT", 3000).max(250); + let (capture_width, capture_height, capture_fps) = capture_profile; + let (width, height, fps) = output_profile; let fps = fps.max(1); let capture_fps = capture_fps.max(1); let keyframe_interval = keyframe_interval.max(1); diff --git a/client/src/launcher/preview/status_pipeline.rs b/client/src/launcher/preview/status_pipeline.rs index 2131821..779e08e 100644 --- a/client/src/launcher/preview/status_pipeline.rs +++ b/client/src/launcher/preview/status_pipeline.rs @@ -241,11 +241,11 @@ fn preview_decoder_candidates() -> Vec { } candidates.sort(); candidates.dedup(); - if let Some(preferred) = preferred { - if let Some(pos) = candidates.iter().position(|name| name == &preferred) { - let decoder = candidates.remove(pos); - candidates.insert(0, decoder); - } + if let Some(preferred) = preferred + && let Some(pos) = candidates.iter().position(|name| name == &preferred) + { + let decoder = candidates.remove(pos); + candidates.insert(0, decoder); } candidates } diff --git a/server/src/audio/ear_capture.rs b/server/src/audio/ear_capture.rs index 0aca853..34efc3d 100644 --- a/server/src/audio/ear_capture.rs +++ b/server/src/audio/ear_capture.rs @@ -77,14 +77,13 @@ fn remember_active_audio_capture(generation: u64, pipeline: &gst::Pipeline) { }; if let Some((previous_generation, previous_pipeline)) = active.replace((generation, pipeline.clone())) + && previous_generation != generation { - if previous_generation != generation { - warn!( - previous_generation, - generation, "🔊 replacing overlapping downstream audio capture" - ); - let _ = previous_pipeline.set_state(gst::State::Null); - } + warn!( + previous_generation, + generation, "🔊 replacing overlapping downstream audio capture" + ); + let _ = previous_pipeline.set_state(gst::State::Null); } } @@ -228,7 +227,7 @@ fn level_message_looks_like_digital_silence(structure: &gst::StructureRef) -> bo fn log_remote_speaker_silence_hint() { static SILENCE_MESSAGES: AtomicU64 = AtomicU64::new(0); let count = SILENCE_MESSAGES.fetch_add(1, Ordering::Relaxed) + 1; - if count <= 3 || count % 30 == 0 { + if count <= 3 || count.is_multiple_of(30) { warn!( count, "🔇 downstream UAC speaker capture is digital silence; Lesavka audio path is open, but the RCT/host is not currently feeding audible audio into the USB speaker endpoint" diff --git a/server/src/audio/opus_decode.rs b/server/src/audio/opus_decode.rs index a81f801..41ab81a 100644 --- a/server/src/audio/opus_decode.rs +++ b/server/src/audio/opus_decode.rs @@ -121,7 +121,7 @@ impl OpusPacketDecoder { .iter() .position(|packet| packet.pts == pts_us) { - return self.pending_packets.drain(..=index).last(); + return self.pending_packets.drain(..=index).next_back(); } self.pending_packets.pop_front() } diff --git a/server/src/bin/lesavka-synthetic-uplink.rs b/server/src/bin/lesavka-synthetic-uplink.rs index 1dfce4b..4dbf87c 100755 --- a/server/src/bin/lesavka-synthetic-uplink.rs +++ b/server/src/bin/lesavka-synthetic-uplink.rs @@ -324,14 +324,11 @@ fn synthetic_rgb_frame(width: usize, height: usize, sequence: u64) -> Vec { for y in 0..height { for x in 0..width { let mut value = synthetic_luma( - width, - height, + (width, height), x, y, sequence, - moving_period, - moving_width, - moving_offset, + (moving_period, moving_width, moving_offset), ); if y >= height / 2 && (((x / 32) + (y / 24) + sequence as usize) & 1) == 0 { value /= 3; @@ -347,15 +344,14 @@ fn synthetic_rgb_frame(width: usize, height: usize, sequence: u64) -> Vec { } fn synthetic_luma( - width: usize, - height: usize, + frame_size: (usize, usize), x: usize, y: usize, sequence: u64, - moving_period: usize, - moving_width: usize, - moving_offset: usize, + moving_bar: (usize, usize, usize), ) -> u8 { + let (width, height) = frame_size; + let (moving_period, moving_width, moving_offset) = moving_bar; let mut value = ((x as u64 * 3 + y as u64 * 5 + sequence.saturating_mul(11)) & 0xff) as u8; let moving = (x + moving_offset) % moving_period; if moving < moving_width { diff --git a/server/src/bin/lesavka-uvc.real.inc b/server/src/bin/lesavka-uvc.real.inc index d893d66..a819003 100644 --- a/server/src/bin/lesavka-uvc.real.inc +++ b/server/src/bin/lesavka-uvc.real.inc @@ -488,14 +488,13 @@ impl UvcVideoStream { return; }; let now = Instant::now(); - if let Some(deadline) = self.next_queue_at { - if let Some(delay) = deadline.checked_duration_since(now) { - if !delay.is_zero() { - thread::sleep(delay); - self.stats.paced_sleeps += 1; - self.stats.paced_sleep_ms += delay.as_millis().min(u128::from(u64::MAX)) as u64; - } - } + if let Some(deadline) = self.next_queue_at + && let Some(delay) = deadline.checked_duration_since(now) + && !delay.is_zero() + { + thread::sleep(delay); + self.stats.paced_sleeps += 1; + self.stats.paced_sleep_ms += delay.as_millis().min(u128::from(u64::MAX)) as u64; } self.next_queue_at = Some(Instant::now() + period); } diff --git a/server/src/main/eye_hub.rs b/server/src/main/eye_hub.rs index 8657166..0fbeb33 100644 --- a/server/src/main/eye_hub.rs +++ b/server/src/main/eye_hub.rs @@ -44,12 +44,11 @@ impl EyeHub { } fn shutdown(&self) { - if self.running.swap(false, Ordering::AcqRel) { - if let Ok(mut task) = self.task.try_lock() - && let Some(task) = task.take() - { - task.abort(); - } + if self.running.swap(false, Ordering::AcqRel) + && let Ok(mut task) = self.task.try_lock() + && let Some(task) = task.take() + { + task.abort(); } } diff --git a/server/src/main/relay_service/upstream_media_rpc.rs b/server/src/main/relay_service/upstream_media_rpc.rs index 1097ca2..5591e84 100644 --- a/server/src/main/relay_service/upstream_media_rpc.rs +++ b/server/src/main/relay_service/upstream_media_rpc.rs @@ -359,14 +359,14 @@ impl Handler { outcome = if outcome == "aborted" { "closed" } else { outcome }; drop(audio_handoff_tx); drop(video_handoff_tx); - if let Some(audio_worker) = audio_worker { - if let Err(err) = audio_worker.await { - warn!( - rpc_id, - session_id = camera_lease.session_id, - "📦 v2 audio handoff worker join failed: {err}" - ); - } + if let Some(audio_worker) = audio_worker + && let Err(err) = audio_worker.await + { + warn!( + rpc_id, + session_id = camera_lease.session_id, + "📦 v2 audio handoff worker join failed: {err}" + ); } if let Err(err) = video_worker.await { warn!( diff --git a/server/src/video_sinks/mjpeg_spool.rs b/server/src/video_sinks/mjpeg_spool.rs index 762ea8d..f85e5f8 100644 --- a/server/src/video_sinks/mjpeg_spool.rs +++ b/server/src/video_sinks/mjpeg_spool.rs @@ -135,7 +135,7 @@ fn uvc_bulk_transfer_enabled() -> bool { return false; } let base = Path::new(CONFIGFS_UVC_BASE); - !(base.exists() && !base.join("streaming_bulk").exists()) + !base.exists() || base.join("streaming_bulk").exists() } fn uvc_streaming_maxpacket(bulk: bool) -> u32 { diff --git a/server/src/video_sinks/webcam_sink.rs b/server/src/video_sinks/webcam_sink.rs index 4916257..b53ee61 100644 --- a/server/src/video_sinks/webcam_sink.rs +++ b/server/src/video_sinks/webcam_sink.rs @@ -127,8 +127,7 @@ fn looks_like_annex_b_hevc(data: &[u8]) -> bool { fn uvc_hevc_freshness_queue_buffers() -> u32 { positive_u64_env("LESAVKA_UVC_HEVC_FRESHNESS_QUEUE_BUFFERS", 2) - .min(4) - .max(1) as u32 + .clamp(1, 4) as u32 } fn uvc_hevc_decode_miss_limit() -> u64 { @@ -1078,7 +1077,7 @@ impl WebcamSink { .fetch_add(1, std::sync::atomic::Ordering::Relaxed) + 1; let limit = u64::from(hevc_mjpeg_guard::direct_mjpeg_normalize_miss_limit()); - if misses == 1 || misses % 30 == 0 { + if misses == 1 || misses.is_multiple_of(30) { warn!( target:"lesavka_server::video", misses,