From 5d83d27798d7e8acaa4ec123fbd74e7c5ab9d049 Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Tue, 25 Feb 2025 16:29:37 +0100 Subject: [PATCH] speechmatics: fix state cycling The static source pad is added to the dynamic srcpads collection for convenience, so when the state transitions back to NULL and state is reset to its default, we need to make sure to re-add the static source pad to the collection. Part-of: --- audio/speechmatics/src/transcriber/imp.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/audio/speechmatics/src/transcriber/imp.rs b/audio/speechmatics/src/transcriber/imp.rs index e5724b635..8db1aa30c 100644 --- a/audio/speechmatics/src/transcriber/imp.rs +++ b/audio/speechmatics/src/transcriber/imp.rs @@ -1534,8 +1534,19 @@ impl Transcriber { }); } + let srcpads = state.srcpads.clone(); + *state = State::default(); + for srcpad in &srcpads { + let mut sstate = srcpad.imp().state.lock().unwrap(); + let unsynced_pad = sstate.unsynced_pad.take(); + *sstate = TranscriberSrcPadState::default(); + sstate.unsynced_pad = unsynced_pad; + } + + state.srcpads = srcpads; + gst::info!( CAT, imp = self, @@ -1551,6 +1562,10 @@ impl Transcriber { let mut state = self.state.lock().unwrap(); + if !state.connected { + return None; + } + if state.start_time.is_none() { state.start_time = Some(now); for pad in state.srcpads.iter() {