mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-12-23 10:30:40 +00:00
aws_transcriber: sanity check alternative length
The design of the element is based on the assumption that when receiving a partial result, the following result will contain at least as many items as there were stable items in the previous result. This patch adds a sanity check to make sure our "partial index" isn't larger than the new received result, and errors out otherwise. partial_index will eventually be reset to 0 once we receive a new non-partial result.
This commit is contained in:
parent
3cf2ad3b77
commit
97e6a89cac
1 changed files with 16 additions and 0 deletions
|
@ -379,6 +379,22 @@ impl Transcriber {
|
|||
) {
|
||||
let lateness = self.settings.lock().unwrap().lateness;
|
||||
|
||||
if alternative.items.len() <= state.partial_index {
|
||||
gst_error!(
|
||||
CAT,
|
||||
obj: element,
|
||||
"sanity check failed, alternative length {} < partial_index {}",
|
||||
alternative.items.len(),
|
||||
state.partial_index
|
||||
);
|
||||
|
||||
if !partial {
|
||||
state.partial_index = 0;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
for item in &alternative.items[state.partial_index..] {
|
||||
let start_time =
|
||||
gst::ClockTime::from_nseconds((item.start_time as f64 * 1_000_000_000.0) as u64)
|
||||
|
|
Loading…
Reference in a new issue