cabana: stable FPS (#26120)

* stable FPS

* fix
old-commit-hash: 686506f4003964e230550e100d6a841c2ff5d3ac
This commit is contained in:
Dean Lee
2022-10-25 02:46:07 +08:00
committed by GitHub
parent 9fbaafa38f
commit bc7b437266
+4 -3
View File
@@ -87,7 +87,7 @@ void CANMessages::process(QHash<QString, std::deque<CanData>> *messages) {
}
bool CANMessages::eventFilter(const Event *event) {
static double prev_update_sec = 0;
static double prev_update_ts = 0;
// drop packets when the GUI thread is calling seekTo. to make sure the current_sec is accurate.
if (!seeking && event->which == cereal::Event::Which::CAN) {
if (!received_msgs) {
@@ -121,8 +121,9 @@ bool CANMessages::eventFilter(const Event *event) {
}
}
if (current_sec < prev_update_sec || (current_sec - prev_update_sec) > 1.0 / settings.fps) {
prev_update_sec = current_sec;
double ts = millis_since_boot();
if ((ts - prev_update_ts) > (1000.0 / settings.fps)) {
prev_update_ts = ts;
// use pointer to avoid data copy in queued connection.
emit received(received_msgs.release());
}