static gboolean __camera_allocate_preview_buffer(camera_h camera);
static void __camera_release_preview_buffer(camera_h camera);
+static void __camera_release_tfd(int tfd[MUSE_NUM_FD]);
static gboolean __camera_allocate_preview_buffer(camera_h camera)
}
+static void __camera_release_tfd(int tfd[MUSE_NUM_FD])
+{
+ int i;
+
+ if (!tfd) {
+ CAM_LOG_WARNING("NULL tfd");
+ return;
+ }
+
+ for (i = 0 ; i < MUSE_NUM_FD ; i++) {
+ if (!CAMERA_IS_FD_VALID(tfd[i]))
+ break;
+
+ close(tfd[i]);
+ tfd[i] = CAMERA_FD_INIT;
+ }
+}
+
+
void _camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
{
if (!cb_info ||
for (i = 0 ; i < num_buffer_fd && i < BUFFER_MAX_PLANE_NUM ; i++)
__camera_release_imported_bo(&buffer_bo[i]);
- for (i = 0 ; i < MUSE_NUM_FD ; i++) {
- if (CAMERA_IS_FD_VALID(tfd[i])) {
- close(tfd[i]);
- tfd[i] = CAMERA_FD_INIT;
- } else {
- break;
- }
- }
+ __camera_release_tfd(tfd);
}
static void __camera_event_handler_capture(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
{
- int i = 0;
int tfd_index = 0;
int capture_fd_main = 0;
int capture_fd_post = 0;
_camera_msg_return_buffer(capture_fd_thumb, cb_info);
}
- for (i = 0 ; i < MUSE_NUM_FD ; i++) {
- if (CAMERA_IS_FD_VALID(tfd[i])) {
- CAM_LOG_INFO("close tfd[%d] %d", i, tfd[i]);
- close(tfd[i]);
- tfd[i] = CAMERA_FD_INIT;
- } else {
- break;
- }
- }
+ __camera_release_tfd(tfd);
CAM_LOG_INFO("return buffer done");
}
while (!g_queue_is_empty(handler_info->queue)) {
cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
if (cam_msg) {
- CAM_LOG_INFO("t:%d remove camera message %p", type, cam_msg);
- free(cam_msg);
- cam_msg = NULL;
+ CAM_LOG_INFO("t:%d remove message %p", type, cam_msg);
+ __camera_release_tfd(cam_msg->tfd);
+ g_free(cam_msg);
} else {
- CAM_LOG_WARNING("t:%d NULL camera message", type);
+ CAM_LOG_WARNING("t:%d NULL message", type);
}
}
cam_msg->event = event;
cam_msg->event_class = event_class;
- if (tfd && CAMERA_IS_FD_VALID(tfd[0]))
+ if (tfd)
memcpy(cam_msg->tfd, tfd, sizeof(cam_msg->tfd));
strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
goto ErrorExit;
}
- /* message handler thread for preview callback */
- if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
- CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
- CAM_LOG_ERROR("preview_cb_info failed");
- goto ErrorExit;
- }
-
/* message handler thread for capture callback */
if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
ErrorExit:
if (cb_info) {
__destroy_msg_handler_thread(&cb_info->msg_handler_info);
- __destroy_msg_handler_thread(&cb_info->preview_cb_info);
__destroy_msg_handler_thread(&cb_info->capture_cb_info);
for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
/* destroy msg handler threads */
__destroy_msg_handler_thread(&cb_info->msg_handler_info);
- __destroy_msg_handler_thread(&cb_info->preview_cb_info);
__destroy_msg_handler_thread(&cb_info->capture_cb_info);
for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
return CAMERA_ERROR_INVALID_OPERATION;
}
- if (current_state == CAMERA_STATE_CREATED && pc->cb_info->user_buffer_supported) {
- if (!__camera_allocate_preview_buffer(camera))
- return CAMERA_ERROR_INVALID_OPERATION;
+ /* message handler thread for preview callback */
+ if (!__create_msg_handler_thread(&pc->cb_info->preview_cb_info,
+ CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", pc->cb_info)) {
+ CAM_LOG_ERROR("preview_cb_info failed");
+ return CAMERA_ERROR_INVALID_OPERATION;
+ }
- _camera_msg_send(api, pc->cb_info->fds, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
+ if (current_state == CAMERA_STATE_CREATED && pc->cb_info->user_buffer_supported) {
+ if (__camera_allocate_preview_buffer(camera))
+ _camera_msg_send(api, pc->cb_info->fds, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
+ else
+ ret = CAMERA_ERROR_INVALID_OPERATION;
} else {
_camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
}
- if (ret == CAMERA_ERROR_NONE && pc->cb_info->is_evas_render) {
- ret = _camera_start_evas_rendering(camera);
- if (ret != CAMERA_ERROR_NONE) {
- CAM_LOG_ERROR("stop preview because of error");
- _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, NULL, pc->cb_info, NULL, 0);
+ if (ret == CAMERA_ERROR_NONE) {
+ if (pc->cb_info->is_evas_render) {
+ ret = _camera_start_evas_rendering(camera);
+ if (ret != CAMERA_ERROR_NONE) {
+ CAM_LOG_ERROR("stop preview because of error");
+ _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, NULL, pc->cb_info, NULL, 0);
+ }
}
}
+ if (ret != CAMERA_ERROR_NONE)
+ __destroy_msg_handler_thread(&pc->cb_info->preview_cb_info);
+
CAM_LOG_INFO("ret : 0x%x", ret);
return ret;
if (ret == CAMERA_ERROR_NONE) {
if (pc->cb_info->user_buffer_supported)
__camera_release_preview_buffer(camera);
+
+ /* release remained message for preview callback */
+ __destroy_msg_handler_thread(&pc->cb_info->preview_cb_info);
} else if (current_state == CAMERA_STATE_PREVIEW) {
CAM_LOG_WARNING("restart evas rendering");
_camera_start_evas_rendering(camera);