mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-06-28 18:12:05 +08:00
FIX: It is not safe to call cameras_close before all threads are done. (#19555)
* call cameras_close after all threads exited * stop buffer before join * remove buf->stop old-commit-hash: 660abb79dc925427ae96e5bf03fb5635061cc919
This commit is contained in:
@@ -25,7 +25,7 @@ void camera_open(CameraState *s, bool rear) {
|
||||
}
|
||||
|
||||
void camera_close(CameraState *s) {
|
||||
s->buf.stop();
|
||||
// empty
|
||||
}
|
||||
|
||||
void camera_init(VisionIpcServer * v, CameraState *s, int camera_id, unsigned int fps, cl_device_id device_id, cl_context ctx, VisionStreamType rgb_type, VisionStreamType yuv_type) {
|
||||
@@ -117,6 +117,6 @@ void cameras_run(MultiCameraState *s) {
|
||||
std::thread t = start_process_thread(s, "processing", &s->rear, camera_process_rear);
|
||||
set_thread_name("frame_streaming");
|
||||
run_frame_stream(s);
|
||||
cameras_close(s);
|
||||
t.join();
|
||||
cameras_close(s);
|
||||
}
|
||||
|
||||
@@ -1491,8 +1491,6 @@ void cameras_open(MultiCameraState *s) {
|
||||
|
||||
|
||||
static void camera_close(CameraState *s) {
|
||||
s->buf.stop();
|
||||
|
||||
// ISP: STOP_STREAM
|
||||
s->stream_cfg.cmd = STOP_STREAM;
|
||||
int err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_CFG_STREAM, &s->stream_cfg);
|
||||
@@ -1783,9 +1781,9 @@ void cameras_run(MultiCameraState *s) {
|
||||
err = pthread_join(ops_thread_handle, NULL);
|
||||
assert(err == 0);
|
||||
|
||||
cameras_close(s);
|
||||
|
||||
for (auto &t : threads) t.join();
|
||||
|
||||
cameras_close(s);
|
||||
}
|
||||
|
||||
void cameras_close(MultiCameraState *s) {
|
||||
|
||||
@@ -903,7 +903,6 @@ static void camera_close(CameraState *s) {
|
||||
|
||||
ret = cam_control(s->video0_fd, CAM_REQ_MGR_DESTROY_SESSION, &s->req_mgr_session_info, sizeof(s->req_mgr_session_info));
|
||||
LOGD("destroyed session: %d", ret);
|
||||
s->buf.stop();
|
||||
}
|
||||
|
||||
static void cameras_close(MultiCameraState *s) {
|
||||
@@ -1197,7 +1196,7 @@ void cameras_run(MultiCameraState *s) {
|
||||
err = pthread_join(ae_thread_handle, NULL);
|
||||
assert(err == 0);
|
||||
|
||||
cameras_close(s);
|
||||
|
||||
for (auto &t : threads) t.join();
|
||||
|
||||
cameras_close(s);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ void camera_open(CameraState *s, bool rear) {
|
||||
}
|
||||
|
||||
void camera_close(CameraState *s) {
|
||||
s->buf.stop();
|
||||
// empty
|
||||
}
|
||||
|
||||
void camera_init(VisionIpcServer * v, CameraState *s, int camera_id, unsigned int fps, cl_device_id device_id, cl_context ctx, VisionStreamType rgb_type, VisionStreamType yuv_type) {
|
||||
@@ -271,8 +271,10 @@ void cameras_run(MultiCameraState *s) {
|
||||
std::thread t_rear = std::thread(rear_thread, &s->rear);
|
||||
set_thread_name("webcam_thread");
|
||||
front_thread(&s->front);
|
||||
|
||||
t_rear.join();
|
||||
cameras_close(s);
|
||||
|
||||
for (auto &t : threads) t.join();
|
||||
|
||||
cameras_close(s);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user