Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
Refactor camera setup, unify formatting, update tests
Richie McIlroy0b3cbab469a1
diff --git a/crates/enc-ffmpeg/src/remux.rs b/crates/enc-ffmpeg/src/remux.rsindex 25d57d224..a9fa2fe65 100644--- a/crates/enc-ffmpeg/src/remux.rs+++ b/crates/enc-ffmpeg/src/remux.rs@@ -478,8 +478,7 @@ fn probe_video_seek_point_with(if packets_tried >= SEEK_PROBE_PACKET_LIMIT {return Err(format!(- "No decodable frames found within {} packets after seeking to {position_us}us",- SEEK_PROBE_PACKET_LIMIT+ "No decodable frames found within {SEEK_PROBE_PACKET_LIMIT} packets after seeking to {position_us}us"));}}diff --git a/crates/recording/src/feeds/camera.rs b/crates/recording/src/feeds/camera.rsindex 879713e4f..23eb475f1 100644--- a/crates/recording/src/feeds/camera.rs+++ b/crates/recording/src/feeds/camera.rs@@ -327,7 +327,7 @@ struct FinalizePendingRelease {id: DeviceOrModelID,}-fn spawn_camera_setup(+struct SpawnCameraSetupArgs {id: DeviceOrModelID,generation: u64,settings: Option<CameraDeviceSettings>,@@ -336,7 +336,21 @@ fn spawn_camera_setup(native_frame_recipient: Recipient<NewNativeFrame>,native_sender_count: Arc<std::sync::atomic::AtomicUsize>,flow: CameraSetupFlow,+}++fn spawn_camera_setup(+ args: SpawnCameraSetupArgs,) -> (ReadyFuture, SyncSender<()>, std::thread::JoinHandle<()>) {+ let SpawnCameraSetupArgs {+ id,+ generation,+ settings,+ actor_ref,+ new_frame_recipient,+ native_frame_recipient,+ native_sender_count,+ flow,+ } = args;let (ready_tx, ready_rx) = oneshot::channel::<Result<InputConnected, SetInputError>>();let (done_tx, done_rx) = std::sync::mpsc::sync_channel(1);@@ -946,16 +960,16 @@ impl Message<SetInput> for CameraFeed {let native_frame_recipient = actor_ref.clone().recipient();let id = msg.id.clone();- let (ready, done_tx, join_handle) = spawn_camera_setup(- id.clone(),+ let (ready, done_tx, join_handle) = spawn_camera_setup(SpawnCameraSetupArgs {+ id: id.clone(),generation,- msg.settings,+ settings: msg.settings,actor_ref,new_frame_recipient,native_frame_recipient,- self.native_sender_count.clone(),- CameraSetupFlow::Open,- );+ native_sender_count: self.native_sender_count.clone(),+ flow: CameraSetupFlow::Open,+ });self.previous_thread = Some(join_handle);@@ -983,16 +997,16 @@ impl Message<SetInput> for CameraFeed {let new_frame_recipient = actor_ref.clone().recipient();let native_frame_recipient = actor_ref.clone().recipient();- let (ready, _done_tx, join_handle) = spawn_camera_setup(- msg.id.clone(),+ let (ready, _done_tx, join_handle) = spawn_camera_setup(SpawnCameraSetupArgs {+ id: msg.id.clone(),generation,- msg.settings,+ settings: msg.settings,actor_ref,new_frame_recipient,native_frame_recipient,- self.native_sender_count.clone(),- CameraSetupFlow::Locked,- );+ native_sender_count: self.native_sender_count.clone(),+ flow: CameraSetupFlow::Locked,+ });self.previous_thread = Some(join_handle);diff --git a/crates/recording/src/output_validation.rs b/crates/recording/src/output_validation.rsindex 40c1c17f3..72da56a4d 100644--- a/crates/recording/src/output_validation.rs+++ b/crates/recording/src/output_validation.rs@@ -81,8 +81,7 @@ pub fn validate_instant_recording(issues.push(issue);} else if ratio < 0.9 {let issue = format!(- "Output duration ({:.1}s) is shorter than expected ({:.1}s)",- actual_secs, expected_secs,+ "Output duration ({actual_secs:.1}s) is shorter than expected ({expected_secs:.1}s)");info!("{issue}");issues.push(issue);diff --git a/crates/recording/src/recovery.rs b/crates/recording/src/recovery.rsindex d6f793c3c..37afb1a09 100644--- a/crates/recording/src/recovery.rs+++ b/crates/recording/src/recovery.rs@@ -1103,12 +1103,10 @@ impl RecoveryManager {match probe_video_can_decode(path) {Ok(true) => Ok(()),Ok(false) => Err(RecoveryError::UnplayableVideo(format!(- "{} video has no decodable frames: {path:?}",- label+ "{label} video has no decodable frames: {path:?}"))),Err(e) => Err(RecoveryError::UnplayableVideo(format!(- "{} video validation failed for {path:?}: {e}",- label+ "{label} video validation failed for {path:?}: {e}"))),}}@@ -1124,8 +1122,7 @@ impl RecoveryManager {probe_video_seek_points(path, EXPORT_SEEK_PROBE_SAMPLE_COUNT).map_err(|e| {RecoveryError::UnplayableVideo(format!(- "{} video seek validation failed for {path:?}: {e}",- label+ "{label} video seek validation failed for {path:?}: {e}"))})?;diff --git a/crates/recording/src/sources/microphone.rs b/crates/recording/src/sources/microphone.rsindex 90332aeff..145cb1402 100644--- a/crates/recording/src/sources/microphone.rs+++ b/crates/recording/src/sources/microphone.rs@@ -573,7 +573,8 @@ mod tests {#[test]fn upsampling_preserves_total_duration() {- use cap_timestamp::{MachAbsoluteTimestamp, Timestamp};+ use cap_timestamp::Timestamp;+ use std::time::Instant;let target = AudioInfo::new_raw(Sample::F32(Type::Packed), 48000, 1);let mut resampler =@@ -583,7 +584,7 @@ mod tests {const FRAME_COUNT: usize = 64;const CHANNELS: usize = 2;- let ts = Timestamp::MachAbsoluteTime(MachAbsoluteTimestamp::now());+ let ts = Timestamp::Instant(Instant::now());let payload_len_bytes = FRAME_SAMPLES * CHANNELS * std::mem::size_of::<f32>();let payload = vec![0u8; payload_len_bytes];@@ -608,7 +609,8 @@ mod tests {#[test]fn downsampling_preserves_total_duration() {- use cap_timestamp::{MachAbsoluteTimestamp, Timestamp};+ use cap_timestamp::Timestamp;+ use std::time::Instant;let target = AudioInfo::new_raw(Sample::F32(Type::Packed), 48000, 1);let mut resampler =@@ -618,7 +620,7 @@ mod tests {const FRAME_COUNT: usize = 64;const CHANNELS: usize = 2;- let ts = Timestamp::MachAbsoluteTime(MachAbsoluteTimestamp::now());+ let ts = Timestamp::Instant(Instant::now());let payload_len_bytes = FRAME_SAMPLES * CHANNELS * std::mem::size_of::<f32>();let payload = vec![0u8; payload_len_bytes];