mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-23 03:50:59 +00:00
threadshare: Pad{Src,Sink}::unprepare: release all functions
This commit is contained in:
parent
e729324cce
commit
4c584fd162
1 changed files with 41 additions and 29 deletions
|
@ -491,21 +491,8 @@ pub struct PadSrc(PadSrcStrong);
|
|||
|
||||
impl PadSrc {
|
||||
pub fn new(gst_pad: gst::Pad) -> Self {
|
||||
let pad = gst_pad.clone();
|
||||
let this = PadSrc(PadSrcStrong::new(gst_pad));
|
||||
|
||||
let this_weak = this.downgrade();
|
||||
pad.set_activatemode_function(move |gst_pad, _parent, mode, active| {
|
||||
// Important: don't panic here as we operate without `catch_panic_pad_function`
|
||||
// because we may not know which element the PadSrc is associated to yet
|
||||
this_weak
|
||||
.upgrade()
|
||||
.ok_or_else(|| {
|
||||
gst_error!(RUNTIME_CAT, obj: gst_pad, "PadSrc no longer exists");
|
||||
gst_loggable_error!(RUNTIME_CAT, "PadSrc no longer exists")
|
||||
})?
|
||||
.activate_mode_hook(mode, active)
|
||||
});
|
||||
this.set_default_activatemode_function();
|
||||
|
||||
this
|
||||
}
|
||||
|
@ -530,6 +517,22 @@ impl PadSrc {
|
|||
self.gst_pad().check_reconfigure()
|
||||
}
|
||||
|
||||
fn set_default_activatemode_function(&self) {
|
||||
let this_weak = self.downgrade();
|
||||
self.gst_pad()
|
||||
.set_activatemode_function(move |gst_pad, _parent, mode, active| {
|
||||
// Important: don't panic here as we operate without `catch_panic_pad_function`
|
||||
// because we may not know which element the PadSrc is associated to yet
|
||||
this_weak
|
||||
.upgrade()
|
||||
.ok_or_else(|| {
|
||||
gst_error!(RUNTIME_CAT, obj: gst_pad, "PadSrc no longer exists");
|
||||
gst_loggable_error!(RUNTIME_CAT, "PadSrc no longer exists")
|
||||
})?
|
||||
.activate_mode_hook(mode, active)
|
||||
});
|
||||
}
|
||||
|
||||
///// Spawns `future` using current [`PadContext`].
|
||||
/////
|
||||
///// # Panics
|
||||
|
@ -675,9 +678,10 @@ impl PadSrc {
|
|||
.map_err(|_| PadContextError::ActiveTask)?;
|
||||
|
||||
self.gst_pad()
|
||||
.set_activatemode_function(move |_gst_pad, _parent, _mode, _active| {
|
||||
.set_activate_function(move |_gst_pad, _parent| {
|
||||
Err(gst_loggable_error!(RUNTIME_CAT, "PadSrc unprepared"))
|
||||
});
|
||||
self.set_default_activatemode_function();
|
||||
self.gst_pad()
|
||||
.set_event_function(move |_gst_pad, _parent, _event| false);
|
||||
self.gst_pad()
|
||||
|
@ -1013,21 +1017,8 @@ pub struct PadSink(PadSinkStrong);
|
|||
|
||||
impl PadSink {
|
||||
pub fn new(gst_pad: gst::Pad) -> Self {
|
||||
let pad = gst_pad.clone();
|
||||
let this = PadSink(PadSinkStrong::new(gst_pad));
|
||||
|
||||
let this_weak = this.downgrade();
|
||||
pad.set_activatemode_function(move |gst_pad, _parent, mode, active| {
|
||||
// Important: don't panic here as we operate without `catch_panic_pad_function`
|
||||
// because we may not know which element the PadSrc is associated to yet
|
||||
this_weak
|
||||
.upgrade()
|
||||
.ok_or_else(|| {
|
||||
gst_error!(RUNTIME_CAT, obj: gst_pad, "PadSink no longer exists");
|
||||
gst_loggable_error!(RUNTIME_CAT, "PadSink no longer exists")
|
||||
})?
|
||||
.activate_mode_hook(mode, active)
|
||||
});
|
||||
this.set_default_activatemode_function();
|
||||
|
||||
this
|
||||
}
|
||||
|
@ -1044,6 +1035,22 @@ impl PadSink {
|
|||
self.0.downgrade()
|
||||
}
|
||||
|
||||
fn set_default_activatemode_function(&self) {
|
||||
let this_weak = self.downgrade();
|
||||
self.gst_pad()
|
||||
.set_activatemode_function(move |gst_pad, _parent, mode, active| {
|
||||
// Important: don't panic here as we operate without `catch_panic_pad_function`
|
||||
// because we may not know which element the PadSrc is associated to yet
|
||||
this_weak
|
||||
.upgrade()
|
||||
.ok_or_else(|| {
|
||||
gst_error!(RUNTIME_CAT, obj: gst_pad, "PadSink no longer exists");
|
||||
gst_loggable_error!(RUNTIME_CAT, "PadSink no longer exists")
|
||||
})?
|
||||
.activate_mode_hook(mode, active)
|
||||
});
|
||||
}
|
||||
|
||||
fn init_pad_functions<H: PadSinkHandler>(&self, handler: &H) {
|
||||
let handler_clone = handler.clone();
|
||||
let this_weak = self.downgrade();
|
||||
|
@ -1234,6 +1241,11 @@ impl PadSink {
|
|||
pub fn unprepare(&self) {
|
||||
gst_log!(RUNTIME_CAT, obj: self.gst_pad(), "Unpreparing");
|
||||
|
||||
self.gst_pad()
|
||||
.set_activate_function(move |_gst_pad, _parent| {
|
||||
Err(gst_loggable_error!(RUNTIME_CAT, "PadSink unprepared"))
|
||||
});
|
||||
self.set_default_activatemode_function();
|
||||
self.gst_pad()
|
||||
.set_chain_function(move |_gst_pad, _parent, _buffer| Err(FlowError::Flushing));
|
||||
self.gst_pad()
|
||||
|
|
Loading…
Reference in a new issue