Closed morajabi closed 9 months ago
It is
Send
on my branch:
My bad — let me try again with latest and will post the exact error if I get any.
@yury this is the error I get:
Do you use latest version?
I just double checked with sc-record
example. Everything is good.
cargo r --example sc-record
Is it broken for you too?
Yes I do. In fact, I see this line:
unsafe impl Send for ShareableContent {}
and it works in one situation but not the other.
This one works in a struct:
pub async fn start(&mut self) -> (i32) {
let queue = dispatch::Queue::serial_with_ar_pool();
// display
let content = sc::ShareableContent::current().await.expect("content");
But when I use this function in another crate it doesn't work:
pub async fn get_sharable_contents() -> Vec<SharableItem> {
// display
let content = cidre::sc::ShareableContent::current()
.await
.expect("content");
let primary_id: u32 = cidre::cg::main_display_id().into();
let displays: Vec<SharableItem> = content
.displays()
.iter()
.map(|display| {
let is_primary = display.display_id() == primary_id;
SharableItem {
id: display.display_id().into(),
kind: SharableKind::Display,
title: format!(
"{} ({w}x{h})",
if is_primary {
"Primary Display"
} else {
"Display"
},
w = display.width(),
h = display.height()
),
}
})
.collect();
return displays;
}
probably I'm missing something myself, can't figure it out though.
Interesting...
Could it be that you are using different async runtime (not tokio) in another crate?
I think, it is ns::Error
. Please try latest version
It works! Thank you
Is there a way to have a sync version or add Send to get sharable content? Because I'm getting error of cannot send !Send struct across await points. https://github.com/yury/cidre/blob/main/cidre/src/sc/shareable_content.rs#L113
Other impls I've seen: https://github.com/svtlabs/screencapturekit-rs/blob/main/screencapturekit-sys/src/shareable_content.rs#L175