Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix camera + remove screen capture recv timeout

Brendan Allan5814101a756b
diff --git a/crates/recording/src/capture_pipeline.rs b/crates/recording/src/capture_pipeline.rs
index f88768f9e..fc5fffe5f 100644
--- a/crates/recording/src/capture_pipeline.rs
+++ b/crates/recording/src/capture_pipeline.rs
@@ -90,13 +90,13 @@ impl MakeCapturePipeline for cap_media::sources::CMSampleBufferCapture {
let result = loop {
use flume::RecvTimeoutError;
- match source.1.recv_timeout(Duration::from_secs(3)) {
+ match source.1.recv() {
Ok(frame) => {
let _ = screen_encoder.queue_video_frame(frame.0.as_ref());
}
- Err(RecvTimeoutError::Timeout) => {
- break Err("Frame receive timeout".to_string());
- }
+ // Err(RecvTimeoutError::Timeout) => {
+ // break Err("Frame receive timeout".to_string());
+ // }
Err(_) => {
break Ok(());
}
diff --git a/crates/rendering/src/layers/camera.rs b/crates/rendering/src/layers/camera.rs
index 29522a9a9..78795e13b 100644
--- a/crates/rendering/src/layers/camera.rs
+++ b/crates/rendering/src/layers/camera.rs
@@ -16,19 +16,26 @@ pub struct CameraLayer {
impl CameraLayer {
pub fn new(device: &wgpu::Device) -> Self {
let frame_texture = CompositeVideoFramePipeline::create_frame_texture(device, 1920, 1080);
+ let frame_texture_view = frame_texture.create_view(&Default::default());
+
+ let pipeline = CompositeVideoFramePipeline::new(device);
+
+ let uniforms_buffer = device.create_buffer_init(
+ &(wgpu::util::BufferInitDescriptor {
+ label: Some("CameraLayer Uniforms Buffer"),
+ contents: bytemuck::cast_slice(&[CompositeVideoFrameUniforms::default()]),
+ usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,
+ }),
+ );
+
+ let bind_group = Some(pipeline.bind_group(&device, &uniforms_buffer, &frame_texture_view));
Self {
- frame_texture_view: frame_texture.create_view(&Default::default()),
frame_texture,
- uniforms_buffer: device.create_buffer_init(
- &(wgpu::util::BufferInitDescriptor {
- label: Some("CameraLayer Uniforms Buffer"),
- contents: bytemuck::cast_slice(&[CompositeVideoFrameUniforms::default()]),
- usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,
- }),
- ),
- bind_group: None,
- pipeline: CompositeVideoFramePipeline::new(device),
+ frame_texture_view,
+ uniforms_buffer,
+ bind_group,
+ pipeline,
}
}
@@ -81,6 +88,7 @@ impl CameraLayer {
pub fn render(&self, pass: &mut wgpu::RenderPass<'_>) {
if let Some(bind_group) = &self.bind_group {
+ dbg!(bind_group.global_id());
pass.set_pipeline(&self.pipeline.render_pipeline);
pass.set_bind_group(0, bind_group, &[]);
pass.draw(0..4, 0..1);