forked from mirrors/gstreamer-rs
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 {
|
struct DrawingContext {
|
||||||
layout: glib::SendUniqueCell<LayoutWrapper>,
|
layout: LayoutWrapper,
|
||||||
info: Option<gst_video::VideoInfo>,
|
info: Option<gst_video::VideoInfo>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,15 +46,13 @@ impl ops::Deref for LayoutWrapper {
|
||||||
type Target = pango::Layout;
|
type Target = pango::Layout;
|
||||||
|
|
||||||
fn deref(&self) -> &pango::Layout {
|
fn deref(&self) -> &pango::Layout {
|
||||||
|
assert_eq!(self.0.ref_count(), 1);
|
||||||
&self.0
|
&self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl glib::SendUnique for LayoutWrapper {
|
// SAFETY: We ensure that there are never multiple references to the layout.
|
||||||
fn is_unique(&self) -> bool {
|
unsafe impl Send for LayoutWrapper {}
|
||||||
self.0.ref_count() == 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn create_pipeline() -> Result<gst::Pipeline, Error> {
|
fn create_pipeline() -> Result<gst::Pipeline, Error> {
|
||||||
gst::init()?;
|
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
|
// 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
|
// 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).
|
// of refcell) instead of compile-time (like with normal references).
|
||||||
let drawer = Arc::new(Mutex::new(DrawingContext {
|
let drawer = Arc::new(Mutex::new(DrawingContext { layout, info: None }));
|
||||||
layout: glib::SendUniqueCell::new(layout).unwrap(),
|
|
||||||
info: None,
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Connect to the overlaycomposition element's "draw" signal, which is emitted for
|
// Connect to the overlaycomposition element's "draw" signal, which is emitted for
|
||||||
// each videoframe piped through the element. The signal handler needs to
|
// 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 timestamp = buffer.pts().unwrap();
|
||||||
|
|
||||||
let info = drawer.info.as_ref().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
|
let angle = 2.0 * PI * (timestamp % (10 * gst::ClockTime::SECOND)).nseconds() as f64
|
||||||
/ (10.0 * gst::ClockTime::SECOND.nseconds() as f64);
|
/ (10.0 * gst::ClockTime::SECOND.nseconds() as f64);
|
||||||
|
|
|
@ -38,7 +38,7 @@ struct ErrorMessage {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct DrawingContext {
|
struct DrawingContext {
|
||||||
layout: glib::SendUniqueCell<LayoutWrapper>,
|
layout: LayoutWrapper,
|
||||||
info: Option<gst_video::VideoInfo>,
|
info: Option<gst_video::VideoInfo>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,15 +49,13 @@ impl ops::Deref for LayoutWrapper {
|
||||||
type Target = pango::Layout;
|
type Target = pango::Layout;
|
||||||
|
|
||||||
fn deref(&self) -> &pango::Layout {
|
fn deref(&self) -> &pango::Layout {
|
||||||
|
assert_eq!(self.0.ref_count(), 1);
|
||||||
&self.0
|
&self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl glib::SendUnique for LayoutWrapper {
|
// SAFETY: We ensure that there are never multiple references to the layout.
|
||||||
fn is_unique(&self) -> bool {
|
unsafe impl Send for LayoutWrapper {}
|
||||||
self.0.ref_count() == 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn create_pipeline() -> Result<gst::Pipeline, Error> {
|
fn create_pipeline() -> Result<gst::Pipeline, Error> {
|
||||||
gst::init()?;
|
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
|
// 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
|
// 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).
|
// of refcell) instead of compile-time (like with normal references).
|
||||||
let drawer = Arc::new(Mutex::new(DrawingContext {
|
let drawer = Arc::new(Mutex::new(DrawingContext { layout, info: None }));
|
||||||
layout: glib::SendUniqueCell::new(layout).unwrap(),
|
|
||||||
info: None,
|
|
||||||
}));
|
|
||||||
|
|
||||||
let drawer_clone = drawer.clone();
|
let drawer_clone = drawer.clone();
|
||||||
// Connect to the cairooverlay element's "draw" signal, which is emitted for
|
// 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 _duration = args[3].get::<gst::ClockTime>().unwrap();
|
||||||
|
|
||||||
let info = drawer.info.as_ref().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
|
let angle = 2.0 * PI * (timestamp % (10 * gst::ClockTime::SECOND)).nseconds() as f64
|
||||||
/ (10.0 * gst::ClockTime::SECOND.nseconds() as f64);
|
/ (10.0 * gst::ClockTime::SECOND.nseconds() as f64);
|
||||||
|
|
|
@ -138,7 +138,7 @@ status = "generate"
|
||||||
name = "GstBase.Adapter"
|
name = "GstBase.Adapter"
|
||||||
status = "generate"
|
status = "generate"
|
||||||
final_type = true
|
final_type = true
|
||||||
concurrency = "send-unique"
|
concurrency = "none"
|
||||||
[[object.function]]
|
[[object.function]]
|
||||||
name = "map"
|
name = "map"
|
||||||
# Unsafe, implemented on `UniqueAdapter`
|
# Unsafe, implemented on `UniqueAdapter`
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
// DO NOT EDIT
|
// DO NOT EDIT
|
||||||
|
|
||||||
use glib::translate::*;
|
use glib::translate::*;
|
||||||
use glib::ObjectExt;
|
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
glib::wrapper! {
|
glib::wrapper! {
|
||||||
|
@ -130,9 +129,3 @@ impl Default for Adapter {
|
||||||
Self::new()
|
Self::new()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl glib::SendUnique for Adapter {
|
|
||||||
fn is_unique(&self) -> bool {
|
|
||||||
self.ref_count() == 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue