mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-12-22 16:16:37 +00:00
Stop using glib::SendUnique
It is being removed because it does not add a lot of value.
This commit is contained in:
parent
7d2ab1450e
commit
8d001d8b16
4 changed files with 13 additions and 30 deletions
|
@ -35,7 +35,7 @@ struct ErrorMessage {
|
|||
}
|
||||
|
||||
struct DrawingContext {
|
||||
layout: glib::SendUniqueCell<LayoutWrapper>,
|
||||
layout: LayoutWrapper,
|
||||
info: Option<gst_video::VideoInfo>,
|
||||
}
|
||||
|
||||
|
@ -46,15 +46,13 @@ impl ops::Deref for LayoutWrapper {
|
|||
type Target = pango::Layout;
|
||||
|
||||
fn deref(&self) -> &pango::Layout {
|
||||
assert_eq!(self.0.ref_count(), 1);
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl glib::SendUnique for LayoutWrapper {
|
||||
fn is_unique(&self) -> bool {
|
||||
self.0.ref_count() == 1
|
||||
}
|
||||
}
|
||||
// SAFETY: We ensure that there are never multiple references to the layout.
|
||||
unsafe impl Send for LayoutWrapper {}
|
||||
|
||||
fn create_pipeline() -> Result<gst::Pipeline, Error> {
|
||||
gst::init()?;
|
||||
|
@ -111,10 +109,7 @@ fn create_pipeline() -> Result<gst::Pipeline, Error> {
|
|||
// interior mutability (see Rust docs). Via this we can get a mutable reference to the contained
|
||||
// data which is checked at runtime for uniqueness (blocking in case of mutex, panic in case
|
||||
// of refcell) instead of compile-time (like with normal references).
|
||||
let drawer = Arc::new(Mutex::new(DrawingContext {
|
||||
layout: glib::SendUniqueCell::new(layout).unwrap(),
|
||||
info: None,
|
||||
}));
|
||||
let drawer = Arc::new(Mutex::new(DrawingContext { layout, info: None }));
|
||||
|
||||
// Connect to the overlaycomposition element's "draw" signal, which is emitted for
|
||||
// each videoframe piped through the element. The signal handler needs to
|
||||
|
@ -140,7 +135,7 @@ fn create_pipeline() -> Result<gst::Pipeline, Error> {
|
|||
let timestamp = buffer.pts().unwrap();
|
||||
|
||||
let info = drawer.info.as_ref().unwrap();
|
||||
let layout = drawer.layout.borrow();
|
||||
let layout = &drawer.layout;
|
||||
|
||||
let angle = 2.0 * PI * (timestamp % (10 * gst::ClockTime::SECOND)).nseconds() as f64
|
||||
/ (10.0 * gst::ClockTime::SECOND.nseconds() as f64);
|
||||
|
|
|
@ -38,7 +38,7 @@ struct ErrorMessage {
|
|||
}
|
||||
|
||||
struct DrawingContext {
|
||||
layout: glib::SendUniqueCell<LayoutWrapper>,
|
||||
layout: LayoutWrapper,
|
||||
info: Option<gst_video::VideoInfo>,
|
||||
}
|
||||
|
||||
|
@ -49,15 +49,13 @@ impl ops::Deref for LayoutWrapper {
|
|||
type Target = pango::Layout;
|
||||
|
||||
fn deref(&self) -> &pango::Layout {
|
||||
assert_eq!(self.0.ref_count(), 1);
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl glib::SendUnique for LayoutWrapper {
|
||||
fn is_unique(&self) -> bool {
|
||||
self.0.ref_count() == 1
|
||||
}
|
||||
}
|
||||
// SAFETY: We ensure that there are never multiple references to the layout.
|
||||
unsafe impl Send for LayoutWrapper {}
|
||||
|
||||
fn create_pipeline() -> Result<gst::Pipeline, Error> {
|
||||
gst::init()?;
|
||||
|
@ -112,10 +110,7 @@ fn create_pipeline() -> Result<gst::Pipeline, Error> {
|
|||
// interior mutability (see Rust docs). Via this we can get a mutable reference to the contained
|
||||
// data which is checked at runtime for uniqueness (blocking in case of mutex, panic in case
|
||||
// of refcell) instead of compile-time (like with normal references).
|
||||
let drawer = Arc::new(Mutex::new(DrawingContext {
|
||||
layout: glib::SendUniqueCell::new(layout).unwrap(),
|
||||
info: None,
|
||||
}));
|
||||
let drawer = Arc::new(Mutex::new(DrawingContext { layout, info: None }));
|
||||
|
||||
let drawer_clone = drawer.clone();
|
||||
// Connect to the cairooverlay element's "draw" signal, which is emitted for
|
||||
|
@ -140,7 +135,7 @@ fn create_pipeline() -> Result<gst::Pipeline, Error> {
|
|||
let _duration = args[3].get::<gst::ClockTime>().unwrap();
|
||||
|
||||
let info = drawer.info.as_ref().unwrap();
|
||||
let layout = drawer.layout.borrow();
|
||||
let layout = &drawer.layout;
|
||||
|
||||
let angle = 2.0 * PI * (timestamp % (10 * gst::ClockTime::SECOND)).nseconds() as f64
|
||||
/ (10.0 * gst::ClockTime::SECOND.nseconds() as f64);
|
||||
|
|
|
@ -138,7 +138,7 @@ status = "generate"
|
|||
name = "GstBase.Adapter"
|
||||
status = "generate"
|
||||
final_type = true
|
||||
concurrency = "send-unique"
|
||||
concurrency = "none"
|
||||
[[object.function]]
|
||||
name = "map"
|
||||
# Unsafe, implemented on `UniqueAdapter`
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
// DO NOT EDIT
|
||||
|
||||
use glib::translate::*;
|
||||
use glib::ObjectExt;
|
||||
use std::mem;
|
||||
|
||||
glib::wrapper! {
|
||||
|
@ -130,9 +129,3 @@ impl Default for Adapter {
|
|||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl glib::SendUnique for Adapter {
|
||||
fn is_unique(&self) -> bool {
|
||||
self.ref_count() == 1
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue