diff options
author | Guillaume Desmottes <guillaume.desmottes@onestream.live> | 2023-01-02 14:02:51 +0300 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@onestream.live> | 2023-01-02 14:04:09 +0300 |
commit | f59d00b8e6824f8b4a4565f82ce196b03dd8dbf1 (patch) | |
tree | 48566267fe64ba076a25225c3902e1dde67a1c76 /text | |
parent | 439ada614c05e1f18ca249d82598c3f5e6a918fa (diff) |
textahead: fix previous buffers
Actually implement a proper queue.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1033>
Diffstat (limited to 'text')
-rw-r--r-- | text/ahead/src/textahead/imp.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/text/ahead/src/textahead/imp.rs b/text/ahead/src/textahead/imp.rs index 82dc1f1b4..6af01de99 100644 --- a/text/ahead/src/textahead/imp.rs +++ b/text/ahead/src/textahead/imp.rs @@ -6,6 +6,7 @@ // // SPDX-License-Identifier: MPL-2.0 +use std::collections::VecDeque; use std::sync::{Mutex, MutexGuard}; use once_cell::sync::Lazy; @@ -54,7 +55,7 @@ struct Input { #[derive(Default)] struct State { - previous: Vec<Input>, + previous: VecDeque<Input>, pending: Vec<Input>, done: bool, /// Segment for which we should send a buffer with ahead text. Only set if `Settings.buffer_start_segment` is set. @@ -425,10 +426,10 @@ impl TextAhead { let duration = current.duration; if settings.n_previous > 0 { - state.previous.push(current); + state.previous.push_back(current); if state.previous.len() > settings.n_previous as usize { - state.previous.pop(); + state.previous.pop_front(); } } |