speechmaticstranscriber: output items as early as possible

There is no reason to delay the output of items until the deadline.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2055>
This commit is contained in:
Mathieu Duponchelle 2025-01-30 15:50:08 +01:00 committed by GStreamer Marge Bot
parent 0ed3f833ac
commit 484275b350

View file

@ -311,35 +311,29 @@ impl TranscriberSrcPad {
let send_eos =
state.send_eos && state.buffers.is_empty() && state.accumulator.is_none();
while let Some(buf) = state.buffers.front() {
if now.saturating_sub(buf.pts().unwrap() + start_time) + granularity > latency {
/* Safe unwrap, we know we have an item */
let mut buf = state.buffers.pop_front().unwrap();
{
let buf_mut = buf.make_mut();
let mut pts = buf_mut.pts().unwrap() + start_time;
let mut duration = buf_mut.duration().unwrap();
if let Some(position) = state.out_segment.position() {
if pts < position {
gst::debug!(
CAT,
imp = self,
"Adjusting item timing({:?} < {:?})",
pts,
position,
);
duration = duration.saturating_sub(position - pts);
pts = position;
}
while let Some(mut buf) = state.buffers.pop_front() {
{
let buf_mut = buf.make_mut();
let mut pts = buf_mut.pts().unwrap() + start_time;
let mut duration = buf_mut.duration().unwrap();
if let Some(position) = state.out_segment.position() {
if pts < position {
gst::debug!(
CAT,
imp = self,
"Adjusting item timing({:?} < {:?})",
pts,
position,
);
duration = duration.saturating_sub(position - pts);
pts = position;
}
buf_mut.set_pts(pts);
buf_mut.set_duration(duration);
}
items.push(buf);
} else {
break;
buf_mut.set_pts(pts);
buf_mut.set_duration(duration);
}
items.push(buf);
}
(