Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

Commit

Permalink
fix macos
Browse files Browse the repository at this point in the history
  • Loading branch information
liam committed Apr 18, 2024
1 parent a320811 commit 81dfe58
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
16 changes: 8 additions & 8 deletions src/feature/wgpu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,25 @@ pub trait WgpuCaptureConfigExt: Sized {
}

impl WgpuCaptureConfigExt for CaptureConfig {
fn with_wgpu_device(self, device: Arc<dyn AsRef<wgpu::Device> + Send + Sync + 'static>) -> Result<Self, String> {
fn with_wgpu_device(self, wgpu_device: Arc<dyn AsRef<wgpu::Device> + Send + Sync + 'static>) -> Result<Self, String> {
#[cfg(target_os = "macos")]
{
unsafe {
let device = AsRef::as_ref(&*device).as_hal::<wgpu::hal::api::Metal, _, _>(move |device| {
let device = AsRef::as_ref(&*wgpu_device).as_hal::<wgpu::hal::api::Metal, _, _>(move |device| {
if let Some(device) = device {
Some(device.raw_device().lock().clone())
} else {
None
}
}).expect("Expected metal device underneath wgpu");
Self {
}).flatten().expect("Expected metal device underneath wgpu");
Ok(Self {
impl_capture_config: MacosCaptureConfig {
metal_device: device,
wgpu_device:
metal_device: Some(device),
wgpu_device: Some(wgpu_device),
..self.impl_capture_config
},
..self
}
})
}
}
#[cfg(target_os = "windows")]
Expand Down Expand Up @@ -201,7 +201,7 @@ impl WgpuVideoFrameExt for VideoFrame {
metal_texture.mipmap_level_count() as u32,
wgpu::hal::CopyExtent { width: metal_texture.width() as u32, height: metal_texture.height() as u32, depth: metal_texture.depth() as u32 }
);
Ok(wgpu_device.create_texture_from_hal::<wgpu::hal::api::Metal>(wgpu_metal_texture, &descriptor))
Ok((&*wgpu_device).as_ref().create_texture_from_hal::<wgpu::hal::api::Metal>(wgpu_metal_texture, &descriptor))
}
},
Err(MacosVideoFrameError::InvalidVideoPlaneTexture) => Err(WgpuVideoFrameError::InvalidVideoPlaneTexture),
Expand Down
6 changes: 3 additions & 3 deletions src/platform/macos/capture_stream.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{borrow::{Borrow, BorrowMut}, cell::{Cell, RefCell}, sync::{atomic::{self, AtomicBool, AtomicU64}, Arc}, time::{Duration, Instant}};
use std::{borrow::{Borrow, BorrowMut}, cell::{Cell, RefCell}, sync::{atomic::{self, AtomicBool, AtomicU64}, Arc}, time::{Duration, Instant}, fmt::Debug};

use futures::executor::block_on;
use objc::runtime::Object;
Expand Down Expand Up @@ -50,12 +50,12 @@ pub(crate) struct MacosCaptureConfig {
#[cfg(feature = "metal")]
pub(crate) metal_device: Option<metal::Device>,
#[cfg(feature = "wgpu")]
pub(crate) wgpu_device: Option<Arc<dyn AsRef<wgpu::Device>>>,
pub(crate) wgpu_device: Option<Arc<dyn AsRef<wgpu::Device> + Send + Sync + 'static>>,
}

impl Debug for MacosCaptureConfig {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("MacosCaptureConfig").field("scale_to_fit", &self.scale_to_fit).field("maximum_fps", &self.maximum_fps).field("metal_device", &self.metal_device).finish()
f.debug_struct("MacosCaptureConfig").field("scale_to_fit", &self.scale_to_fit).field("maximum_fps", &self.maximum_fps).finish()
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/platform/macos/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub(crate) struct MacosSCStreamVideoFrame {
#[cfg(feature = "metal")]
pub(crate) metal_device: Option<metal::Device>,
#[cfg(feature = "wgpu")]
pub(crate) wgpu_device: Option<Arc<wgpu::Device>>,
pub(crate) wgpu_device: Option<Arc<dyn AsRef<wgpu::Device> + Send + Sync + 'static>>,
}

pub(crate) struct MacosCGDisplayStreamVideoFrame {
Expand All @@ -28,7 +28,7 @@ pub(crate) struct MacosCGDisplayStreamVideoFrame {
#[cfg(feature = "metal")]
pub(crate) metal_device: metal::Device,
#[cfg(feature = "wgpu")]
pub(crate) wgpu_device: Option<Arc<wgpu::Device>>,
pub(crate) wgpu_device: Option<Arc<dyn AsRef<wgpu::Device> + Send + Sync + 'static>>,
}

impl MacosSCStreamVideoFrame {
Expand Down

0 comments on commit 81dfe58

Please sign in to comment.