Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fmt
Richie McIlroy2edc948d6eea
diff --git a/crates/rendering/src/zoom.rs b/crates/rendering/src/zoom.rsindex 2ae4c33ba..2ce9e9cc5 100644--- a/crates/rendering/src/zoom.rs+++ b/crates/rendering/src/zoom.rs@@ -425,10 +425,8 @@ impl InterpolatedZoom {},};- if is_auto_mode {- if let Some(cursor_coord) = actual_cursor {- return result.ensure_cursor_visible((cursor_coord.x, cursor_coord.y));- }+ if is_auto_mode && let Some(cursor_coord) = actual_cursor {+ return result.ensure_cursor_visible((cursor_coord.x, cursor_coord.y));}resultdiff --git a/crates/rendering/src/zoom_focus_interpolation.rs b/crates/rendering/src/zoom_focus_interpolation.rsindex 7a1c983b4..a622b9c7d 100644--- a/crates/rendering/src/zoom_focus_interpolation.rs+++ b/crates/rendering/src/zoom_focus_interpolation.rs@@ -142,10 +142,10 @@ impl ZoomFocusInterpolator {return Coord::new(XY::new(pos.x as f64, pos.y as f64));}- if let Some(last) = events.last() {- if time_ms >= last.time {- return Coord::new(XY::new(last.position.x as f64, last.position.y as f64));- }+ if let Some(last) = events.last()+ && time_ms >= last.time+ {+ return Coord::new(XY::new(last.position.x as f64, last.position.y as f64));}let idx = eventsdiff --git a/crates/scap-cpal/src/lib.rs b/crates/scap-cpal/src/lib.rsindex 9eee0832e..0a81c1bb1 100644--- a/crates/scap-cpal/src/lib.rs+++ b/crates/scap-cpal/src/lib.rs@@ -1,9 +1,13 @@use cpal::{- InputCallbackInfo, PauseStreamError, PlayStreamError, Stream, StreamConfig, StreamError,- traits::StreamTrait,+ BufferSize, InputCallbackInfo, PauseStreamError, PlayStreamError, Stream, StreamConfig,+ StreamError, SupportedBufferSize, traits::StreamTrait,};use thiserror::Error;+const DEFAULT_BUFFER_FRAMES: u32 = 4096;+const MIN_BUFFER_FRAMES: u32 = 256;+const MAX_BUFFER_FRAMES: u32 = 16384;+#[derive(Clone, Error, Debug)]pub enum CapturerError {#[error("NoDevice")]@@ -14,6 +18,25 @@ pub enum CapturerError {BuildStream(String),}+fn safe_buffer_size(supported: &SupportedBufferSize, sample_rate: u32) -> BufferSize {+ match supported {+ SupportedBufferSize::Range { min, max } => {+ let target_frames = if sample_rate > 0 {+ let target_ms = 80u64;+ let frames = (sample_rate as u64 * target_ms) / 1000;+ frames.clamp(MIN_BUFFER_FRAMES as u64, MAX_BUFFER_FRAMES as u64) as u32+ } else {+ DEFAULT_BUFFER_FRAMES+ };++ let clamped = target_frames.clamp(*min, *max);++ BufferSize::Fixed(clamped)+ }+ SupportedBufferSize::Unknown => BufferSize::Default,+ }+}+pub fn create_capturer(mut data_callback: impl FnMut(&cpal::Data, &InputCallbackInfo, &StreamConfig) + Send + 'static,error_callback: impl FnMut(StreamError) + Send + 'static,@@ -27,7 +50,14 @@ pub fn create_capturer(let supported_config = output_device.default_output_config().map_err(|e| CapturerError::DefaultConfig(e.to_string()))?;- let config = supported_config.clone().into();++ let buffer_size = safe_buffer_size(+ supported_config.buffer_size(),+ supported_config.sample_rate().0,+ );++ let mut config: StreamConfig = supported_config.clone().into();+ config.buffer_size = buffer_size;let stream = output_device.build_input_stream_raw(