Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

clippy

Richie McIlroy7b34a39edea4
diff --git a/apps/desktop/src/utils/shared-frame-buffer.ts b/apps/desktop/src/utils/shared-frame-buffer.ts
index 8bbc6d4ec..7b0f82737 100644
--- a/apps/desktop/src/utils/shared-frame-buffer.ts
+++ b/apps/desktop/src/utils/shared-frame-buffer.ts
@@ -203,14 +203,12 @@ export function createProducer(init: SharedFrameBufferInit): Producer {
);
if (oldValue === observed) {
- const successSlotMetaIdx =
- (metadataOffset + observed * METADATA_ENTRY_SIZE) / 4;
Atomics.store(
metadataView,
- successSlotMetaIdx + META_SLOT_STATE,
+ slotMetaIdx + META_SLOT_STATE,
SLOT_STATE.READY,
);
- Atomics.notify(metadataView, successSlotMetaIdx + META_SLOT_STATE, 1);
+ Atomics.notify(metadataView, slotMetaIdx + META_SLOT_STATE, 1);
return true;
}
diff --git a/crates/rendering/src/decoder/avassetreader.rs b/crates/rendering/src/decoder/avassetreader.rs
index edccdc734..1a723d87e 100644
--- a/crates/rendering/src/decoder/avassetreader.rs
+++ b/crates/rendering/src/decoder/avassetreader.rs
@@ -22,7 +22,7 @@ use super::{FRAME_CACHE_SIZE, VideoDecoderMessage, pts_to_frame};
#[derive(Clone)]
struct ProcessedFrame {
- number: u32,
+ _number: u32,
data: Arc<Vec<u8>>,
width: u32,
height: u32,
@@ -198,7 +198,7 @@ impl CachedFrame {
let (data, format, y_stride, uv_stride) = processor.extract_raw(&mut image_buf);
let frame = ProcessedFrame {
- number,
+ _number: number,
data: Arc::new(data),
width,
height,
@@ -244,7 +244,7 @@ impl AVAssetReaderDecoder {
}
fn run(
- name: &'static str,
+ _name: &'static str,
path: PathBuf,
fps: u32,
rx: mpsc::Receiver<VideoDecoderMessage>,
@@ -272,11 +272,11 @@ impl AVAssetReaderDecoder {
let last_sent_frame = Rc::new(RefCell::new(None::<ProcessedFrame>));
let mut frames = this.inner.frames();
- let mut processor = ImageBufProcessor::new();
+ let processor = ImageBufProcessor::new();
while let Ok(r) = rx.recv() {
match r {
- VideoDecoderMessage::GetFrame(mut requested_time, mut sender) => {
+ VideoDecoderMessage::GetFrame(requested_time, sender) => {
if sender.is_closed() {
continue;
}
@@ -292,22 +292,22 @@ impl AVAssetReaderDecoder {
{
let is_backward_within_tolerance = requested_frame < c_min
&& requested_frame + BACKWARD_SEEK_TOLERANCE >= c_min;
- if is_backward_within_tolerance {
- if let Some(closest_frame) = cache.get(&c_min) {
- let data = closest_frame.data().clone();
- if let Err(err) = sender.send(data.to_decoded_frame()) {
- debug!(?err, "frame receiver dropped before send");
- }
- *last_sent_frame.borrow_mut() = Some(data);
- continue;
+ if is_backward_within_tolerance
+ && let Some(closest_frame) = cache.get(&c_min)
+ {
+ let data = closest_frame.data().clone();
+ if sender.send(data.to_decoded_frame()).is_err() {
+ debug!("frame receiver dropped before send");
}
+ *last_sent_frame.borrow_mut() = Some(data);
+ continue;
}
}
let mut sender = if let Some(cached) = cache.get(&requested_frame) {
let data = cached.data().clone();
- if let Err(err) = sender.send(data.to_decoded_frame()) {
- debug!(?err, "frame receiver dropped before send");
+ if sender.send(data.to_decoded_frame()).is_err() {
+ debug!("frame receiver dropped before send");
}
*last_sent_frame.borrow_mut() = Some(data);
continue;
@@ -315,8 +315,8 @@ impl AVAssetReaderDecoder {
let last_sent_frame = last_sent_frame.clone();
Some(move |data: ProcessedFrame| {
*last_sent_frame.borrow_mut() = Some(data.clone());
- if let Err(err) = sender.send(data.to_decoded_frame()) {
- debug!(?err, "frame receiver dropped before send");
+ if sender.send(data.to_decoded_frame()).is_err() {
+ debug!("frame receiver dropped before send");
}
})
};
@@ -365,7 +365,7 @@ impl AVAssetReaderDecoder {
};
let cache_frame =
- CachedFrame::new(&mut processor, frame.retained(), current_frame);
+ CachedFrame::new(&processor, frame.retained(), current_frame);
this.is_done = false;
@@ -444,7 +444,7 @@ impl AVAssetReaderDecoder {
let black_frame_data =
vec![0u8; (video_width * video_height * 4) as usize];
let black_frame = ProcessedFrame {
- number: requested_frame,
+ _number: requested_frame,
data: Arc::new(black_frame_data),
width: video_width,
height: video_height,
diff --git a/crates/rendering/src/decoder/mod.rs b/crates/rendering/src/decoder/mod.rs
index d20afec19..8d587d19c 100644
--- a/crates/rendering/src/decoder/mod.rs
+++ b/crates/rendering/src/decoder/mod.rs
@@ -1,5 +1,6 @@
use ::ffmpeg::Rational;
use std::{
+ fmt,
path::PathBuf,
sync::{Arc, mpsc},
};
@@ -18,7 +19,7 @@ pub enum PixelFormat {
Yuv420p,
}
-#[derive(Clone, Debug)]
+#[derive(Clone)]
pub struct DecodedFrame {
data: Arc<Vec<u8>>,
width: u32,
@@ -28,6 +29,19 @@ pub struct DecodedFrame {
uv_stride: u32,
}
+impl fmt::Debug for DecodedFrame {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ f.debug_struct("DecodedFrame")
+ .field("data_len", &self.data.len())
+ .field("width", &self.width)
+ .field("height", &self.height)
+ .field("format", &self.format)
+ .field("y_stride", &self.y_stride)
+ .field("uv_stride", &self.uv_stride)
+ .finish()
+ }
+}
+
impl DecodedFrame {
pub fn new(data: Vec<u8>, width: u32, height: u32) -> Self {
Self {
diff --git a/crates/rendering/src/frame_pipeline.rs b/crates/rendering/src/frame_pipeline.rs
index 5097e425e..bbeeef8c3 100644
--- a/crates/rendering/src/frame_pipeline.rs
+++ b/crates/rendering/src/frame_pipeline.rs
@@ -32,7 +32,7 @@ impl PendingReadback {
Err(e) => return Err(e.into()),
}
poll_count += 1;
- if poll_count % 3 == 0 {
+ if poll_count.is_multiple_of(3) {
tokio::task::yield_now().await;
}
}
diff --git a/crates/rendering/src/layers/camera.rs b/crates/rendering/src/layers/camera.rs
index 31addfa40..48c14d97f 100644
--- a/crates/rendering/src/layers/camera.rs
+++ b/crates/rendering/src/layers/camera.rs
@@ -120,8 +120,7 @@ impl CameraLayer {
PixelFormat::Nv12 => {
if let (Some(y_data), Some(uv_data)) =
(camera_frame.y_plane(), camera_frame.uv_plane())
- {
- if self
+ && self
.yuv_converter
.convert_nv12(
device,
@@ -133,9 +132,8 @@ impl CameraLayer {
camera_frame.y_stride(),
)
.is_ok()
- {
- self.copy_from_yuv_output(device, queue, next_texture, frame_size);
- }
+ {
+ self.copy_from_yuv_output(device, queue, next_texture, frame_size);
}
}
PixelFormat::Yuv420p => {
@@ -143,24 +141,22 @@ impl CameraLayer {
camera_frame.y_plane(),
camera_frame.u_plane(),
camera_frame.v_plane(),
- ) {
- if self
- .yuv_converter
- .convert_yuv420p(
- device,
- queue,
- y_data,
- u_data,
- v_data,
- frame_size.x,
- frame_size.y,
- camera_frame.y_stride(),
- camera_frame.uv_stride(),
- )
- .is_ok()
- {
- self.copy_from_yuv_output(device, queue, next_texture, frame_size);
- }
+ ) && self
+ .yuv_converter
+ .convert_yuv420p(
+ device,
+ queue,
+ y_data,
+ u_data,
+ v_data,
+ frame_size.x,
+ frame_size.y,
+ camera_frame.y_stride(),
+ camera_frame.uv_stride(),
+ )
+ .is_ok()
+ {
+ self.copy_from_yuv_output(device, queue, next_texture, frame_size);
}
}
}
diff --git a/crates/rendering/src/layers/display.rs b/crates/rendering/src/layers/display.rs
index 46861e76f..c2d4743bc 100644
--- a/crates/rendering/src/layers/display.rs
+++ b/crates/rendering/src/layers/display.rs
@@ -170,29 +170,27 @@ impl DisplayLayer {
screen_frame.y_plane(),
screen_frame.u_plane(),
screen_frame.v_plane(),
- ) {
- if self
- .yuv_converter
- .convert_yuv420p(
- device,
- queue,
- y_data,
- u_data,
- v_data,
- frame_size.x,
- frame_size.y,
- screen_frame.y_stride(),
- screen_frame.uv_stride(),
- )
- .is_ok()
- && self.yuv_converter.output_texture().is_some()
- {
- self.pending_copy = Some(PendingTextureCopy {
- width: frame_size.x,
- height: frame_size.y,
- dst_texture_index: next_texture,
- });
- }
+ ) && self
+ .yuv_converter
+ .convert_yuv420p(
+ device,
+ queue,
+ y_data,
+ u_data,
+ v_data,
+ frame_size.x,
+ frame_size.y,
+ screen_frame.y_stride(),
+ screen_frame.uv_stride(),
+ )
+ .is_ok()
+ && self.yuv_converter.output_texture().is_some()
+ {
+ self.pending_copy = Some(PendingTextureCopy {
+ width: frame_size.x,
+ height: frame_size.y,
+ dst_texture_index: next_texture,
+ });
}
}
}
diff --git a/crates/rendering/src/lib.rs b/crates/rendering/src/lib.rs
index 429d06b3d..1bd871cca 100644
--- a/crates/rendering/src/lib.rs
+++ b/crates/rendering/src/lib.rs
@@ -19,7 +19,6 @@ use spring_mass_damper::SpringMassDamperSimulationConfig;
use std::{collections::HashMap, sync::Arc};
use std::{path::PathBuf, time::Instant};
use tokio::sync::mpsc;
-use tracing::error;
mod composite_frame;
mod coord;
diff --git a/crates/rendering/src/yuv_converter.rs b/crates/rendering/src/yuv_converter.rs
index 2ed8631ea..d1bbe9875 100644
--- a/crates/rendering/src/yuv_converter.rs
+++ b/crates/rendering/src/yuv_converter.rs
@@ -106,10 +106,10 @@ pub struct YuvToRgbaConverter {
u_texture: Option<wgpu::Texture>,
v_texture: Option<wgpu::Texture>,
output_texture: Option<wgpu::Texture>,
- y_view: Option<wgpu::TextureView>,
- uv_view: Option<wgpu::TextureView>,
- u_view: Option<wgpu::TextureView>,
- v_view: Option<wgpu::TextureView>,
+ _y_view: Option<wgpu::TextureView>,
+ _uv_view: Option<wgpu::TextureView>,
+ _u_view: Option<wgpu::TextureView>,
+ _v_view: Option<wgpu::TextureView>,
output_view: Option<wgpu::TextureView>,
cached_width: u32,
cached_height: u32,
@@ -257,10 +257,10 @@ impl YuvToRgbaConverter {
u_texture: None,
v_texture: None,
output_texture: None,
- y_view: None,
- uv_view: None,
- u_view: None,
- v_view: None,
+ _y_view: None,
+ _uv_view: None,
+ _u_view: None,
+ _v_view: None,
output_view: None,
cached_width: 0,
cached_height: 0,
@@ -379,6 +379,7 @@ impl YuvToRgbaConverter {
self.cached_format = Some(format);
}
+ #[allow(clippy::too_many_arguments)]
pub fn convert_nv12(
&mut self,
device: &wgpu::Device,
@@ -461,6 +462,7 @@ impl YuvToRgbaConverter {
Ok(self.output_view.as_ref().unwrap())
}
+ #[allow(clippy::too_many_arguments)]
pub fn convert_yuv420p(
&mut self,
device: &wgpu::Device,