From 90c86e00319e79b8bdfc32870fb70025e7920395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 3 Jan 2019 11:11:48 +0200 Subject: [PATCH] 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. --- gstreamer-base/src/flow_combiner.rs | 47 +++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/gstreamer-base/src/flow_combiner.rs b/gstreamer-base/src/flow_combiner.rs index e833a1c02..3ea5828fb 100644 --- a/gstreamer-base/src/flow_combiner.rs +++ b/gstreamer-base/src/flow_combiner.rs @@ -13,6 +13,7 @@ use gobject_ffi; use gst; glib_wrapper! { + #[derive(Debug)] pub struct FlowCombiner(Shared); match fn { @@ -85,3 +86,49 @@ impl Default for FlowCombiner { 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>(&mut self, pad: &P) { + self.0.add_pad(pad); + } + + pub fn clear(&self) { + self.0.clear(); + } + + pub fn remove_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>( + &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() + } +}