mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-06-28 10:02:06 +08:00
replay: fix possible segfault in CameraServer (#22556)
old-commit-hash: 20b0ae0e65c9e5237a6b9f89329d31254ffab20e
This commit is contained in:
@@ -60,5 +60,12 @@ void CameraServer::thread() {
|
||||
} else {
|
||||
std::cout << "camera[" << type << "] failed to get frame:" << eidx.getSegmentId() << std::endl;
|
||||
}
|
||||
|
||||
--publishing_;
|
||||
}
|
||||
}
|
||||
|
||||
void CameraServer::pushFrame(CameraType type, FrameReader *fr, const cereal::EncodeIndex::Reader &eidx) {
|
||||
++publishing_;
|
||||
queue_.push({type, fr, eidx});
|
||||
}
|
||||
|
||||
@@ -10,11 +10,9 @@ class CameraServer {
|
||||
public:
|
||||
CameraServer();
|
||||
~CameraServer();
|
||||
inline void pushFrame(CameraType type, FrameReader* fr, const cereal::EncodeIndex::Reader& eidx) {
|
||||
queue_.push({type, fr, eidx});
|
||||
}
|
||||
void pushFrame(CameraType type, FrameReader* fr, const cereal::EncodeIndex::Reader& eidx);
|
||||
inline void waitFinish() {
|
||||
while (!queue_.empty()) usleep(0);
|
||||
while (publishing_ > 0) usleep(0);
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -33,6 +31,8 @@ protected:
|
||||
{.rgb_type = VISION_STREAM_RGB_FRONT, .yuv_type = VISION_STREAM_YUV_FRONT},
|
||||
{.rgb_type = VISION_STREAM_RGB_WIDE, .yuv_type = VISION_STREAM_YUV_WIDE},
|
||||
};
|
||||
|
||||
std::atomic<int> publishing_ = 0;
|
||||
std::thread camera_thread_;
|
||||
std::unique_ptr<VisionIpcServer> vipc_server_;
|
||||
SafeQueue<std::tuple<CameraType, FrameReader*, const cereal::EncodeIndex::Reader>> queue_;
|
||||
|
||||
Reference in New Issue
Block a user