replay: fix seekTo issue (#29422)

* fix seekTo issue

* remove extra space
pull/29431/head
Dean Lee 2 years ago committed by GitHub
parent f07e4fb49a
commit e8e03197ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      tools/replay/replay.cc
  2. 4
      tools/replay/tests/test_replay.cc

@ -18,7 +18,7 @@ Replay::Replay(QString route, QStringList allow, QStringList block, QStringList
for (const auto &it : services) {
uint16_t which = event_struct.getFieldByName(it.name).getProto().getDiscriminantValue();
if ((which == cereal::Event::Which::UI_DEBUG || which == cereal::Event::Which::USER_FLAG) &&
!(flags & REPLAY_FLAG_ALL_SERVICES) &&
!(flags & REPLAY_FLAG_ALL_SERVICES) &&
!allow.contains(it.name)) {
continue;
}
@ -307,7 +307,8 @@ void Replay::mergeSegments(const SegmentMap::iterator &begin, const SegmentMap::
updateEvents([&]() {
events_.swap(new_events_);
segments_merged_ = segments_need_merge;
return true;
// Do not wake up the stream thread if the current segment has not been merged.
return isSegmentMerged(current_segment_) || (segments_.count(current_segment_) == 0);
});
}
}

@ -147,7 +147,7 @@ TEST_CASE("Route") {
// helper class for unit tests
class TestReplay : public Replay {
public:
TestReplay(const QString &route, uint8_t flags = REPLAY_FLAG_NO_FILE_CACHE) : Replay(route, {}, {}, {}, nullptr, flags) {}
TestReplay(const QString &route, uint32_t flags = REPLAY_FLAG_NO_FILE_CACHE | REPLAY_FLAG_NO_VIPC) : Replay(route, {}, {}, {}, nullptr, flags) {}
void test_seek();
void testSeekTo(int seek_to);
};
@ -191,7 +191,7 @@ void TestReplay::test_seek() {
QEventLoop loop;
std::thread thread = std::thread([&]() {
for (int i = 0; i < 10; ++i) {
testSeekTo(util::random_int(0, 1 * 60));
testSeekTo(util::random_int(0, 2 * 60));
}
loop.quit();
});

Loading…
Cancel
Save