diff --git a/gstreamer-video/Cargo.toml b/gstreamer-video/Cargo.toml index 28e52dfb6..7dfdbf6bc 100644 --- a/gstreamer-video/Cargo.toml +++ b/gstreamer-video/Cargo.toml @@ -23,7 +23,6 @@ gst = { package = "gstreamer", path = "../gstreamer" } gst-base = { package = "gstreamer-base", path = "../gstreamer-base" } once_cell = "1.0" futures-channel = "0.3" -fragile = "1" serde = { version = "1.0", optional = true, features = ["derive"] } [dev-dependencies] diff --git a/gstreamer-video/src/functions.rs b/gstreamer-video/src/functions.rs index a9293f0a3..cf516d44e 100644 --- a/gstreamer-video/src/functions.rs +++ b/gstreamer-video/src/functions.rs @@ -58,7 +58,7 @@ pub fn convert_sample_async_local( .acquire() .expect("thread default main context already acquired by another thread"); - let func = fragile::Fragile::new(func); + let func = glib::thread_guard::ThreadGuard::new(func); convert_sample_async_unsafe(sample, caps, timeout, move |res| (func.into_inner())(res)) } diff --git a/gstreamer/Cargo.toml b/gstreamer/Cargo.toml index 2c31ce48e..c1fb846e7 100644 --- a/gstreamer/Cargo.toml +++ b/gstreamer/Cargo.toml @@ -32,7 +32,6 @@ serde_bytes = { version = "0.11", optional = true } paste = "1.0" pretty-hex = "0.2" thiserror = "1" -fragile = "1" [dev-dependencies] ron = "0.7" diff --git a/gstreamer/src/bus.rs b/gstreamer/src/bus.rs index daa00725b..579eb9c0c 100644 --- a/gstreamer/src/bus.rs +++ b/gstreamer/src/bus.rs @@ -13,8 +13,6 @@ use std::mem::transmute; use std::pin::Pin; use std::task::{Context, Poll}; -use fragile::Fragile; - use crate::Bus; use crate::BusSyncReply; use crate::Message; @@ -48,20 +46,22 @@ unsafe extern "C" fn trampoline_watch_local Continue msg: *mut ffi::GstMessage, func: gpointer, ) -> gboolean { - let func: &Fragile> = &*(func as *const Fragile>); - (&mut *func.get().borrow_mut())(&from_glib_borrow(bus), &Message::from_glib_borrow(msg)) + let func: &glib::thread_guard::ThreadGuard> = + &*(func as *const glib::thread_guard::ThreadGuard>); + (&mut *func.get_ref().borrow_mut())(&from_glib_borrow(bus), &Message::from_glib_borrow(msg)) .into_glib() } unsafe extern "C" fn destroy_closure_watch_local Continue + 'static>( ptr: gpointer, ) { - Box::>>::from_raw(ptr as *mut _); + Box::>>::from_raw(ptr as *mut _); } fn into_raw_watch_local Continue + 'static>(func: F) -> gpointer { #[allow(clippy::type_complexity)] - let func: Box>> = Box::new(Fragile::new(RefCell::new(func))); + let func: Box>> = + Box::new(glib::thread_guard::ThreadGuard::new(RefCell::new(func))); Box::into_raw(func) as gpointer }