Remove timeout for handle creation API 48/114848/1
authorJeongmo Yang <jm80.yang@samsung.com>
Thu, 9 Feb 2017 07:18:38 +0000 (16:18 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Wed, 15 Feb 2017 08:40:43 +0000 (17:40 +0900)
In handle creation API, muse camera module checks privilege for camera use,
but it can be stuck for a long time if app does not have camera privilege and there is no feedback for privilege popup.

[Version] 0.2.95
[Profile] Common
[Issue Type] Update
[Dependency module] N/A
[Test] [M(T) - Boot=(OK), sdb=(OK), Home=(OK), Touch=(OK), Version=tizen-3.0-mobile_20170207.1]

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

index f1d3cd5..0fa2f77 100644 (file)
@@ -35,6 +35,7 @@ extern "C" {
 
 #define BUFFER_MAX_PLANE_NUM     4
 #define CAMERA_CB_TIMEOUT        4
+#define CAMERA_CB_NO_TIMEOUT     0
 
 #define CAMERA_MSG_PARAM_SET(param, msg_type, set_value) { \
        param.type = MUSE_TYPE_##msg_type; \
index 23b65d9..c51262d 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-camera
 Summary:    A Camera API
-Version:    0.2.94
+Version:    0.2.95
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 77f7912..a74860f 100644 (file)
@@ -394,15 +394,22 @@ static int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_in
        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->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
+               if (time_out == CAMERA_CB_NO_TIMEOUT) {
+                       LOGW("wait for api %d", api);
+                       g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
                        ret = cb_info->api_ret[api];
                        cb_info->api_activating[api] = 0;
-
-                       /*LOGD("return value : 0x%x", ret);*/
+                       LOGW("api %d returned 0x%x", api, ret);
                } else {
-                       ret = CAMERA_ERROR_INVALID_OPERATION;
-                       LOGE("api %d was TIMED OUT!", api);
+                       end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
+                       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;
+                               LOGE("api %d was TIMED OUT!", api);
+                       }
                }
        } else {
                ret = cb_info->api_ret[api];
@@ -2552,7 +2559,7 @@ int camera_create(camera_device_e device, camera_h *camera)
 
        LOGD("cb info : %d", pc->cb_info->fd);
 
-       ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
+       ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_NO_TIMEOUT);
 
        pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;