Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
clippy
Richie McIlroy6864653998ca
diff --git a/apps/desktop/src-tauri/src/windows.rs b/apps/desktop/src-tauri/src/windows.rsindex e1bbc509e..ecccce3df 100644--- a/apps/desktop/src-tauri/src/windows.rs+++ b/apps/desktop/src-tauri/src/windows.rs@@ -796,6 +796,7 @@ impl ShowCapWindow {show_result);let _ = window.set_focus();+ fake_window::spawn_fake_window_listener(app.clone(), window.clone());}windowdiff --git a/crates/recording/src/output_pipeline/win_segmented_camera.rs b/crates/recording/src/output_pipeline/win_segmented_camera.rsindex c50dcefb4..7b0fd44b4 100644--- a/crates/recording/src/output_pipeline/win_segmented_camera.rs+++ b/crates/recording/src/output_pipeline/win_segmented_camera.rs@@ -236,10 +236,15 @@ impl WindowsSegmentedCameraMuxer {};let manifest_path = self.base_path.join("manifest.json");- let _ = std::fs::write(- manifest_path,+ if let Err(e) = std::fs::write(+ &manifest_path,serde_json::to_string_pretty(&manifest).unwrap_or_default(),- );+ ) {+ warn!(+ "Failed to write manifest to {}: {e}",+ manifest_path.display()+ );+ }}fn finalize_manifest(&self) {diff --git a/crates/rendering/src/cpu_yuv.rs b/crates/rendering/src/cpu_yuv.rsindex c9e333549..95d7461f0 100644--- a/crates/rendering/src/cpu_yuv.rs+++ b/crates/rendering/src/cpu_yuv.rs@@ -44,6 +44,7 @@ pub fn nv12_to_rgba(}}+#[allow(clippy::too_many_arguments)]pub fn yuv420p_to_rgba(y_data: &[u8],u_data: &[u8],@@ -230,6 +231,7 @@ pub fn nv12_to_rgba_simd(}#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]+#[allow(clippy::too_many_arguments)]pub fn yuv420p_to_rgba_simd(y_data: &[u8],u_data: &[u8],@@ -357,6 +359,7 @@ pub fn yuv420p_to_rgba_simd(}#[cfg(not(any(target_arch = "x86_64", target_arch = "x86")))]+#[allow(clippy::too_many_arguments)]pub fn yuv420p_to_rgba_simd(y_data: &[u8],u_data: &[u8],diff --git a/crates/rendering/src/decoder/ffmpeg.rs b/crates/rendering/src/decoder/ffmpeg.rsindex 6a1685695..450e8db07 100644--- a/crates/rendering/src/decoder/ffmpeg.rs+++ b/crates/rendering/src/decoder/ffmpeg.rs@@ -1,3 +1,5 @@+#![allow(dead_code)]+use ffmpeg::{format, frame, sys::AVHWDeviceType};use log::debug;use std::{diff --git a/crates/rendering/src/decoder/frame_converter.rs b/crates/rendering/src/decoder/frame_converter.rsindex 30b6d40ad..27a24fcac 100644--- a/crates/rendering/src/decoder/frame_converter.rs+++ b/crates/rendering/src/decoder/frame_converter.rs@@ -1,3 +1,5 @@+#![allow(dead_code)]+use ffmpeg::{format, frame, software};pub struct FrameConverter {diff --git a/crates/rendering/src/layers/display.rs b/crates/rendering/src/layers/display.rsindex 970501989..78e3dd9fc 100644--- a/crates/rendering/src/layers/display.rs+++ b/crates/rendering/src/layers/display.rs@@ -26,6 +26,7 @@ pub struct DisplayLayer {}impl DisplayLayer {+ #[allow(dead_code)]pub fn new(device: &wgpu::Device) -> Self {Self::new_with_options(device, false)}diff --git a/crates/rendering/src/yuv_converter.rs b/crates/rendering/src/yuv_converter.rsindex 3386f61e6..f97841158 100644--- a/crates/rendering/src/yuv_converter.rs+++ b/crates/rendering/src/yuv_converter.rs@@ -25,6 +25,12 @@ pub enum YuvConversionError {expected: usize,actual: usize,},+ #[error("{dimension} dimension ({value}) exceeds maximum allowed ({max})")]+ DimensionExceedsLimit {+ dimension: &'static str,+ value: u32,+ max: u32,+ },#[cfg(target_os = "macos")]#[error("IOSurface error: {0}")]IOSurfaceError(#[from] IOSurfaceTextureError),@@ -79,6 +85,24 @@ fn upload_plane_with_stride(const MAX_TEXTURE_WIDTH: u32 = 3840;const MAX_TEXTURE_HEIGHT: u32 = 2160;+fn validate_dimensions(width: u32, height: u32) -> Result<(), YuvConversionError> {+ if width > MAX_TEXTURE_WIDTH {+ return Err(YuvConversionError::DimensionExceedsLimit {+ dimension: "width",+ value: width,+ max: MAX_TEXTURE_WIDTH,+ });+ }+ if height > MAX_TEXTURE_HEIGHT {+ return Err(YuvConversionError::DimensionExceedsLimit {+ dimension: "height",+ value: height,+ max: MAX_TEXTURE_HEIGHT,+ });+ }+ Ok(())+}+pub struct YuvToRgbaConverter {nv12_pipeline: wgpu::ComputePipeline,yuv420p_pipeline: wgpu::ComputePipeline,@@ -376,6 +400,7 @@ impl YuvToRgbaConverter {y_stride: u32,uv_stride: u32,) -> Result<&wgpu::TextureView, YuvConversionError> {+ validate_dimensions(width, height)?;self.swap_output_buffer();upload_plane_with_stride(queue, &self.y_texture, y_data, width, height, y_stride, "Y")?;@@ -469,6 +494,8 @@ impl YuvToRgbaConverter {let width = image_buf.width() as u32;let height = image_buf.height() as u32;+ validate_dimensions(width, height)?;+let y_metal_texture = cache.create_y_texture(io_surface, width, height)?;let uv_metal_texture = cache.create_uv_texture(io_surface, width, height)?;@@ -544,6 +571,7 @@ impl YuvToRgbaConverter {y_stride: u32,uv_stride: u32,) -> Result<&wgpu::TextureView, YuvConversionError> {+ validate_dimensions(width, height)?;self.swap_output_buffer();upload_plane_with_stride(queue, &self.y_texture, y_data, width, height, y_stride, "Y")?;@@ -623,6 +651,8 @@ impl YuvToRgbaConverter {width: u32,height: u32,) -> Result<&wgpu::TextureView, YuvConversionError> {+ validate_dimensions(width, height)?;+use windows::Win32::Graphics::Dxgi::Common::DXGI_FORMAT_NV12;if self.d3d11_staging_width != width@@ -773,6 +803,8 @@ impl YuvToRgbaConverter {width: u32,height: u32,) -> Result<&wgpu::TextureView, YuvConversionError> {+ validate_dimensions(width, height)?;+use crate::d3d_texture::import_d3d11_texture_to_wgpu;self.swap_output_buffer();@@ -848,6 +880,7 @@ impl YuvToRgbaConverter {y_stride: u32,uv_stride: u32,) -> Result<&wgpu::TextureView, YuvConversionError> {+ validate_dimensions(width, height)?;self.swap_output_buffer();let mut rgba_data = vec![0u8; (width * height * 4) as usize];@@ -898,6 +931,7 @@ impl YuvToRgbaConverter {y_stride: u32,uv_stride: u32,) -> Result<&wgpu::TextureView, YuvConversionError> {+ validate_dimensions(width, height)?;self.swap_output_buffer();let mut rgba_data = vec![0u8; (width * height * 4) as usize];diff --git a/crates/video-decode/src/media_foundation.rs b/crates/video-decode/src/media_foundation.rsindex 2217a65c0..2b635071d 100644--- a/crates/video-decode/src/media_foundation.rs+++ b/crates/video-decode/src/media_foundation.rs@@ -1,5 +1,3 @@-#![cfg(target_os = "windows")]-use std::path::Path;use tracing::info;use windows::{@@ -10,14 +8,11 @@ use windows::{Direct3D11::{D3D11_BIND_SHADER_RESOURCE, D3D11_CPU_ACCESS_READ,D3D11_CREATE_DEVICE_BGRA_SUPPORT, D3D11_CREATE_DEVICE_VIDEO_SUPPORT,- D3D11_MAP_READ, D3D11_MAPPED_SUBRESOURCE, D3D11_RESOURCE_MISC_SHARED_NTHANDLE,- D3D11_SDK_VERSION, D3D11_TEXTURE2D_DESC, D3D11_USAGE_DEFAULT, D3D11_USAGE_STAGING,- D3D11CreateDevice, ID3D11Device, ID3D11DeviceContext, ID3D11Texture2D,- },- Dxgi::{- Common::{DXGI_FORMAT_NV12, DXGI_SAMPLE_DESC},- DXGI_SHARED_RESOURCE_READ, IDXGIResource1,+ D3D11_MAP_READ, D3D11_MAPPED_SUBRESOURCE, D3D11_SDK_VERSION, D3D11_TEXTURE2D_DESC,+ D3D11_USAGE_DEFAULT, D3D11_USAGE_STAGING, D3D11CreateDevice, ID3D11Device,+ ID3D11DeviceContext, ID3D11Texture2D,},+ Dxgi::Common::{DXGI_FORMAT_NV12, DXGI_SAMPLE_DESC},},Media::MediaFoundation::{IMFAttributes, IMFDXGIBuffer, IMFDXGIDeviceManager, IMFSample, IMFSourceReader,@@ -65,6 +60,17 @@ pub struct MediaFoundationDecoder {staging_height: u32,}+struct MFInitGuard;++impl Drop for MFInitGuard {+ fn drop(&mut self) {+ unsafe {+ let _ = MFShutdown();+ CoUninitialize();+ }+ }+}+impl MediaFoundationDecoder {pub fn new(path: impl AsRef<Path>) -> Result<Self, String> {unsafe { Self::new_inner(path.as_ref()) }@@ -80,6 +86,8 @@ impl MediaFoundationDecoder {.map_err(|e| format!("Failed to start Media Foundation: {e:?}"))?;}+ let guard = MFInitGuard;+let (d3d11_device, d3d11_context) = unsafe { create_d3d11_device()? };let device_manager = unsafe { create_dxgi_device_manager(&d3d11_device)? };@@ -95,6 +103,8 @@ impl MediaFoundationDecoder {width, height, frame_rate_num, frame_rate_den);+ std::mem::forget(guard);+Ok(Self {source_reader,d3d11_device,@@ -324,8 +334,9 @@ impl MediaFoundationDecoder {unsafe {let prop_ptr = prop.as_mut_ptr();let inner_ptr = std::ptr::addr_of_mut!((*prop_ptr).Anonymous.Anonymous);- std::ptr::addr_of_mut!((*inner_ptr).vt).write(windows::Win32::System::Variant::VT_I8);- std::ptr::addr_of_mut!((*inner_ptr).Anonymous.hVal).write(time_100ns);+ let inner = &mut *inner_ptr;+ inner.vt = windows::Win32::System::Variant::VT_I8;+ inner.Anonymous.hVal = time_100ns;let prop = prop.assume_init();self.source_reader@@ -502,26 +513,6 @@ unsafe fn get_video_info(source_reader: &IMFSourceReader) -> Result<(u32, u32, uOk((width, height, frame_rate_num, frame_rate_den.max(1)))}-unsafe fn get_shared_handle(texture: &ID3D11Texture2D) -> Result<HANDLE, String> {- use windows::Win32::Security::SECURITY_ATTRIBUTES;-- let dxgi_resource: IDXGIResource1 = texture- .cast()- .map_err(|e| format!("Failed to cast to IDXGIResource1: {e:?}"))?;-- let handle = unsafe {- dxgi_resource- .CreateSharedHandle(- None::<*const SECURITY_ATTRIBUTES>,- DXGI_SHARED_RESOURCE_READ.0,- PCWSTR::null(),- )- .map_err(|e| format!("CreateSharedHandle failed: {e:?}"))?- };-- Ok(handle)-}-struct YuvPlaneTextures {y_texture: ID3D11Texture2D,y_handle: Option<HANDLE>,