static void __camera_release_preview_buffer(camera_h camera);
static void __camera_release_tfd(int tfd[MUSE_NUM_FD]);
+static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
+ int type, const char *thread_name, camera_cb_info_s *cb_info);
+static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info);
+
static gboolean __camera_allocate_preview_buffer(camera_h camera)
{
cb_info = (camera_cb_info_s *)handler_info->cb_info;
type = handler_info->type;
- CAM_LOG_INFO("t:%d start", type);
+ CAM_LOG_INFO("t:%d start[thread:%p]", type, handler_info->thread);
g_mutex_lock(&handler_info->mutex);
g_mutex_unlock(&cb_info->api_mutex[api]);
} else if (api == MUSE_CAMERA_CB_EVENT) {
+ if (cam_msg->event == MUSE_CAMERA_EVENT_TYPE_INTERRUPTED) {
+ CAM_LOG_WARNING("INTERRUPTED, release thread for preview cb");
+ __destroy_msg_handler_thread(&cb_info->preview_cb_info);
+ }
+
switch (cam_msg->event_class) {
case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
__camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event, cam_msg->tfd);
g_mutex_unlock(&handler_info->mutex);
- CAM_LOG_INFO("t:%d return", type);
+ CAM_LOG_INFO("t:%d return[thread:%p]", type, handler_info->thread);
return NULL;
}
return false;
}
+ if (handler_info->thread) {
+ CAM_LOG_WARNING("t:%d thread[%p] is already created", type, handler_info->thread);
+ return true;
+ }
+
CAM_LOG_INFO("t:%d [%s]", type, thread_name);
handler_info->type = type;
return false;
}
- CAM_LOG_INFO("t:%d done", type);
+ CAM_LOG_INFO("t:%d done[thread:%p]", type, handler_info->thread);
return true;
}
type = handler_info->type;
- CAM_LOG_INFO("t:%d thread %p", type, handler_info->thread);
+ CAM_LOG_INFO("t:%d thread[%p]", type, handler_info->thread);
g_mutex_lock(&handler_info->mutex);
g_atomic_int_set(&handler_info->running, 0);
CAM_LOG_INFO("msg_recv thread removed");
/* destroy msg handler threads */
+ if (cb_info->preview_cb_info.thread)
+ __destroy_msg_handler_thread(&cb_info->preview_cb_info);
__destroy_msg_handler_thread(&cb_info->msg_handler_info);
__destroy_msg_handler_thread(&cb_info->capture_cb_info);