From 09a9877f40a49dae222390b22ee233d938df6663 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Wed, 8 Mar 2023 14:07:05 +0100 Subject: [PATCH] uriplaylistbin: reset element when switching back to NULL Allow us to re-use the element later. Part-of: --- .../uriplaylistbin/src/uriplaylistbin/imp.rs | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/utils/uriplaylistbin/src/uriplaylistbin/imp.rs b/utils/uriplaylistbin/src/uriplaylistbin/imp.rs index 3b6ae3ec..a088b554 100644 --- a/utils/uriplaylistbin/src/uriplaylistbin/imp.rs +++ b/utils/uriplaylistbin/src/uriplaylistbin/imp.rs @@ -962,7 +962,13 @@ impl ElementImpl for UriPlaylistBin { } } - self.parent_change_state(transition) + let res = self.parent_change_state(transition); + + if transition == gst::StateChange::ReadyToNull { + self.stop(); + } + + res } } @@ -1684,6 +1690,20 @@ impl UriPlaylistBin { } } } + + fn stop(&self) { + // remove all children and pads + let children = self.obj().children(); + let children_ref = children.iter().collect::>(); + self.obj().remove_many(&children_ref).unwrap(); + + for pad in self.obj().src_pads() { + self.obj().remove_pad(&pad).unwrap(); + } + + let mut state_guard = self.state.lock().unwrap(); + *state_guard = None; + } } #[derive(Default, Clone, Debug)]