diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2020-06-22 11:03:52 +0300 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2020-06-22 11:28:19 +0300 |
commit | 9bb3e75fb9f64b531fa5ac60776c4c934b635e47 (patch) | |
tree | 7bd5447060340b6b0e12975734f1f9a94c610caa /text | |
parent | c917e77687f6d7b4de22c5a27bcf48a27982b2cc (diff) |
Update to use the new pad builders for safely setting pad functions
Only two uses of unsafely setting the pad functions is left:
- fallbacksrc for overriding the chain function of the proxy pad of a
ghost pad
- threadshare for overriding the pad functions after creationg, which
probably needs some fixing at some point
Diffstat (limited to 'text')
-rw-r--r-- | text/wrap/src/gsttextwrap.rs | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/text/wrap/src/gsttextwrap.rs b/text/wrap/src/gsttextwrap.rs index 6d9b157bc..a9c851cb7 100644 --- a/text/wrap/src/gsttextwrap.rs +++ b/text/wrap/src/gsttextwrap.rs @@ -127,16 +127,6 @@ struct TextWrap { } impl TextWrap { - fn set_pad_functions(sinkpad: &gst::Pad) { - sinkpad.set_chain_function(|pad, parent, buffer| { - TextWrap::catch_panic_pad_function( - parent, - || Err(gst::FlowError::Error), - |textwrap, element| textwrap.sink_chain(pad, element, buffer), - ) - }); - } - fn update_wrapper(&self, element: &gst::Element) { let settings = self.settings.lock().unwrap(); let mut state = self.state.lock().unwrap(); @@ -279,16 +269,21 @@ impl ObjectSubclass for TextWrap { fn with_class(klass: &subclass::simple::ClassStruct<Self>) -> Self { let templ = klass.get_pad_template("sink").unwrap(); - let sinkpad = gst::Pad::from_template(&templ, Some("sink")); - sinkpad.set_pad_flags(gst::PadFlags::PROXY_CAPS); - let templ = klass.get_pad_template("src").unwrap(); - let srcpad = gst::Pad::from_template(&templ, Some("src")); - srcpad.set_pad_flags(gst::PadFlags::PROXY_CAPS); - - srcpad.use_fixed_caps(); - sinkpad.use_fixed_caps(); + let sinkpad = gst::Pad::builder_with_template(&templ, Some("sink")) + .chain_function(|pad, parent, buffer| { + TextWrap::catch_panic_pad_function( + parent, + || Err(gst::FlowError::Error), + |textwrap, element| textwrap.sink_chain(pad, element, buffer), + ) + }) + .flags(gst::PadFlags::PROXY_CAPS | gst::PadFlags::FIXED_CAPS) + .build(); - TextWrap::set_pad_functions(&sinkpad); + let templ = klass.get_pad_template("src").unwrap(); + let srcpad = gst::Pad::builder_with_template(&templ, Some("src")) + .flags(gst::PadFlags::PROXY_CAPS | gst::PadFlags::FIXED_CAPS) + .build(); let settings = Mutex::new(Settings::default()); let state = Mutex::new(State::default()); |