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 /audio | |
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 'audio')
-rw-r--r-- | audio/audiofx/src/audioloudnorm.rs | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/audio/audiofx/src/audioloudnorm.rs b/audio/audiofx/src/audioloudnorm.rs index 1ea708225..9113111e7 100644 --- a/audio/audiofx/src/audioloudnorm.rs +++ b/audio/audiofx/src/audioloudnorm.rs @@ -1746,34 +1746,35 @@ impl ObjectSubclass for AudioLoudNorm { 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); - - sinkpad.set_chain_function(|pad, parent, buffer| { - Self::catch_panic_pad_function( - parent, - || Err(gst::FlowError::Error), - |this, element| this.sink_chain(pad, element, buffer), - ) - }); - sinkpad.set_event_function(|pad, parent, event| { - Self::catch_panic_pad_function( - parent, - || false, - |this, element| this.sink_event(pad, element, event), - ) - }); + let sinkpad = gst::Pad::builder_with_template(&templ, Some("sink")) + .chain_function(|pad, parent, buffer| { + Self::catch_panic_pad_function( + parent, + || Err(gst::FlowError::Error), + |this, element| this.sink_chain(pad, element, buffer), + ) + }) + .event_function(|pad, parent, event| { + Self::catch_panic_pad_function( + parent, + || false, + |this, element| this.sink_event(pad, element, event), + ) + }) + .flags(gst::PadFlags::PROXY_CAPS) + .build(); - srcpad.set_query_function(|pad, parent, query| { - Self::catch_panic_pad_function( - parent, - || false, - |this, element| this.src_query(pad, element, query), - ) - }); + let templ = klass.get_pad_template("src").unwrap(); + let srcpad = gst::Pad::builder_with_template(&templ, Some("src")) + .query_function(|pad, parent, query| { + Self::catch_panic_pad_function( + parent, + || false, + |this, element| this.src_query(pad, element, query), + ) + }) + .flags(gst::PadFlags::PROXY_CAPS) + .build(); Self { sinkpad, |