From: Jeongmo Yang Date: Thu, 19 Nov 2015 09:29:32 +0000 (+0900) Subject: Release version 0.2.24 X-Git-Tag: accepted/tizen/mobile/20151122.234540^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=571320aeb3756fd1cbe5a26b4994d104a448c949;p=platform%2Fcore%2Fapi%2Fcamera.git Release version 0.2.24 1. Fix bug - capture completed callback is not called when continuous capture mode 2. Renaming some member variables 3. Update error handling in _client_callback_new function 4. Remove unused code Change-Id: I15fbf122a0cf8e5e93a0e09b9d2227b0adf34698 Signed-off-by: Jeongmo Yang --- diff --git a/include/camera_private.h b/include/camera_private.h index 905e2d7..9bb0891 100644 --- a/include/camera_private.h +++ b/include/camera_private.h @@ -30,69 +30,39 @@ extern "C" { #endif -#define MAX_DETECTED_FACE 20 - #define CAMERA_PARSE_STRING_SIZE 20 -typedef enum { - _CAMERA_EVENT_TYPE_STATE_CHANGE, - _CAMERA_EVENT_TYPE_FOCUS_CHANGE, - _CAMERA_EVENT_TYPE_CAPTURE_COMPLETE, - _CAMERA_EVENT_TYPE_PREVIEW, - _CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW, - _CAMERA_EVENT_TYPE_CAPTURE, - _CAMERA_EVENT_TYPE_ERROR, - _CAMERA_EVENT_TYPE_HDR_PROGRESS, - _CAMERA_EVENT_TYPE_INTERRUPTED, - _CAMERA_EVENT_TYPE_FACE_DETECTION, - _CAMERA_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR, - _CAMERA_EVENT_TYPE_NUM -}_camera_event_e; - -typedef struct _camera_cb_data { - int event_type; - void *handle; -} camera_cb_data; - -typedef struct _callback_cb_info { - GThread *msg_rcv_thread; - GThread *message_handler_thread; - gint rcv_thread_running; - gint message_handler_running; +typedef struct _camera_cb_info_s { gint fd; - gint id; - gpointer user_cb[MUSE_CAMERA_EVENT_TYPE_NUM]; - gpointer user_cb_completed[MUSE_CAMERA_EVENT_TYPE_NUM]; - gpointer user_data[MUSE_CAMERA_EVENT_TYPE_NUM]; - gchar recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH]; - GCond *pCond; - GMutex *pMutex; - GCond message_handler_cond; - GMutex message_handler_mutex; + GThread *msg_recv_thread; + GThread *msg_handler_thread; + gint msg_recv_running; + gint msg_handler_running; + GCond msg_handler_cond; + GMutex msg_handler_mutex; + GQueue *msg_queue; GList *idle_event_list; GCond idle_event_cond; GMutex idle_event_mutex; - gint *activating; - gint *ret; + gpointer user_cb[MUSE_CAMERA_EVENT_TYPE_NUM]; + gpointer user_data[MUSE_CAMERA_EVENT_TYPE_NUM]; + gchar recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH]; + GCond *api_cond; + GMutex *api_mutex; + gint *api_activating; + gint *api_ret; tbm_bufmgr bufmgr; - GQueue *message_queue; gint prev_state; media_format_h pkt_fmt; -} callback_cb_info_s; +} camera_cb_info_s; typedef struct _camera_message_s { gchar recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH]; muse_camera_api_e api; } camera_message_s; -typedef struct _camera_event_s { - callback_cb_info_s *cb_info; - gchar recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH]; - muse_camera_event_e event; -} camera_event_s; - typedef struct _camera_idle_event_s { - callback_cb_info_s *cb_info; + camera_cb_info_s *cb_info; gchar recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH]; muse_camera_event_e event; GMutex event_mutex; @@ -101,8 +71,8 @@ typedef struct _camera_idle_event_s { typedef struct _camera_cli_s { intptr_t remote_handle; MMHandleType client_handle; - intptr_t cli_display_handle; - callback_cb_info_s *cb_info; + intptr_t display_handle; + camera_cb_info_s *cb_info; #ifdef HAVE_WAYLAND MMCamWaylandInfo *wl_info; #endif /* #ifdef HAVE_WAYLAND */ @@ -115,17 +85,7 @@ typedef struct _camera_media_packet_data { int num_buffer_key; } camera_media_packet_data; -typedef enum { - MUSE_CAMERA_CLIENT_SYNC_CB_HANDLER, - MUSE_CAMERA_CLIENT_USER_CALLBACK, - MUSE_CAMERA_CLIENT_MAX -} muse_cli_camera_api_e; - -int _camera_get_mm_handle(camera_h camera , MMHandleType *handle); -int _camera_set_relay_mm_message_callback(camera_h camera, MMMessageCallback callback, void *user_data); -int __camera_start_continuous_focusing(camera_h camera); -int _camera_set_use(camera_h camera, bool used); -bool _camera_is_used(camera_h camera); + int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format); int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype); int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data); diff --git a/packaging/capi-media-camera.spec b/packaging/capi-media-camera.spec index ae64718..04004c6 100644 --- a/packaging/capi-media-camera.spec +++ b/packaging/capi-media-camera.spec @@ -3,7 +3,7 @@ Name: capi-media-camera Summary: A Camera API -Version: 0.2.23 +Version: 0.2.24 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/camera.c b/src/camera.c index c1663f0..7430597 100755 --- a/src/camera.c +++ b/src/camera.c @@ -239,34 +239,35 @@ static void _release_imported_bo(tbm_bo *bo) return; } -static int _client_wait_for_cb_return(muse_camera_api_e api, callback_cb_info_s *cb_info, int time_out) +static int _client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out) { int ret = CAMERA_ERROR_NONE; gint64 end_time; LOGD("Enter api : %d", api); - g_mutex_lock(&(cb_info->pMutex[api])); - if (cb_info->activating[api] == 0) { + g_mutex_lock(&(cb_info->api_mutex[api])); + + if (cb_info->api_activating[api] == 0) { end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND; - if (g_cond_wait_until(&(cb_info->pCond[api]), &(cb_info->pMutex[api]), end_time)) { - ret = cb_info->ret[api]; - cb_info->activating[api] = 0; + if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) { + ret = cb_info->api_ret[api]; + cb_info->api_activating[api] = 0; LOGD("return value : 0x%x", ret); } else { ret = CAMERA_ERROR_INVALID_OPERATION; - LOGD("api %d was TIMED OUT!", api); + LOGE("api %d was TIMED OUT!", api); } } else { - ret = cb_info->ret[api]; - cb_info->activating[api] = 0; + ret = cb_info->api_ret[api]; + cb_info->api_activating[api] = 0; - LOGE("condition is already checked for the api[%d], return[0x%x]", api, ret); + LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret); } - g_mutex_unlock(&(cb_info->pMutex[api])); + g_mutex_unlock(&(cb_info->api_mutex[api])); return ret; } @@ -388,7 +389,7 @@ int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user { int i = 0; int ret = 0; - callback_cb_info_s *cb_info = (callback_cb_info_s *)user_data; + camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data; camera_media_packet_data *mp_data = NULL; tbm_surface_h tsurf = NULL; @@ -439,7 +440,7 @@ int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user return MEDIA_PACKET_FINALIZE; } -static void _client_user_callback(callback_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event) +static void _client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event) { int param1 = 0; int param2 = 0; @@ -448,11 +449,11 @@ static void _client_user_callback(callback_cb_info_s *cb_info, char *recv_msg, m tbm_bo_handle bo_handle = {NULL, }; if (recv_msg == NULL || event >= MUSE_CAMERA_EVENT_TYPE_NUM) { - LOGE("invalid parameter - msg %p, event %d", recv_msg, event); + LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event); return; } - LOGD("get msg %s, event %d", recv_msg, event); + LOGD("get camera msg %s, event %d", recv_msg, event); if (cb_info->user_cb[event] == NULL) { LOGW("user callback for event %d is not set", event); @@ -1107,7 +1108,7 @@ static void _client_user_callback(callback_cb_info_s *cb_info, char *recv_msg, m static bool _camera_idle_event_callback(void *data) { - callback_cb_info_s *cb_info = NULL; + camera_cb_info_s *cb_info = NULL; camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data; if (cam_idle_event == NULL) { @@ -1120,7 +1121,7 @@ static bool _camera_idle_event_callback(void *data) cb_info = cam_idle_event->cb_info; if (cb_info == NULL) { - LOGW("cb_info is NULL. event %d", cam_idle_event->event); + LOGW("camera cb_info is NULL. event %d", cam_idle_event->event); goto IDLE_EVENT_CALLBACK_DONE; } @@ -1129,7 +1130,7 @@ static bool _camera_idle_event_callback(void *data) if (cb_info->idle_event_list) { cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event); } - /*LOGD("remove idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/ + /*LOGD("remove camera idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/ g_mutex_unlock(&cb_info->idle_event_mutex); /* user callback */ @@ -1149,14 +1150,15 @@ IDLE_EVENT_CALLBACK_DONE: return false; } -static void *_message_handler(gpointer data) +static void *_camera_msg_handler_func(gpointer data) { int ret = 0; + int api = 0; int event = 0; int event_class = 0; camera_message_s *cam_msg = NULL; camera_idle_event_s *cam_idle_event = NULL; - callback_cb_info_s *cb_info = (callback_cb_info_s *)data; + camera_cb_info_s *cb_info = (camera_cb_info_s *)data; if (cb_info == NULL) { LOGE("cb_info NULL"); @@ -1165,57 +1167,59 @@ static void *_message_handler(gpointer data) LOGD("start"); - g_mutex_lock(&cb_info->message_handler_mutex); + g_mutex_lock(&cb_info->msg_handler_mutex); - while (g_atomic_int_get(&cb_info->message_handler_running)) { - if (g_queue_is_empty(cb_info->message_queue)) { + while (g_atomic_int_get(&cb_info->msg_handler_running)) { + if (g_queue_is_empty(cb_info->msg_queue)) { LOGD("signal wait..."); - g_cond_wait(&cb_info->message_handler_cond, &cb_info->message_handler_mutex); + g_cond_wait(&cb_info->msg_handler_cond, &cb_info->msg_handler_mutex); LOGD("signal received"); - if (g_atomic_int_get(&cb_info->message_handler_running) == 0) { + if (g_atomic_int_get(&cb_info->msg_handler_running) == 0) { LOGD("stop event thread"); break; } } - cam_msg = (camera_message_s *)g_queue_pop_head(cb_info->message_queue); + cam_msg = (camera_message_s *)g_queue_pop_head(cb_info->msg_queue); - g_mutex_unlock(&cb_info->message_handler_mutex); + g_mutex_unlock(&cb_info->msg_handler_mutex); if (cam_msg == NULL) { LOGE("NULL message"); - g_mutex_lock(&cb_info->message_handler_mutex); + g_mutex_lock(&cb_info->msg_handler_mutex); continue; } - if (cam_msg->api < MUSE_CAMERA_API_MAX) { - g_mutex_lock(&cb_info->pMutex[cam_msg->api]); + api = cam_msg->api; + + if (api < MUSE_CAMERA_API_MAX) { + g_mutex_lock(&cb_info->api_mutex[api]); if (muse_camera_msg_get(ret, cam_msg->recv_msg)) { - cb_info->ret[cam_msg->api] = ret; - cb_info->activating[cam_msg->api] = 1; + cb_info->api_ret[api] = ret; + cb_info->api_activating[api] = 1; - LOGD("api %d - return 0x%x", ret); + LOGD("camera api %d - return 0x%x", ret); - g_cond_signal(&cb_info->pCond[cam_msg->api]); + g_cond_signal(&cb_info->api_cond[api]); } else { - LOGE("failed to get ret for api %d, msg %s", cam_msg->api, cam_msg->recv_msg); + LOGE("failed to get camera ret for api %d, msg %s", api, cam_msg->recv_msg); } - g_mutex_unlock(&cb_info->pMutex[cam_msg->api]); - } else if (cam_msg->api == MUSE_CAMERA_CB_EVENT) { + g_mutex_unlock(&cb_info->api_mutex[api]); + } else if (api == MUSE_CAMERA_CB_EVENT) { event = -1; event_class = -1; if (!muse_camera_msg_get(event, cam_msg->recv_msg) || !muse_camera_msg_get(event_class, cam_msg->recv_msg)) { - LOGE("failed to get event %d, class %d", event, event_class); + LOGE("failed to get camera event %d, class %d", event, event_class); g_free(cam_msg); cam_msg = NULL; - g_mutex_lock(&cb_info->message_handler_mutex); + g_mutex_lock(&cb_info->msg_handler_mutex); continue; } @@ -1235,7 +1239,7 @@ static void *_message_handler(gpointer data) g_mutex_init(&cam_idle_event->event_mutex); memcpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg)); - LOGD("add event[%d, %p] to IDLE", event, cam_idle_event); + LOGD("add camera event[%d, %p] to IDLE", event, cam_idle_event); g_mutex_lock(&cb_info->idle_event_mutex); cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event); @@ -1247,22 +1251,22 @@ static void *_message_handler(gpointer data) NULL); break; default: - LOGE("unknown event class %d", event_class); + LOGE("unknown camera event class %d", event_class); break; } } else { - LOGE("unknown api[%d] message", cam_msg->api); + LOGE("unknown camera api[%d] message[%s]", api, cam_msg->recv_msg); } free(cam_msg); cam_msg = NULL; - g_mutex_lock(&cb_info->message_handler_mutex); + g_mutex_lock(&cb_info->msg_handler_mutex); } /* remove remained event */ - while (!g_queue_is_empty(cb_info->message_queue)) { - cam_msg = (camera_message_s *)g_queue_pop_head(cb_info->message_queue); + while (!g_queue_is_empty(cb_info->msg_queue)) { + cam_msg = (camera_message_s *)g_queue_pop_head(cb_info->msg_queue); if (cam_msg) { LOGD("remove camera message %p", cam_msg); free(cam_msg); @@ -1272,14 +1276,14 @@ static void *_message_handler(gpointer data) } } - g_mutex_unlock(&cb_info->message_handler_mutex); + g_mutex_unlock(&cb_info->msg_handler_mutex); LOGD("return"); return NULL; } -static void _camera_remove_idle_event_all(callback_cb_info_s *cb_info) +static void _camera_remove_idle_event_all(camera_cb_info_s *cb_info) { camera_idle_event_s *cam_idle_event = NULL; gboolean ret = TRUE; @@ -1350,19 +1354,19 @@ static void _camera_remove_idle_event_all(callback_cb_info_s *cb_info) return; } -static void *_client_cb_handler(gpointer data) +static void *_camera_msg_recv_func(gpointer data) { + int i = 0; int ret = 0; int api = 0; int api_class = 0; int num_token = 0; - int i = 0; int str_pos = 0; int prev_pos = 0; int prev_state = CAMERA_STATE_NONE; - callback_cb_info_s *cb_info = (callback_cb_info_s *)data; char *recv_msg = NULL; char **parse_str = NULL; + camera_cb_info_s *cb_info = (camera_cb_info_s *)data; if (cb_info == NULL) { LOGE("cb_info NULL"); @@ -1387,7 +1391,7 @@ static void *_client_cb_handler(gpointer data) recv_msg = cb_info->recv_msg; - while (g_atomic_int_get(&cb_info->rcv_thread_running)) { + while (g_atomic_int_get(&cb_info->msg_recv_running)) { ret = muse_core_ipc_recv_msg(cb_info->fd, recv_msg); if (ret <= 0) break; @@ -1424,34 +1428,34 @@ static void *_client_cb_handler(gpointer data) api_class = -1; if (!muse_camera_msg_get(api, parse_str[i])) { - LOGE("failed to get api"); + LOGE("failed to get camera api"); continue; } if (muse_camera_msg_get(api_class, parse_str[i])) { - LOGD("api_class[%d]", api_class); + LOGD("camera api_class[%d]", api_class); } if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) { - g_mutex_lock(&cb_info->pMutex[api]); + g_mutex_lock(&cb_info->api_mutex[api]); if (!muse_camera_msg_get(ret, parse_str[i])) { - LOGE("failed to get ret"); - g_mutex_unlock(&cb_info->pMutex[api]); + LOGE("failed to get camera ret"); + g_mutex_unlock(&cb_info->api_mutex[api]); continue; } - cb_info->ret[api] = ret; - cb_info->activating[api] = 1; + cb_info->api_ret[api] = ret; + cb_info->api_activating[api] = 1; if (api == MUSE_CAMERA_API_CREATE) { if (ret != CAMERA_ERROR_NONE) { - g_atomic_int_set(&cb_info->rcv_thread_running, 0); + g_atomic_int_set(&cb_info->msg_recv_running, 0); LOGE("camera create error 0x%x. close client cb handler", ret); } } else if (api == MUSE_CAMERA_API_DESTROY) { if (ret == CAMERA_ERROR_NONE) { - g_atomic_int_set(&cb_info->rcv_thread_running, 0); + g_atomic_int_set(&cb_info->msg_recv_running, 0); LOGD("camera destroy done. close client cb handler"); } } else if (api == MUSE_CAMERA_API_START_PREVIEW) { @@ -1459,8 +1463,8 @@ static void *_client_cb_handler(gpointer data) cb_info->prev_state = prev_state; } - g_cond_signal(&cb_info->pCond[api]); - g_mutex_unlock(&cb_info->pMutex[api]); + g_cond_signal(&cb_info->api_cond[api]); + g_mutex_unlock(&cb_info->api_mutex[api]); } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) { camera_message_s *cam_msg = g_new0(camera_message_s, 1); @@ -1472,14 +1476,14 @@ static void *_client_cb_handler(gpointer data) cam_msg->api = api; memcpy(cam_msg->recv_msg, parse_str[i], sizeof(cam_msg->recv_msg)); - LOGD("add message to queue : api %d", api); + LOGD("add camera message to queue : api %d", api); - g_mutex_lock(&cb_info->message_handler_mutex); - g_queue_push_tail(cb_info->message_queue, (gpointer)cam_msg); - g_cond_signal(&cb_info->message_handler_cond); - g_mutex_unlock(&cb_info->message_handler_mutex); + g_mutex_lock(&cb_info->msg_handler_mutex); + g_queue_push_tail(cb_info->msg_queue, (gpointer)cam_msg); + g_cond_signal(&cb_info->msg_handler_cond); + g_mutex_unlock(&cb_info->msg_handler_mutex); } else { - LOGW("unknown api %d and api_class %d", api, api_class); + LOGW("unknown camera api %d and api_class %d", api, api_class); } } @@ -1503,111 +1507,157 @@ CB_HANDLER_EXIT: return NULL; } -static callback_cb_info_s *_client_callback_new(gint sockfd) +static camera_cb_info_s *_client_callback_new(gint sockfd) { - callback_cb_info_s *cb_info = NULL; - GCond *camera_cond = NULL; - GMutex *camera_mutex = NULL; - gint *camera_activ = NULL; - gint *ret = NULL; + camera_cb_info_s *cb_info = NULL; + GCond *tmp_cond = NULL; + GMutex *tmp_mutex = NULL; + gint *tmp_activating = NULL; + gint *tmp_ret = NULL; g_return_val_if_fail(sockfd > 0, NULL); - cb_info = g_new0(callback_cb_info_s, 1); + cb_info = g_new0(camera_cb_info_s, 1); if (cb_info == NULL) { LOGE("cb_info failed"); goto ErrorExit; } - camera_cond = g_new0(GCond, MUSE_CAMERA_API_MAX); - if (camera_cond == NULL) { - LOGE("camera_cond failed"); + g_mutex_init(&cb_info->msg_handler_mutex); + g_cond_init(&cb_info->msg_handler_cond); + g_mutex_init(&cb_info->idle_event_mutex); + g_cond_init(&cb_info->idle_event_cond); + + tmp_cond = g_new0(GCond, MUSE_CAMERA_API_MAX); + if (tmp_cond == NULL) { + LOGE("tmp_cond failed"); + goto ErrorExit; + } + + tmp_mutex = g_new0(GMutex, MUSE_CAMERA_API_MAX); + if (tmp_mutex == NULL) { + LOGE("tmp_mutex failed"); goto ErrorExit; } - camera_mutex = g_new0(GMutex, MUSE_CAMERA_API_MAX); - if (camera_mutex == NULL) { - LOGE("camera_mutex failed"); + + tmp_activating = g_new0(gint, MUSE_CAMERA_API_MAX); + if (tmp_activating == NULL) { + LOGE("tmp_activating failed"); goto ErrorExit; } - camera_activ = g_new0(gint, MUSE_CAMERA_API_MAX); - if (camera_activ == NULL) { - LOGE("camera_activ failed"); + + tmp_ret = g_new0(gint, MUSE_CAMERA_API_MAX); + if (tmp_ret == NULL) { + LOGE("tmp_ret failed"); goto ErrorExit; } - ret = g_new0(gint, MUSE_CAMERA_API_MAX); - if (ret == NULL) { - LOGE("ret failed"); + + cb_info->msg_queue = g_queue_new(); + if (cb_info->msg_queue == NULL) { + LOGE("msg_queue new failed"); + goto ErrorExit; + } + + g_atomic_int_set(&cb_info->msg_handler_running, 1); + cb_info->msg_handler_thread = g_thread_try_new("camera_msg_handler", + _camera_msg_handler_func, + (gpointer)cb_info, + NULL); + if (cb_info->msg_handler_thread == NULL) { + LOGE("message handler thread creation failed"); goto ErrorExit; } - g_atomic_int_set(&cb_info->rcv_thread_running, 1); cb_info->fd = sockfd; - cb_info->pCond = camera_cond; - cb_info->pMutex = camera_mutex; - cb_info->activating = camera_activ; - cb_info->ret = ret; - cb_info->msg_rcv_thread = g_thread_new("msg_rcv_thread", _client_cb_handler, (gpointer)cb_info); - - g_atomic_int_set(&cb_info->message_handler_running, 1); - g_mutex_init(&cb_info->message_handler_mutex); - g_cond_init(&cb_info->message_handler_cond); - g_mutex_init(&cb_info->idle_event_mutex); - g_cond_init(&cb_info->idle_event_cond); - cb_info->message_queue = g_queue_new(); - cb_info->message_handler_thread = g_thread_new("message_handler", _message_handler, (gpointer)cb_info); + cb_info->api_cond = tmp_cond; + cb_info->api_mutex = tmp_mutex; + cb_info->api_activating = tmp_activating; + cb_info->api_ret = tmp_ret; + + g_atomic_int_set(&cb_info->msg_recv_running, 1); + cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv", + _camera_msg_recv_func, + (gpointer)cb_info, + NULL); + if (cb_info->msg_recv_thread == NULL) { + LOGE("message receive thread creation failed"); + goto ErrorExit; + } return cb_info; ErrorExit: - if (camera_cond) { - g_free(camera_cond); - camera_cond = NULL; + if (cb_info) { + if (cb_info->msg_handler_thread) { + g_mutex_lock(&cb_info->msg_handler_mutex); + g_atomic_int_set(&cb_info->msg_handler_running, 0); + g_cond_signal(&cb_info->msg_handler_cond); + g_mutex_unlock(&cb_info->msg_handler_mutex); + + g_thread_join(cb_info->msg_handler_thread); + g_thread_unref(cb_info->msg_handler_thread); + cb_info->msg_handler_thread = NULL; + } + + g_mutex_clear(&cb_info->msg_handler_mutex); + g_cond_clear(&cb_info->msg_handler_cond); + g_mutex_clear(&cb_info->idle_event_mutex); + g_cond_clear(&cb_info->idle_event_cond); + + if (cb_info->msg_queue) { + g_queue_free(cb_info->msg_queue); + cb_info->msg_queue = NULL; + } + + g_free(cb_info); + cb_info = NULL; } - if (camera_mutex) { - g_free(camera_mutex); - camera_mutex = NULL; + + if (tmp_cond) { + g_free(tmp_cond); + tmp_cond = NULL; } - if (camera_activ) { - g_free(camera_activ); - camera_activ = NULL; + if (tmp_mutex) { + g_free(tmp_mutex); + tmp_mutex = NULL; } - if (ret) { - g_free(ret); - ret = NULL; + if (tmp_activating) { + g_free(tmp_activating); + tmp_activating = NULL; } - if (cb_info) { - g_free(cb_info); - cb_info = NULL; + if (tmp_ret) { + g_free(tmp_ret); + tmp_ret = NULL; } return NULL; } -static void _client_callback_destroy(callback_cb_info_s * cb_info) +static void _client_callback_destroy(camera_cb_info_s *cb_info) { g_return_if_fail(cb_info != NULL); - LOGI("MSG receive thread[%p] destroy", cb_info->msg_rcv_thread); + LOGD("MSG receive thread[%p] destroy", cb_info->msg_recv_thread); - g_thread_join(cb_info->msg_rcv_thread); - g_thread_unref(cb_info->msg_rcv_thread); - cb_info->msg_rcv_thread = NULL; + g_thread_join(cb_info->msg_recv_thread); + g_thread_unref(cb_info->msg_recv_thread); + cb_info->msg_recv_thread = NULL; LOGD("msg thread removed"); - g_mutex_lock(&cb_info->message_handler_mutex); - g_atomic_int_set(&cb_info->message_handler_running, 0); - g_cond_signal(&cb_info->message_handler_cond); - g_mutex_unlock(&cb_info->message_handler_mutex); + g_mutex_lock(&cb_info->msg_handler_mutex); + g_atomic_int_set(&cb_info->msg_handler_running, 0); + g_cond_signal(&cb_info->msg_handler_cond); + g_mutex_unlock(&cb_info->msg_handler_mutex); - g_thread_join(cb_info->message_handler_thread); - g_thread_unref(cb_info->message_handler_thread); - cb_info->message_handler_thread = NULL; + g_thread_join(cb_info->msg_handler_thread); + g_thread_unref(cb_info->msg_handler_thread); + cb_info->msg_handler_thread = NULL; - g_queue_free(cb_info->message_queue); - cb_info->message_queue = NULL; - g_mutex_clear(&cb_info->message_handler_mutex); - g_cond_clear(&cb_info->message_handler_cond); + g_queue_free(cb_info->msg_queue); + cb_info->msg_queue = NULL; + g_mutex_clear(&cb_info->msg_handler_mutex); + g_cond_clear(&cb_info->msg_handler_cond); g_mutex_clear(&cb_info->idle_event_mutex); g_cond_clear(&cb_info->idle_event_cond); @@ -1617,21 +1667,21 @@ static void _client_callback_destroy(callback_cb_info_s * cb_info) tbm_bufmgr_deinit(cb_info->bufmgr); cb_info->bufmgr = NULL; } - if (cb_info->pCond) { - g_free(cb_info->pCond); - cb_info->pCond = NULL; + if (cb_info->api_cond) { + g_free(cb_info->api_cond); + cb_info->api_cond = NULL; } - if (cb_info->pMutex) { - g_free(cb_info->pMutex); - cb_info->pMutex = NULL; + if (cb_info->api_mutex) { + g_free(cb_info->api_mutex); + cb_info->api_mutex = NULL; } - if (cb_info->activating) { - g_free(cb_info->activating); - cb_info->activating = NULL; + if (cb_info->api_activating) { + g_free(cb_info->api_activating); + cb_info->api_activating = NULL; } - if (cb_info->ret) { - g_free(cb_info->ret); - cb_info->ret = NULL; + if (cb_info->api_ret) { + g_free(cb_info->api_ret); + cb_info->api_ret = NULL; } if (cb_info->pkt_fmt) { media_format_unref(cb_info->pkt_fmt); @@ -1639,6 +1689,7 @@ static void _client_callback_destroy(callback_cb_info_s * cb_info) } g_free(cb_info); + cb_info = NULL; return; } @@ -1978,10 +2029,12 @@ int camera_start_continuous_capture(camera_h camera, int count, int interval, ca pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data; - pc->cb_info->user_cb_completed[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = completed_cb; + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb; muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, count, INT, interval); + LOGD("ret : 0x%x", ret); + return ret; } @@ -2308,7 +2361,7 @@ int camera_set_display(camera_h camera, camera_display_type_e type, camera_displ } } - pc->cli_display_handle = (intptr_t)set_display_handle; + pc->display_handle = (intptr_t)set_display_handle; muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);