Skip to content

Commit

Permalink
fix: Fix use_camera
Browse files Browse the repository at this point in the history
  • Loading branch information
marc2332 committed Aug 6, 2023
1 parent c9cc59e commit 03e6566
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion hooks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ euclid = { workspace = true }
uuid = { workspace = true }
tween = "2.0.0"
ropey = "1.6.0"
nokhwa = { version = "0.10.3", features = ["input-native"], optional = true }
nokhwa = { version = "0.10.4", features = ["input-native"], optional = true }
bytes = "1.3.0"

[dev-dependencies]
Expand Down
5 changes: 3 additions & 2 deletions hooks/src/use_camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use freya_common::EventMessage;
use freya_node_state::{CustomAttributeValues, ImageReference};
use nokhwa::{pixel_format::RgbFormat, utils::RequestedFormat, Camera, NokhwaError};
use tokio::time::sleep;
use crate::use_platform;

pub use nokhwa::utils::{CameraIndex, RequestedFormatType, Resolution};

Expand Down Expand Up @@ -62,7 +63,7 @@ pub fn use_camera(
cx: &ScopeState,
camera_settings: CameraSettings,
) -> (AttributeValue, &UseState<Option<NokhwaError>>) {
let platform = use_platform();
let platform = use_platform(cx);
let camera_error = use_state(cx, || None);
let image_reference = cx.use_hook(|| Arc::new(Mutex::new(None)));

Expand Down Expand Up @@ -102,7 +103,7 @@ pub fn use_camera(
// Send the frame to the renderer via the image reference
image_reference.lock().unwrap().replace(bts);

// Request the renderer to relayout
// Request the renderer to rerender
platform.send(EventMessage::RequestRerender).unwrap();
} else if let Err(err) = frame {
handle_error(err);
Expand Down

0 comments on commit 03e6566

Please sign in to comment.