Add a maximum length to history buffer too

This commit is contained in:
QuantumEntangledAndy committed 2024-04-16 10:14:34 +07:00
1 parent 9480dd8605
commit a19a5f3919
1 file changed
+3 -3
+3 -3
View File
@@ -579,7 +579,7 @@ impl StreamData {
let drop_time = d.ts.saturating_sub(BUFFER_DURATION);
let dts = d.ts;
history.push_back(d);
while history.front().is_some_and(|di| di.ts < drop_time || di.ts > dts) {
while history.front().is_some_and(|di| di.ts < drop_time || di.ts > dts) || history.len() > 1000 {
history.pop_front();
}
log::info!("history: {}", history.len());
@@ -602,7 +602,7 @@ impl StreamData {
let drop_time = d.ts.saturating_sub(BUFFER_DURATION);
let dts = d.ts;
history.push_back(d);
while history.front().is_some_and(|di| di.ts < drop_time || di.ts > dts) {
while history.front().is_some_and(|di| di.ts < drop_time || di.ts > dts) || history.len() > 1000 {
history.pop_front();
}
});
@@ -621,7 +621,7 @@ impl StreamData {
let drop_time = d.ts.saturating_sub(BUFFER_DURATION);
let dts = d.ts;
history.push_back(d);
while history.front().is_some_and(|di| di.ts < drop_time || di.ts > dts) {
while history.front().is_some_and(|di| di.ts < drop_time || di.ts > dts) || history.len() > 1000 {
history.pop_front();
}
});