summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeongmo Yang <jm80.yang@samsung.com>2016-10-17 14:09:46 +0900
committerJeongmo Yang <jm80.yang@samsung.com>2016-10-17 14:27:09 +0900
commit2ef267dba0b2bab5461dd008f9ae51e818b5eb29 (patch)
tree5854c6d806adef4e1f4c3bf9a1501e755bb5b80f
parentce837d81660c8df716a92afe5aadb02c35e40d16 (diff)
downloadcamera-2ef267dba0b2bab5461dd008f9ae51e818b5eb29.tar.gz
camera-2ef267dba0b2bab5461dd008f9ae51e818b5eb29.tar.bz2
camera-2ef267dba0b2bab5461dd008f9ae51e818b5eb29.zip
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>
-rw-r--r--include/camera_private.h1
-rw-r--r--packaging/capi-media-camera.spec2
-rw-r--r--src/camera.c66
3 files changed, 59 insertions, 10 deletions
diff --git a/include/camera_private.h b/include/camera_private.h
index 7cbd9e1..747b6c4 100644
--- a/include/camera_private.h
+++ b/include/camera_private.h
@@ -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 */
diff --git a/packaging/capi-media-camera.spec b/packaging/capi-media-camera.spec
index 2a21d0b..22da559 100644
--- a/packaging/capi-media-camera.spec
+++ b/packaging/capi-media-camera.spec
@@ -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
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");