From dcf2befe52c417e8fe687b75ae3ef06a5f3345a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 19 Mar 2020 11:29:32 +0200 Subject: [PATCH] threadshare/inputselector: Send a reconfigure event when the active pad changes --- gst-plugin-threadshare/src/inputselector.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/gst-plugin-threadshare/src/inputselector.rs b/gst-plugin-threadshare/src/inputselector.rs index 2bbc2b27..ca30b06a 100644 --- a/gst-plugin-threadshare/src/inputselector.rs +++ b/gst-plugin-threadshare/src/inputselector.rs @@ -550,14 +550,29 @@ impl ObjectImpl for InputSelector { let pad = value.get::().expect("type checked upstream"); let mut state = self.state.lock().unwrap(); let pads = self.pads.lock().unwrap(); - if let Some(pad) = pad { + let mut old_pad = None; + if let Some(ref pad) = pad { if pads.sink_pads.get(&pad).is_some() { - state.active_sinkpad = Some(pad); + old_pad = state.active_sinkpad.clone(); + state.active_sinkpad = Some(pad.clone()); state.switched_pad = true; } } else { state.active_sinkpad = None; } + + drop(pads); + drop(state); + + if let Some(old_pad) = old_pad { + if Some(&old_pad) != pad.as_ref() { + let _ = old_pad.push_event(gst::Event::new_reconfigure().build()); + } + } + + if let Some(pad) = pad { + let _ = pad.push_event(gst::Event::new_reconfigure().build()); + } } _ => unimplemented!(), }