Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

handle a couple of errors better

Brendan Allan36dc16df84b8
diff --git a/crates/camera-ffmpeg/src/windows.rs b/crates/camera-ffmpeg/src/windows.rs
index 087de07f4..5b34ea60a 100644
--- a/crates/camera-ffmpeg/src/windows.rs
+++ b/crates/camera-ffmpeg/src/windows.rs
@@ -8,6 +8,8 @@ use crate::CapturedFrameExt;
pub enum AsFFmpegError {
#[error("FailedToGetBytes: {0}")]
FailedToGetBytes(windows_core::Error),
+ #[error("Empty")]
+ Empty,
}
impl CapturedFrameExt for CapturedFrame {
@@ -16,8 +18,16 @@ impl CapturedFrameExt for CapturedFrame {
let width = native.width;
let height = native.height;
+ if width == 0 || height == 0 {
+ return Err(AsFFmpegError::Empty);
+ }
+
let bytes = native.bytes().map_err(AsFFmpegError::FailedToGetBytes)?;
+ if bytes.len() == 0 {
+ return Err(AsFFmpegError::Empty);
+ }
+
Ok(match native.pixel_format {
PixelFormat::YUV420P => {
let mut ff_frame = FFVideo::new(Pixel::YUV420P, width as u32, height as u32);
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index d5291b63a..e03acb64a 100644
--- a/crates/editor/src/editor.rs
+++ b/crates/editor/src/editor.rs
@@ -121,7 +121,7 @@ impl Renderer {
impl RendererHandle {
async fn send(&self, msg: RendererMessage) {
- self.tx.send(msg).await.unwrap();
+ let _ = self.tx.send(msg).await;
}
pub async fn render_frame(