cabana: improve time control (#25985)

* group signals/slots together

* slider:fix wrong minimum

* add TODO

* moveing to mouse click position

* show tickmark

* fix seek back to the old pos after sliderReleased

* reduce data copied in queued connection

* drop packets while seeking

* install event filter in streaming

* stop replay in dctor
old-commit-hash: 750b96aaedb88defd522a60a4bb5fbfeb46332db
This commit is contained in:
Dean Lee
2022-10-07 06:02:22 +08:00
committed by GitHub
parent c18d23c8be
commit 2d9dacacfe
8 changed files with 100 additions and 55 deletions
+2
View File
@@ -325,6 +325,8 @@ void Replay::startStream(const Segment *cur_segment) {
}
void Replay::publishMessage(const Event *e) {
if (event_filter && event_filter(e, filter_opaque)) return;
if (sm == nullptr) {
auto bytes = e->bytes();
int ret = pm->send(sockets_[e->which], (capnp::byte *)bytes.begin(), bytes.size());
+10
View File
@@ -32,6 +32,7 @@ enum class FindFlag {
};
enum class TimelineType { None, Engaged, AlertInfo, AlertWarning, AlertCritical, UserFlag };
typedef bool (*replayEventFilter)(const Event *, void *);
class Replay : public QObject {
Q_OBJECT
@@ -47,6 +48,13 @@ public:
void seekToFlag(FindFlag flag);
void seekTo(double seconds, bool relative);
inline bool isPaused() const { return paused_; }
// the filter is called in streaming thread.try to return quickly from it to avoid blocking streaming.
// the filter function must return true if the event should be filtered.
// otherwise it must return false.
inline void installEventFilter(replayEventFilter filter, void *opaque) {
filter_opaque = opaque;
event_filter = filter;
}
inline bool hasFlag(REPLAY_FLAGS flag) const { return flags_ & flag; }
inline void addFlag(REPLAY_FLAGS flag) { flags_ |= flag; }
inline void removeFlag(REPLAY_FLAGS flag) { flags_ &= ~flag; }
@@ -119,4 +127,6 @@ protected:
std::set<cereal::Event::Which> allow_list;
std::string car_fingerprint_;
float speed_ = 1.0;
replayEventFilter event_filter = nullptr;
void *filter_opaque = nullptr;
};