mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-09-01 17:23:48 +00:00
awstranscriber2: Handle multiple stream-start event
Do not spawn new task loop with channel if we have one already.
The same change as 731ceb58bd
for awstranscriber2
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2404>
This commit is contained in:
parent
47a3d4a37f
commit
00b7ebab48
1 changed files with 16 additions and 1 deletions
|
@ -92,6 +92,7 @@ struct State {
|
|||
receive_handle: Option<tokio::task::JoinHandle<()>>,
|
||||
partial_index: usize,
|
||||
seqnum: gst::Seqnum,
|
||||
task_started: bool,
|
||||
}
|
||||
|
||||
impl Default for State {
|
||||
|
@ -109,6 +110,7 @@ impl Default for State {
|
|||
receive_handle: None,
|
||||
partial_index: 0,
|
||||
seqnum: gst::Seqnum::next(),
|
||||
task_started: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -391,6 +393,11 @@ impl Transcriber {
|
|||
}
|
||||
|
||||
fn start_srcpad_task(&self) -> Result<(), gst::LoggableError> {
|
||||
if self.state.lock().unwrap().task_started {
|
||||
gst::debug!(CAT, imp = self, "Task started already");
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
gst::debug!(CAT, imp = self, "starting source pad task");
|
||||
|
||||
self.ensure_connection()
|
||||
|
@ -489,6 +496,8 @@ impl Transcriber {
|
|||
return Err(gst::loggable_error!(CAT, "Failed to start pad task"));
|
||||
}
|
||||
|
||||
self.state.lock().unwrap().task_started = true;
|
||||
|
||||
gst::debug!(CAT, imp = self, "started source pad task");
|
||||
|
||||
Ok(())
|
||||
|
@ -817,6 +826,8 @@ impl Transcriber {
|
|||
handle.abort();
|
||||
}
|
||||
|
||||
let mut task_started = state.task_started;
|
||||
|
||||
// Make sure the task is fully stopped before resetting the state,
|
||||
// in order not to break expectations such as in_segment being
|
||||
// present while the task is still processing items
|
||||
|
@ -824,9 +835,13 @@ impl Transcriber {
|
|||
drop(state);
|
||||
let _ = self.srcpad.stop_task();
|
||||
state = self.state.lock().unwrap();
|
||||
task_started = false;
|
||||
}
|
||||
|
||||
*state = State::default();
|
||||
*state = State {
|
||||
task_started,
|
||||
..Default::default()
|
||||
};
|
||||
}
|
||||
|
||||
fn src_query(&self, pad: &gst::Pad, query: &mut gst::QueryRef) -> bool {
|
||||
|
|
Loading…
Reference in a new issue