Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Refactor duration calculation for readability

Richie McIlroya0aeffaaf83f
diff --git a/crates/recording/src/output_pipeline/core.rs b/crates/recording/src/output_pipeline/core.rs
index 56ec9e95a..a3d79c8a6 100644
--- a/crates/recording/src/output_pipeline/core.rs
+++ b/crates/recording/src/output_pipeline/core.rs
@@ -464,7 +464,9 @@ fn spawn_video_encoder<TMutex: VideoMuxer<VideoFrame = TVideo::Frame>, TVideo: V
let _ = first_tx.send(timestamp);
}
- let duration = timestamp.checked_duration_since(timestamps).unwrap_or(Duration::ZERO);
+ let duration = timestamp
+ .checked_duration_since(timestamps)
+ .unwrap_or(Duration::ZERO);
muxer
.lock()
@@ -518,7 +520,10 @@ impl PreparedAudioSources {
let _ = first_tx.send(frame.timestamp);
}
- let timestamp = frame.timestamp.checked_duration_since(timestamps).unwrap_or(Duration::ZERO);
+ let timestamp = frame
+ .timestamp
+ .checked_duration_since(timestamps)
+ .unwrap_or(Duration::ZERO);
if let Err(e) = muxer.lock().await.send_audio_frame(frame, timestamp) {
error!("Audio encoder: {e}");
}
diff --git a/crates/timestamp/src/lib.rs b/crates/timestamp/src/lib.rs
index aafa3dd3e..47b4b1901 100644
--- a/crates/timestamp/src/lib.rs
+++ b/crates/timestamp/src/lib.rs
@@ -37,7 +37,9 @@ impl Timestamp {
Self::Instant(instant) => instant.checked_duration_since(start.instant),
Self::SystemTime(time) => time.duration_since(start.system_time).ok(),
#[cfg(windows)]
- Self::PerformanceCounter(counter) => counter.checked_duration_since(start.performance_counter),
+ Self::PerformanceCounter(counter) => {
+ counter.checked_duration_since(start.performance_counter)
+ }
#[cfg(target_os = "macos")]
Self::MachAbsoluteTime(time) => time.checked_duration_since(start.mach_absolute_time),
}