flow_combiner: Add a UniqueFlowCombiner wrapper

This implements Send/Sync and for allowing this safely it provides no
reference counting and requires a mutable reference for all mutable
operations.
This commit is contained in:
Sebastian Dröge 2019-01-03 11:11:48 +02:00
parent 6ed4f95ad0
commit 90c86e0031

View file

@ -13,6 +13,7 @@ use gobject_ffi;
use gst; use gst;
glib_wrapper! { glib_wrapper! {
#[derive(Debug)]
pub struct FlowCombiner(Shared<ffi::GstFlowCombiner>); pub struct FlowCombiner(Shared<ffi::GstFlowCombiner>);
match fn { match fn {
@ -85,3 +86,49 @@ impl Default for FlowCombiner {
Self::new() Self::new()
} }
} }
#[derive(Debug)]
pub struct UniqueFlowCombiner(FlowCombiner);
unsafe impl Sync for UniqueFlowCombiner {}
unsafe impl Send for UniqueFlowCombiner {}
impl UniqueFlowCombiner {
pub fn new() -> UniqueFlowCombiner {
UniqueFlowCombiner(FlowCombiner::new())
}
pub fn add_pad<P: IsA<gst::Pad>>(&mut self, pad: &P) {
self.0.add_pad(pad);
}
pub fn clear(&self) {
self.0.clear();
}
pub fn remove_pad<P: IsA<gst::Pad>>(&mut self, pad: &P) {
self.0.remove_pad(pad);
}
pub fn reset(&mut self) {
self.0.reset();
}
pub fn update_flow(&mut self, fret: gst::FlowReturn) -> gst::FlowReturn {
self.0.update_flow(fret)
}
pub fn update_pad_flow<P: IsA<gst::Pad>>(
&mut self,
pad: &P,
fret: gst::FlowReturn,
) -> gst::FlowReturn {
self.0.update_pad_flow(pad, fret)
}
}
impl Default for UniqueFlowCombiner {
fn default() -> Self {
Self::new()
}
}