diff --git a/selfdrive/ui/qt/onroad/onroad_home.cc b/selfdrive/ui/qt/onroad/onroad_home.cc index a627df9928..f7df0431c6 100644 --- a/selfdrive/ui/qt/onroad/onroad_home.cc +++ b/selfdrive/ui/qt/onroad/onroad_home.cc @@ -6,6 +6,8 @@ #include "selfdrive/ui/qt/util.h" OnroadWindow::OnroadWindow(QWidget *parent) : QWidget(parent) { + qRegisterMetaType>("std::shared_ptr"); + QVBoxLayout *main_layout = new QVBoxLayout(this); main_layout->setMargin(UI_BORDER_SIZE); QStackedLayout *stacked_layout = new QStackedLayout; @@ -44,8 +46,6 @@ void OnroadWindow::updateState(const UIState &s) { return; } - emit drewOnroadFrame(new QImage(grab().toImage())); - alerts->updateState(s); nvg->updateState(s); @@ -55,6 +55,8 @@ void OnroadWindow::updateState(const UIState &s) { bg = bgColor; update(); } + + emit drewOnroadFrame(std::make_shared(std::move(grab()))); } void OnroadWindow::offroadTransition(bool offroad) { diff --git a/selfdrive/ui/qt/onroad/onroad_home.h b/selfdrive/ui/qt/onroad/onroad_home.h index 46c32e33a7..86c33aaa2f 100644 --- a/selfdrive/ui/qt/onroad/onroad_home.h +++ b/selfdrive/ui/qt/onroad/onroad_home.h @@ -10,7 +10,7 @@ public: OnroadWindow(QWidget* parent = 0); signals: - void drewOnroadFrame(QImage *frame); + void drewOnroadFrame(const std::shared_ptr &frame); private: void paintEvent(QPaintEvent *event); diff --git a/tools/clip/application.cc b/tools/clip/application.cc index 12d5fd6743..5d1fbfc53c 100644 --- a/tools/clip/application.cc +++ b/tools/clip/application.cc @@ -46,7 +46,8 @@ void Application::initReplay() { std::vector allow; std::vector block; replay = std::make_unique("a2a0ccea32023010|2023-07-27--13-01-19", allow, block, nullptr, - REPLAY_FLAG_NONE & REPLAY_FLAG_ECAM & REPLAY_FLAG_DCAM); + REPLAY_FLAG_NONE); + replay->setSegmentCacheLimit(10); } void Application::startReplay() { diff --git a/tools/clip/recorder/moc_widget.cc b/tools/clip/recorder/moc_widget.cc index 09b38588b0..2ef0fa6f73 100644 --- a/tools/clip/recorder/moc_widget.cc +++ b/tools/clip/recorder/moc_widget.cc @@ -22,8 +22,8 @@ QT_BEGIN_MOC_NAMESPACE QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED struct qt_meta_stringdata_Recorder_t { - QByteArrayData data[6]; - char stringdata0[39]; + QByteArrayData data[5]; + char stringdata0[51]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ @@ -35,13 +35,12 @@ static const qt_meta_stringdata_Recorder_t qt_meta_stringdata_Recorder = { QT_MOC_LITERAL(0, 0, 8), // "Recorder" QT_MOC_LITERAL(1, 9, 9), // "saveFrame" QT_MOC_LITERAL(2, 19, 0), // "" -QT_MOC_LITERAL(3, 20, 7), // "QImage*" -QT_MOC_LITERAL(4, 28, 5), // "frame" -QT_MOC_LITERAL(5, 34, 4) // "stop" +QT_MOC_LITERAL(3, 20, 24), // "std::shared_ptr" +QT_MOC_LITERAL(4, 45, 5) // "frame" }, - "Recorder\0saveFrame\0\0QImage*\0frame\0" - "stop" + "Recorder\0saveFrame\0\0std::shared_ptr\0" + "frame" }; #undef QT_MOC_LITERAL @@ -51,7 +50,7 @@ static const uint qt_meta_data_Recorder[] = { 8, // revision 0, // classname 0, 0, // classinfo - 2, 14, // methods + 1, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors @@ -59,12 +58,10 @@ static const uint qt_meta_data_Recorder[] = { 0, // signalCount // slots: name, argc, parameters, tag, flags - 1, 1, 24, 2, 0x0a /* Public */, - 5, 0, 27, 2, 0x0a /* Public */, + 1, 1, 19, 2, 0x0a /* Public */, // slots: parameters QMetaType::Void, 0x80000000 | 3, 4, - QMetaType::Void, 0 // eod }; @@ -75,8 +72,7 @@ void Recorder::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, vo auto *_t = static_cast(_o); (void)_t; switch (_id) { - case 0: _t->saveFrame((*reinterpret_cast< QImage*(*)>(_a[1]))); break; - case 1: _t->stop(); break; + case 0: _t->saveFrame((*reinterpret_cast< const std::shared_ptr(*)>(_a[1]))); break; default: ; } } @@ -111,13 +107,13 @@ int Recorder::qt_metacall(QMetaObject::Call _c, int _id, void **_a) if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { - if (_id < 2) + if (_id < 1) qt_static_metacall(this, _c, _id, _a); - _id -= 2; + _id -= 1; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { - if (_id < 2) + if (_id < 1) *reinterpret_cast(_a[0]) = -1; - _id -= 2; + _id -= 1; } return _id; } diff --git a/tools/clip/recorder/widget.cc b/tools/clip/recorder/widget.cc index 94433b723b..5d8ad78850 100644 --- a/tools/clip/recorder/widget.cc +++ b/tools/clip/recorder/widget.cc @@ -10,7 +10,7 @@ Recorder::~Recorder() { delete encoder; } -void Recorder::saveFrame(QImage *frame) { +void Recorder::saveFrame(const std::shared_ptr &frame) { QMutexLocker locker(&mutex); frameQueue.enqueue(frame); // Add frame to queue if (!isProcessing) { @@ -21,7 +21,7 @@ void Recorder::saveFrame(QImage *frame) { void Recorder::processQueue() { while (true) { - QImage *frame; + std::shared_ptr frame; { QMutexLocker locker(&mutex); if (frameQueue.isEmpty() || !keepRunning) { @@ -31,16 +31,9 @@ void Recorder::processQueue() { frame = frameQueue.dequeue(); } - if (!encoder->writeFrame(frame->convertToFormat(QImage::Format_ARGB32_Premultiplied))) { + if (!encoder->writeFrame(frame->toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied))) { fprintf(stderr, "did not write\n"); } - - delete frame; } } -void Recorder::stop() { - QMutexLocker locker(&mutex); - keepRunning = false; -} - diff --git a/tools/clip/recorder/widget.h b/tools/clip/recorder/widget.h index 63bff91eef..fcb7dcbd26 100644 --- a/tools/clip/recorder/widget.h +++ b/tools/clip/recorder/widget.h @@ -16,12 +16,11 @@ public: ~Recorder() override; public slots: - void saveFrame(QImage *frame); - void stop(); + void saveFrame(const std::shared_ptr &frame); private: FFmpegEncoder *encoder; - QQueue frameQueue; + QQueue> frameQueue; QMutex mutex; bool isProcessing = false; bool keepRunning = true;