Update for wayland API usage and etc 51/92451/3 accepted/tizen/3.0/ivi/20161028.123119 accepted/tizen/3.0/mobile/20161028.122348 accepted/tizen/3.0/tv/20161028.122652 accepted/tizen/3.0/wearable/20161028.122850 accepted/tizen/common/20161019.145744 accepted/tizen/ivi/20161019.141543 accepted/tizen/mobile/20161019.141354 accepted/tizen/tv/20161019.141449 accepted/tizen/wearable/20161019.141518 submit/tizen/20161019.084351 submit/tizen_3.0/20161028.062323 submit/tizen_3.0/20161028.082323
authorJeongmo Yang <jm80.yang@samsung.com>
Mon, 17 Oct 2016 05:09:46 +0000 (14:09 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Mon, 17 Oct 2016 05:27:09 +0000 (14:27 +0900)
1. Change wayland API for multithreading environment
2. Set user data for capture completed callback in case of continuous capture mode
3. Add lock for socket API

[Version] 0.2.78
[Profile] Common
[Issue Type] Update and bug fix
[Dependency module] N/A
[Dependency commit] N/A
[Test] [M(T) - Boot=(OK), sdb=(OK), Home=(OK), Touch=(OK), Version=tizen-mobile_20161016.2]

Change-Id: I7333131c675dfd317687a15fb81a492dc65fb20f
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
include/camera_private.h
packaging/capi-media-camera.spec
src/camera.c

index 7cbd9e1..747b6c4 100644 (file)
@@ -108,6 +108,7 @@ typedef struct _camera_msg_handler_info_s {
 typedef struct _camera_cb_info_s {
        /* server connection */
        gint fd;
+       GMutex fd_lock;
        gboolean is_server_connected;
 
        /* message receive thread */
index 2a21d0b..22da559 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-camera
 Summary:    A Camera API
-Version:    0.2.77
+Version:    0.2.78
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index d0f8419..f368341 100644 (file)
@@ -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");