Skip to content

Commit cfd360e

Browse files
committed
clippy
1 parent d2df462 commit cfd360e

8 files changed

Lines changed: 59 additions & 67 deletions

File tree

apps/desktop/src-tauri/src/captions.rs

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -115,30 +115,28 @@ async fn extract_audio_from_video(video_path: &str, output_path: &PathBuf) -> Re
115115
if mixed_samples.is_empty() {
116116
mixed_samples = audio.samples().to_vec();
117117
channel_count = audio.channels() as usize;
118-
} else {
119-
if audio.channels() as usize != channel_count {
120-
log::info!(
121-
"Channel count mismatch: {} vs {}, mixing to mono",
122-
channel_count,
123-
audio.channels()
124-
);
125-
126-
if channel_count > 1 {
127-
let mono_samples = convert_to_mono(&mixed_samples, channel_count);
128-
mixed_samples = mono_samples;
129-
channel_count = 1;
130-
}
118+
} else if audio.channels() as usize != channel_count {
119+
log::info!(
120+
"Channel count mismatch: {} vs {}, mixing to mono",
121+
channel_count,
122+
audio.channels()
123+
);
131124

132-
let samples = if audio.channels() > 1 {
133-
convert_to_mono(audio.samples(), audio.channels() as usize)
134-
} else {
135-
audio.samples().to_vec()
136-
};
125+
if channel_count > 1 {
126+
let mono_samples = convert_to_mono(&mixed_samples, channel_count);
127+
mixed_samples = mono_samples;
128+
channel_count = 1;
129+
}
137130

138-
mix_samples(&mut mixed_samples, &samples);
131+
let samples = if audio.channels() > 1 {
132+
convert_to_mono(audio.samples(), audio.channels() as usize)
139133
} else {
140-
mix_samples(&mut mixed_samples, audio.samples());
141-
}
134+
audio.samples().to_vec()
135+
};
136+
137+
mix_samples(&mut mixed_samples, &samples);
138+
} else {
139+
mix_samples(&mut mixed_samples, audio.samples());
142140
}
143141
}
144142
Err(e) => {
@@ -1012,13 +1010,11 @@ fn start_whisperx_server(
10121010
std::thread::spawn(move || {
10131011
use std::io::BufRead;
10141012
let reader = std::io::BufReader::new(stderr);
1015-
for line in reader.lines() {
1016-
if let Ok(line) = line {
1017-
if line.starts_with("STDERR:") {
1018-
log::info!("[WhisperX] {}", &line[7..]);
1019-
} else {
1020-
log::info!("[WhisperX stderr] {}", line);
1021-
}
1013+
for line in reader.lines().flatten() {
1014+
if let Some(stripped) = line.strip_prefix("STDERR:") {
1015+
log::info!("[WhisperX] {}", stripped);
1016+
} else {
1017+
log::info!("[WhisperX stderr] {}", line);
10221018
}
10231019
}
10241020
});

apps/desktop/src-tauri/src/export.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::{FramesRendered, get_video_metadata};
22
use cap_export::ExporterBase;
3-
use cap_project::{RecordingMeta, XY};
3+
use cap_project::RecordingMeta;
44
use serde::Deserialize;
55
use specta::Type;
66
use std::path::PathBuf;

apps/desktop/src-tauri/src/tray.rs

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ impl TryFrom<MenuId> for TrayItem {
8989
#[derive(Debug, Clone)]
9090
enum PreviousItemType {
9191
StudioRecording,
92-
InstantRecording { link: Option<String> },
92+
InstantRecording {
93+
#[allow(dead_code)]
94+
link: Option<String>,
95+
},
9396
Screenshot,
9497
}
9598

@@ -104,16 +107,11 @@ struct CachedPreviousItem {
104107
created_at: std::time::SystemTime,
105108
}
106109

110+
#[derive(Default)]
107111
struct PreviousItemsCache {
108112
items: Vec<CachedPreviousItem>,
109113
}
110114

111-
impl Default for PreviousItemsCache {
112-
fn default() -> Self {
113-
Self { items: Vec::new() }
114-
}
115-
}
116-
117115
fn recordings_path(app: &AppHandle) -> PathBuf {
118116
let path = app.path().app_data_dir().unwrap().join("recordings");
119117
std::fs::create_dir_all(&path).unwrap_or_default();
@@ -230,27 +228,25 @@ fn load_all_previous_items(app: &AppHandle, load_thumbnails: bool) -> Vec<Cached
230228
let screenshots_dir = screenshots_path(app);
231229

232230
let recordings_dir = recordings_path(app);
233-
if recordings_dir.exists() {
234-
if let Ok(entries) = std::fs::read_dir(&recordings_dir) {
235-
for entry in entries.flatten() {
236-
if let Some(item) =
237-
load_single_item(&entry.path(), &screenshots_dir, load_thumbnails)
238-
{
239-
items.push(item);
240-
}
231+
if recordings_dir.exists()
232+
&& let Ok(entries) = std::fs::read_dir(&recordings_dir)
233+
{
234+
for entry in entries.flatten() {
235+
if let Some(item) = load_single_item(&entry.path(), &screenshots_dir, load_thumbnails) {
236+
items.push(item);
241237
}
242238
}
243239
}
244240

245-
if screenshots_dir.exists() {
246-
if let Ok(entries) = std::fs::read_dir(&screenshots_dir) {
247-
for entry in entries.flatten() {
248-
let path = entry.path();
249-
if path.extension().and_then(|s| s.to_str()) == Some("cap") {
250-
if let Some(item) = load_single_item(&path, &screenshots_dir, load_thumbnails) {
251-
items.push(item);
252-
}
253-
}
241+
if screenshots_dir.exists()
242+
&& let Ok(entries) = std::fs::read_dir(&screenshots_dir)
243+
{
244+
for entry in entries.flatten() {
245+
let path = entry.path();
246+
if path.extension().and_then(|s| s.to_str()) == Some("cap")
247+
&& let Some(item) = load_single_item(&path, &screenshots_dir, load_thumbnails)
248+
{
249+
items.push(item);
254250
}
255251
}
256252
}

crates/frame-converter/src/pool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ impl AsyncConverterPool {
185185
Err(flume::TrySendError::Full(_)) => {
186186
self.stats.frames_dropped.fetch_add(1, Ordering::Relaxed);
187187
let dropped = self.stats.frames_dropped.load(Ordering::Relaxed);
188-
if dropped % 30 == 0 {
188+
if dropped.is_multiple_of(30) {
189189
warn!(
190190
"Converter pool input full, dropped {} frames so far",
191191
dropped

crates/recording/src/feeds/camera.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -506,15 +506,15 @@ async fn setup_camera(
506506
}))
507507
.try_send();
508508

509-
if callback_num % 30 == 0 {
509+
if callback_num.is_multiple_of(30) {
510510
tracing::debug!(
511511
"Camera callback: sent frame {} to actor, result={:?}",
512512
callback_num,
513513
send_result.is_ok()
514514
);
515515
}
516516

517-
if send_result.is_err() && callback_num % 30 == 0 {
517+
if send_result.is_err() && callback_num.is_multiple_of(30) {
518518
tracing::warn!(
519519
"Camera callback: failed to send frame {} to actor (mailbox full?)",
520520
callback_num
@@ -612,15 +612,15 @@ async fn setup_camera(
612612
}))
613613
.try_send();
614614

615-
if callback_num % 30 == 0 {
615+
if callback_num.is_multiple_of(30) {
616616
tracing::debug!(
617617
"Camera callback: sent frame {} to actor, result={:?}",
618618
callback_num,
619619
send_result.is_ok()
620620
);
621621
}
622622

623-
if send_result.is_err() && callback_num % 30 == 0 {
623+
if send_result.is_err() && callback_num.is_multiple_of(30) {
624624
tracing::warn!(
625625
"Camera callback: failed to send frame {} to actor (mailbox full?)",
626626
callback_num
@@ -789,7 +789,7 @@ impl Message<NewFrame> for CameraFeed {
789789
async fn handle(&mut self, msg: NewFrame, _: &mut Context<Self, Self::Reply>) -> Self::Reply {
790790
let frame_num = CAMERA_FRAME_COUNTER.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
791791

792-
if frame_num % 30 == 0 {
792+
if frame_num.is_multiple_of(30) {
793793
debug!(
794794
"CameraFeed: received frame {}, broadcasting to {} senders",
795795
frame_num,
@@ -803,7 +803,7 @@ impl Message<NewFrame> for CameraFeed {
803803
match sender.try_send(msg.0.clone()) {
804804
Ok(()) => {}
805805
Err(flume::TrySendError::Full(_)) => {
806-
if frame_num % 30 == 0 {
806+
if frame_num.is_multiple_of(30) {
807807
warn!(
808808
"Camera sender {} channel full at frame {}, dropping frame",
809809
i, frame_num
@@ -843,7 +843,7 @@ impl Message<NewNativeFrame> for CameraFeed {
843843
let frame_num =
844844
NATIVE_CAMERA_FRAME_COUNTER.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
845845

846-
if frame_num % 30 == 0 {
846+
if frame_num.is_multiple_of(30) {
847847
debug!(
848848
"CameraFeed: received native frame {}, broadcasting to {} native senders",
849849
frame_num,
@@ -857,7 +857,7 @@ impl Message<NewNativeFrame> for CameraFeed {
857857
match sender.try_send(msg.0.clone()) {
858858
Ok(()) => {}
859859
Err(flume::TrySendError::Full(_)) => {
860-
if frame_num % 30 == 0 {
860+
if frame_num.is_multiple_of(30) {
861861
warn!(
862862
"Native camera sender {} channel full at frame {}, dropping frame",
863863
i, frame_num

crates/recording/src/output_pipeline/async_camera.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ impl VideoMuxer for AsyncCameraMp4Muxer {
267267
}
268268
}
269269

270-
if self.frames_submitted % 60 == 0 {
270+
if self.frames_submitted.is_multiple_of(60) {
271271
trace!(
272272
"Camera encoder progress: submitted={}, encoded={}, backlog={}",
273273
self.frames_submitted, self.frames_encoded, backlog

crates/recording/src/sources/camera.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl VideoSource for Camera {
6969
match video_tx.try_send(frame) {
7070
Ok(()) => {
7171
sent_count += 1;
72-
if sent_count % 30 == 0 {
72+
if sent_count.is_multiple_of(30) {
7373
tracing::debug!(
7474
"Camera source: sent {} frames, dropped {} in {:?}",
7575
sent_count,
@@ -81,7 +81,7 @@ impl VideoSource for Camera {
8181
Err(e) => {
8282
if e.is_full() {
8383
dropped_count += 1;
84-
if dropped_count % 30 == 0 {
84+
if dropped_count.is_multiple_of(30) {
8585
tracing::warn!(
8686
"Camera source: encoder can't keep up, dropped {} frames so far",
8787
dropped_count

crates/recording/src/sources/native_camera.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl VideoSource for NativeCamera {
6868
match video_tx.try_send(frame) {
6969
Ok(()) => {
7070
sent_count += 1;
71-
if sent_count % 30 == 0 {
71+
if sent_count.is_multiple_of(30) {
7272
tracing::debug!(
7373
"Native camera source: sent {} frames, dropped {} in {:?}",
7474
sent_count,
@@ -80,7 +80,7 @@ impl VideoSource for NativeCamera {
8080
Err(e) => {
8181
if e.is_full() {
8282
dropped_count += 1;
83-
if dropped_count % 30 == 0 {
83+
if dropped_count.is_multiple_of(30) {
8484
tracing::warn!(
8585
"Native camera source: encoder can't keep up, dropped {} frames so far",
8686
dropped_count

0 commit comments

Comments
 (0)