textaccumulate: add mechanism for recalculating timeout ..

.. when queue fills again

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2528>
This commit is contained in:
Mathieu Duponchelle 2025-08-29 22:15:35 +02:00
parent 22168549fa
commit ebc943e54c

View file

@ -217,6 +217,7 @@ enum AccumulateInput {
},
Event(gst::Event),
Query(std::ptr::NonNull<gst::QueryRef>),
RecalculateTimeout,
}
// SAFETY: Need to be able to pass *mut gst::QueryRef
@ -740,6 +741,9 @@ impl Accumulate {
this.state.lock().unwrap().serialized_query_return = Some(res);
this.serialized_query_cond.notify_all();
}
AccumulateInput::RecalculateTimeout => {
continue;
}
}
}
Err(RecvTimeoutError::Timeout) => {
@ -847,6 +851,19 @@ impl Accumulate {
}
}
// The queue was empty and has started filling up again, recalculate timeout
if state
.input
.as_ref()
.map(|input| input.items.len())
.unwrap_or(0)
== 1
{
if let Some(tx) = state.accumulate_tx.as_ref() {
let _ = tx.send(AccumulateInput::RecalculateTimeout);
}
}
gst::trace!(CAT, imp = self, "input is now {:#?}", state.input);
Ok(gst::FlowSuccess::Ok)