#define CAMERASRC_SET_CMD(cmd, value) _camerasrc_set_cmd(handle, cmd, (void*)value);
#define CAMERASRC_GET_CMD(cmd, value) _camerasrc_get_cmd(handle, cmd, (void*)value);
-static int do_exit = 0; // temporary !!
void __print_time(const char *str, struct timeval *last_tv)
{
handle->cur_af_range = CAMERASRC_AF_RANGE_NORMAL;
handle->af_usr_data = NULL;
handle->af_cb = NULL;
+ handle->isp_thread_cancel = FALSE;
handle->first_frame = 1;
handle->frame_count = 0;
handle->request_count = 0;
/* __print_timestamp(__func__, __LINE__, &last_tv); */
- while (!do_exit) {
+ while (!p->isp_thread_cancel) {
/* SENSOR - DQBUF */
ret = _camerasrc_ioctl_dqbuf(p, p->fd_sensor,
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
break;
}
+ ret = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
+ if (ret != 0)
+ camsrc_error("[ISP] pthread_setcancelstate failed");
+
shot_sensor = (struct camera2_shot_ext *)p->buffer_sensor[buf_index_sensor].planes[1].start;
timestamp = shot_sensor->shot.dm.sensor.timeStamp;
p->frame_count = shot_sensor->shot.dm.request.frameCount;
camsrc_debug("[ISP] DQBUF index %d", buf_index_isp);
}
+ ret = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
+ if (ret != 0)
+ camsrc_error("[ISP] pthread_setcancelstate failed");
+
buf_index_isp = buf_index_3aa_cap;
shot_isp = (struct camera2_shot_ext *)p->buffer_isp[buf_index_isp].planes[1].start;
}
camsrc_debug("[SENSOR] QBUF index %d", buf_index_sensor);
+
+ /* Short delay to allow cancelling of the thread */
+ g_usleep(1000);
}
return NULL;
/* __print_timestamp(__func__, __LINE__, &last_tv); */
- while (!do_exit) {
+ while (!p->isp_thread_cancel) {
ret = _camerasrc_ioctl_dqbuf(p,
p->fd_sensor,
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
break;
}
+ ret = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
+ if (ret != 0)
+ camsrc_error("[ISP] pthread_setcancelstate failed");
+
p->qbuf_count_sensor--;
sensor_buf_count++;
camsrc_debug("[3AA - CAPTURE] QBUF index %d", buf_index_3aa_cap);
camsrc_debug("[Sensor] buffer count: %d\n", sensor_buf_count);
+ ret = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
+ if (ret != 0)
+ camsrc_error("[ISP] pthread_setcancelstate failed");
+
/* FIXME: This delay prevents the tearing issue */
g_usleep((G_USEC_PER_SEC / CAMERASRC_PRIMARY_FRAME_RATE) + 1);
}
camsrc_info("Stopping streaming and releasing buffers...");
- /* FIXME */
- do_exit = 1;
- pthread_join(p->isp_thread, 0);
+ p->isp_thread_cancel = TRUE;
+
+ ret = pthread_cancel(p->isp_thread);
+ if (ret != 0)
+ camsrc_error("[ISP] ISP thread cancel failed[%x]", ret);
+
+ ret = pthread_join(p->isp_thread, 0);
+ if (ret != 0)
+ camsrc_error("[ISP] ISP thread join failed[%x]", ret);
/* STREAM OFF */
if (p->cur_dev_id == CAMERASRC_DEV_ID_PRIMARY) {