diff options
Diffstat (limited to 'src/camera.c')
-rw-r--r-- | src/camera.c | 66 |
1 files changed, 57 insertions, 9 deletions
diff --git a/src/camera.c b/src/camera.c index d0f8419..f368341 100644 --- a/src/camera.c +++ b/src/camera.c @@ -117,8 +117,10 @@ int _camera_get_wl_info(Evas_Object *obj, camera_wl_info_s *wl_info) int ret = CAMERA_ERROR_NONE; Ecore_Wl_Window *window = NULL; struct wl_display *display = NULL; + struct wl_display *display_wrapper = NULL; struct wl_surface *surface = NULL; struct wl_registry *registry = NULL; + struct wl_event_queue *queue = NULL; struct tizen_surface *tz_surface = NULL; struct tizen_resource *tz_resource = NULL; @@ -148,7 +150,23 @@ int _camera_get_wl_info(Evas_Object *obj, camera_wl_info_s *wl_info) goto _DONE; } - registry = wl_display_get_registry(display); + display_wrapper = wl_proxy_create_wrapper(display); + if (!display_wrapper) { + LOGE("failed to create wl display wrapper"); + ret = CAMERA_ERROR_INVALID_OPERATION; + goto _DONE; + } + + queue = wl_display_create_queue(display); + if (!queue) { + LOGE("failed to create wl display queue"); + ret = CAMERA_ERROR_INVALID_OPERATION; + goto _DONE; + } + + wl_proxy_set_queue((struct wl_proxy *)display_wrapper, queue); + + registry = wl_display_get_registry(display_wrapper); if (!registry) { LOGE("failed to get wayland registry"); ret = CAMERA_ERROR_INVALID_OPERATION; @@ -157,8 +175,8 @@ int _camera_get_wl_info(Evas_Object *obj, camera_wl_info_s *wl_info) wl_registry_add_listener(registry, &_camera_wl_registry_listener, &tz_surface); - wl_display_dispatch(display); - wl_display_roundtrip(display); + wl_display_dispatch_queue(display, queue); + wl_display_roundtrip_queue(display, queue); if (!tz_surface) { LOGE("failed to get tizen surface"); @@ -178,7 +196,7 @@ int _camera_get_wl_info(Evas_Object *obj, camera_wl_info_s *wl_info) tizen_resource_add_listener(tz_resource, &_camera_tz_resource_listener, &wl_info->parent_id); - wl_display_roundtrip(display); + wl_display_roundtrip_queue(display, queue); if (wl_info->parent_id > 0) { int rotation = 0; @@ -230,6 +248,16 @@ _DONE: registry = NULL; } + if (queue) { + wl_event_queue_destroy(queue); + queue = NULL; + } + + if (display_wrapper) { + wl_proxy_wrapper_destroy(display_wrapper); + display_wrapper = NULL; + } + return ret; } @@ -407,8 +435,11 @@ static void _camera_msg_send(int api, camera_cb_info_s *cb_info, /*LOGD("send msg %s", msg);*/ - if (cb_info->is_server_connected) + if (cb_info->is_server_connected) { + g_mutex_lock(&cb_info->fd_lock); send_ret = muse_core_ipc_send_msg(cb_info->fd, msg); + g_mutex_unlock(&cb_info->fd_lock); + } if (send_ret < 0) { LOGE("msg send failed"); @@ -469,8 +500,11 @@ static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info, /*LOGD("send msg %s", msg);*/ - if (cb_info->is_server_connected) + if (cb_info->is_server_connected) { + g_mutex_lock(&cb_info->fd_lock); send_ret = muse_core_ipc_send_msg(cb_info->fd, msg); + g_mutex_unlock(&cb_info->fd_lock); + } if (send_ret < 0) { LOGE("msg send failed"); @@ -2070,6 +2104,7 @@ static camera_cb_info_s *_camera_client_callback_new(gint sockfd, bool need_msg_ g_cond_init(&cb_info->api_cond[i]); } + g_mutex_init(&cb_info->fd_lock); g_mutex_init(&cb_info->idle_event_mutex); g_cond_init(&cb_info->idle_event_cond); g_mutex_init(&cb_info->mp_data_mutex); @@ -2125,6 +2160,7 @@ ErrorExit: __destroy_msg_handler_thread(&cb_info->preview_cb_info); __destroy_msg_handler_thread(&cb_info->capture_cb_info); + g_mutex_clear(&cb_info->fd_lock); g_mutex_clear(&cb_info->idle_event_mutex); g_cond_clear(&cb_info->idle_event_cond); g_mutex_clear(&cb_info->mp_data_mutex); @@ -2163,6 +2199,7 @@ static void _camera_client_callback_destroy(camera_cb_info_s *cb_info) __destroy_msg_handler_thread(&cb_info->preview_cb_info); __destroy_msg_handler_thread(&cb_info->capture_cb_info); + g_mutex_clear(&cb_info->fd_lock); g_mutex_clear(&cb_info->idle_event_mutex); g_cond_clear(&cb_info->idle_event_cond); g_mutex_clear(&cb_info->mp_data_mutex); @@ -2669,7 +2706,9 @@ 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[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb; + pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data; value = (count << 16) | interval; CAMERA_MSG_PARAM_SET(param, INT, value); @@ -3064,8 +3103,11 @@ int camera_set_display(camera_h camera, camera_display_type_e type, camera_displ return CAMERA_ERROR_OUT_OF_MEMORY; } - if (pc->cb_info->is_server_connected) + if (pc->cb_info->is_server_connected) { + g_mutex_lock(&pc->cb_info->fd_lock); send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg); + g_mutex_unlock(&pc->cb_info->fd_lock); + } if (send_ret < 0) { LOGE("message send failed"); @@ -4777,8 +4819,11 @@ int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, d return CAMERA_ERROR_OUT_OF_MEMORY; } - if (pc->cb_info->is_server_connected) + if (pc->cb_info->is_server_connected) { + g_mutex_lock(&pc->cb_info->fd_lock); send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg); + g_mutex_unlock(&pc->cb_info->fd_lock); + } if (send_ret < 0) { LOGE("message send failed"); @@ -6446,8 +6491,11 @@ int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, i return CAMERA_ERROR_OUT_OF_MEMORY; } - if (pc->cb_info->is_server_connected) + if (pc->cb_info->is_server_connected) { + g_mutex_lock(&pc->cb_info->fd_lock); send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg); + g_mutex_unlock(&pc->cb_info->fd_lock); + } if (send_ret < 0) { LOGE("message send failed"); |