summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeongmo Yang <jm80.yang@samsung.com>2017-10-17 15:44:49 +0900
committerJeongmo Yang <jm80.yang@samsung.com>2017-10-18 16:23:34 +0900
commit00cedaf59f1ffaad57f9a84aee0412e04001d753 (patch)
treea68bf5a713b964bd4007ce4e9ffc1ad873931d8d
parent3c9539556de81516611b0a1d91d61a713743d315 (diff)
downloadcamera-00cedaf59f1ffaad57f9a84aee0412e04001d753.tar.gz
camera-00cedaf59f1ffaad57f9a84aee0412e04001d753.tar.bz2
camera-00cedaf59f1ffaad57f9a84aee0412e04001d753.zip
In some case, event callback could be called after unset by timing. So, this patch is added to prevent the case. [Version] 0.3.8 [Profile] Common [Issue Type] Bug fix [Dependency module] N/A [Test] [M(T) - Boot=(OK), sdb=(OK), Home=(OK), Touch=(OK), Version=tizen-4.0-unified_20171013.1] Change-Id: I997badab7ff8947cc49c7976cd8b5ff3b9009425 Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
-rw-r--r--include/camera_private.h2
-rw-r--r--packaging/capi-media-camera.spec2
-rw-r--r--src/camera.c199
-rw-r--r--test/camera_test.c9
4 files changed, 148 insertions, 64 deletions
diff --git a/include/camera_private.h b/include/camera_private.h
index 582d3d3..3215f82 100644
--- a/include/camera_private.h
+++ b/include/camera_private.h
@@ -137,6 +137,7 @@ typedef struct _camera_cb_info_s {
/* user callback */
gpointer user_cb[MUSE_CAMERA_EVENT_TYPE_NUM];
gpointer user_data[MUSE_CAMERA_EVENT_TYPE_NUM];
+ GMutex user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_NUM];
/* tbm */
tbm_bufmgr bufmgr;
@@ -147,7 +148,6 @@ typedef struct _camera_cb_info_s {
/* preview callback flag */
int preview_cb_flag;
- GMutex preview_cb_mutex;
/* evas surface */
#ifdef TIZEN_FEATURE_EVAS_RENDERER
diff --git a/packaging/capi-media-camera.spec b/packaging/capi-media-camera.spec
index 6c4825b..ef01eea 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.3.7
+Version: 0.3.8
Release: 0
Group: Multimedia/API
License: Apache-2.0
diff --git a/src/camera.c b/src/camera.c
index bcc0ede..14430e4 100644
--- a/src/camera.c
+++ b/src/camera.c
@@ -1094,25 +1094,20 @@ static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_m
/*LOGD("get camera msg %s, event %d", recv_msg, event);*/
- if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
- if (!(CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) &&
- cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] == NULL &&
- cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] == NULL) {
- /* return preview callback */
- _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info, NULL, 0);
-
- /* return buffer */
- muse_camera_msg_get(tbm_key, recv_msg);
- LOGW("all preview callback from user are NULL - return key %d", tbm_key);
- if (tbm_key > 0) {
- CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
- _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, &param, 0);
- }
+ g_mutex_lock(&cb_info->user_cb_mutex[event]);
+
+ if (cb_info->user_cb[event] == NULL) {
+ if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
+ event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
+ event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
+ event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
+ g_mutex_unlock(&cb_info->user_cb_mutex[event]);
+ LOGW("NULL callback for event %d, return here", event);
return;
+ } else {
+ /* do not return in this case, because return buffer message should be sent. */
+ LOGW("NULL callback for event %d, NOT return here", event);
}
- } else if (cb_info->user_cb[event] == NULL) {
- LOGW("user callback for event %d is not set", event);
- return;
}
switch (event) {
@@ -1233,8 +1228,6 @@ static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_m
}
/* call preview callback */
- g_mutex_lock(&cb_info->preview_cb_mutex);
-
if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
_camera_preview_frame_create(stream, num_buffer_key, buffer_bo_handle, &data_bo_handle, &frame);
@@ -1242,8 +1235,6 @@ static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_m
cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
}
- g_mutex_unlock(&cb_info->preview_cb_mutex);
-
if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
#ifdef TIZEN_FEATURE_EVAS_RENDERER
ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
@@ -1377,7 +1368,7 @@ static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_m
muse_camera_msg_get(count, recv_msg);
muse_camera_msg_get(tbm_key, recv_msg);
- if (count >= 0) {
+ if (count >= 0 && cb_info->user_cb[event]) {
LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key);
if (tbm_key > 0) {
@@ -1392,15 +1383,16 @@ static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_m
/* release bo */
_camera_release_imported_bo(&bo);
-
- /* return buffer */
- if (tbm_key > 0) {
- CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
- _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, &param, 0);
- /*LOGD("return buffer done");*/
- }
} else {
- LOGE("invalid message - count %d, key %d", count, tbm_key);
+ LOGW("skip face detection message [count %d, key %d, cb %p",
+ count, tbm_key, cb_info->user_cb[event]);
+ }
+
+ /* return buffer */
+ if (tbm_key > 0) {
+ CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
+ _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, &param, 0);
+ /*LOGD("return buffer done");*/
}
}
break;
@@ -1508,9 +1500,16 @@ static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_m
break;
}
+ if (cb_info->user_cb[event] == NULL) {
+ LOGW("NULL callback");
+ goto _EVENT_CAPTURE_DONE;
+ }
+
/* import tbm bo and get virtual address */
- if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_main, &bo_main, &bo_main_handle))
- break;
+ if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_main, &bo_main, &bo_main_handle)) {
+ LOGE("failed to import key [%d] for main", tbm_key_main);
+ goto _EVENT_CAPTURE_DONE;
+ }
buf_pos = (unsigned char *)bo_main_handle.ptr;
rImage = (camera_image_data_s *)buf_pos;
@@ -1527,25 +1526,26 @@ static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_m
if (tbm_key_post > 0) {
/* import tbm bo and get virtual address */
- if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_post, &bo_post, &bo_post_handle))
- break;
-
- buf_pos = (unsigned char *)bo_post_handle.ptr;
- rPostview = (camera_image_data_s *)buf_pos;
- LOGD("rPostview->size : %d", rPostview->size);
- rPostview->data = buf_pos + sizeof(camera_image_data_s);
+ if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key_post, &bo_post, &bo_post_handle)) {
+ buf_pos = (unsigned char *)bo_post_handle.ptr;
+ rPostview = (camera_image_data_s *)buf_pos;
+ LOGD("rPostview->size : %d", rPostview->size);
+ rPostview->data = buf_pos + sizeof(camera_image_data_s);
+ } else {
+ LOGE("failed to import key [%d] for postview", tbm_key_post);
+ }
}
if (tbm_key_thumb > 0) {
/* import tbm bo and get virtual address */
- if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_thumb, &bo_thumb, &bo_thumb_handle))
- break;
-
- buf_pos = (unsigned char *)bo_thumb_handle.ptr;
-
- rThumbnail = (camera_image_data_s *)buf_pos;
- LOGD("rThumbnail->size : %d", rThumbnail->size);
- rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
+ if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key_thumb, &bo_thumb, &bo_thumb_handle)) {
+ buf_pos = (unsigned char *)bo_thumb_handle.ptr;
+ rThumbnail = (camera_image_data_s *)buf_pos;
+ LOGD("rThumbnail->size : %d", rThumbnail->size);
+ rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
+ } else {
+ LOGE("failed to import key [%d] for thumbnail", tbm_key_thumb);
+ }
}
((camera_capturing_cb)cb_info->user_cb[event])(rImage, rPostview, rThumbnail, cb_info->user_data[event]);
@@ -1553,6 +1553,7 @@ static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_m
/* unmap and unref tbm bo */
_camera_release_imported_bo(&bo_main);
+_EVENT_CAPTURE_DONE:
/* return buffer */
tbm_key = tbm_key_main;
@@ -1586,6 +1587,8 @@ static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_m
break;
}
+ g_mutex_unlock(&cb_info->user_cb_mutex[event]);
+
return;
}
@@ -2083,6 +2086,11 @@ static void *_camera_msg_recv_func(gpointer data)
LOGW("incompleted message [len %d]", remained_length);
+ if (remained_msg) {
+ free(remained_msg);
+ remained_msg = NULL;
+ }
+
remained_msg = (char *)malloc(remained_length + 1);
if (remained_msg) {
strncpy(remained_msg, recv_msg + prev_pos, remained_length);
@@ -2240,11 +2248,13 @@ static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
g_mutex_init(&cb_info->idle_event_mutex);
g_cond_init(&cb_info->idle_event_cond);
g_mutex_init(&cb_info->mp_data_mutex);
- g_mutex_init(&cb_info->preview_cb_mutex);
#ifdef TIZEN_FEATURE_EVAS_RENDERER
g_mutex_init(&cb_info->evas_mutex);
#endif /* TIZEN_FEATURE_EVAS_RENDERER */
+ for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
+ g_mutex_init(&cb_info->user_cb_mutex[i]);
+
/* message handler thread */
if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
@@ -2291,11 +2301,13 @@ ErrorExit:
__destroy_msg_handler_thread(&cb_info->preview_cb_info);
__destroy_msg_handler_thread(&cb_info->capture_cb_info);
+ for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
+ g_mutex_clear(&cb_info->user_cb_mutex[i]);
+
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);
- g_mutex_clear(&cb_info->preview_cb_mutex);
#ifdef TIZEN_FEATURE_EVAS_RENDERER
g_mutex_clear(&cb_info->evas_mutex);
#endif /* TIZEN_FEATURE_EVAS_RENDERER */
@@ -2330,11 +2342,13 @@ 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);
+ for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
+ g_mutex_clear(&cb_info->user_cb_mutex[i]);
+
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);
- g_mutex_clear(&cb_info->preview_cb_mutex);
#ifdef TIZEN_FEATURE_EVAS_RENDERER
g_mutex_clear(&cb_info->evas_mutex);
#endif /* TIZEN_FEATURE_EVAS_RENDERER */
@@ -2995,11 +3009,17 @@ int camera_start_face_detection(camera_h camera, camera_face_detected_cb callbac
LOGD("Enter");
- pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
- pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
-
_camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
+
+ pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
+ }
+
LOGD("ret : 0x%x", ret);
return ret;
@@ -3020,6 +3040,15 @@ int camera_stop_face_detection(camera_h camera)
_camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
+
+ pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
+ }
+
LOGD("ret : 0x%x", ret);
return ret;
@@ -3796,12 +3825,12 @@ int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *use
_camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
if (ret == CAMERA_ERROR_NONE) {
- g_mutex_lock(&pc->cb_info->preview_cb_mutex);
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
- g_mutex_unlock(&pc->cb_info->preview_cb_mutex);
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
}
@@ -3828,12 +3857,12 @@ int camera_unset_preview_cb(camera_h camera)
_camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
if (ret == CAMERA_ERROR_NONE) {
- g_mutex_lock(&pc->cb_info->preview_cb_mutex);
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
- g_mutex_unlock(&pc->cb_info->preview_cb_mutex);
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
}
@@ -3870,8 +3899,12 @@ int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_prev
_camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
+
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
}
LOGD("ret : 0x%x", ret);
@@ -3896,8 +3929,12 @@ int camera_unset_media_packet_preview_cb(camera_h camera)
_camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
+
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
}
LOGD("ret : 0x%x", ret);
@@ -3922,8 +3959,12 @@ int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callbac
_camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
+
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
}
LOGD("ret : 0x%x", ret);
@@ -3948,8 +3989,12 @@ int camera_unset_state_changed_cb(camera_h camera)
_camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
+
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
}
LOGD("ret : 0x%x", ret);
@@ -3974,8 +4019,12 @@ int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, v
_camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
+
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
}
LOGD("ret : 0x%x", ret);
@@ -4000,8 +4049,12 @@ int camera_unset_interrupted_cb(camera_h camera)
_camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
+
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
}
LOGD("ret : 0x%x", ret);
@@ -4026,8 +4079,12 @@ int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb
_camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
+
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
}
LOGD("ret : 0x%x", ret);
@@ -4052,8 +4109,12 @@ int camera_unset_interrupt_started_cb(camera_h camera)
_camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
+
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
}
LOGD("ret : 0x%x", ret);
@@ -4078,8 +4139,12 @@ int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callbac
_camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
+
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
}
LOGD("ret : 0x%x", ret);
@@ -4104,8 +4169,12 @@ int camera_unset_focus_changed_cb(camera_h camera)
_camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
+
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
}
LOGD("ret : 0x%x", ret);
@@ -4130,8 +4199,12 @@ int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_da
_camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
+
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
}
LOGD("ret : 0x%x", ret);
@@ -4156,8 +4229,12 @@ int camera_unset_error_cb(camera_h camera)
_camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
+
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
}
LOGD("ret : 0x%x", ret);
@@ -6050,8 +6127,12 @@ int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_pro
_camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
+
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
}
LOGD("ret : 0x%x", ret);
@@ -6076,8 +6157,12 @@ int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
_camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
+
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
}
LOGD("ret : 0x%x", ret);
diff --git a/test/camera_test.c b/test/camera_test.c
index d872bb4..95d5b80 100644
--- a/test/camera_test.c
+++ b/test/camera_test.c
@@ -762,6 +762,8 @@ static void print_menu()
static void main_menu(gchar buf)
{
int err = 0;
+ int interval = 0;
+ int count = 0;
camera_state_e capi_state = CAMERA_STATE_NONE;
switch (buf) {
@@ -775,7 +777,6 @@ static void main_menu(gchar buf)
case '2': /* multishot Capture */
g_print("multishot capture");
hcamcorder->is_multishot = TRUE;
- int interval = 0, count = 0;
flush_stdin();
g_print("\n\tinput interval(ms) : ");
err = scanf("%d", &interval);
@@ -847,6 +848,7 @@ static void setting_menu(gchar buf)
int y = 0;
int width = 0;
int height = 0;
+ int result = 0;
switch (buf) {
/* Camera setting */
@@ -860,7 +862,6 @@ static void setting_menu(gchar buf)
flush_stdin();
err = scanf("%d", &idx);
- int result = 0;
if (resolution_list.count > idx && idx >= 0) {
g_print("-----------------PREVIEW RESOLUTION (%dx%d)---------------------\n",
resolution_list.width[idx], resolution_list.height[idx]);
@@ -1247,6 +1248,7 @@ static void setting_menu(gchar buf)
if (idx == 1) {
g_print("\n Restart preview with NV12 and 720p resolution\n");
err = camera_stop_preview(hcamcorder->camera);
+ g_print("stop preview result 0x%x\n", err);
camera_set_preview_resolution(hcamcorder->camera, 1280, 720);
camera_set_preview_format(hcamcorder->camera, CAMERA_PIXEL_FORMAT_NV12);
}
@@ -1380,11 +1382,9 @@ static gboolean mode_change(gchar buf)
switch (buf) {
case '1':
hcamcorder->type = cam_info = CAMERA_DEVICE_CAMERA1;
- check = TRUE;
break;
case '2':
hcamcorder->type = cam_info = CAMERA_DEVICE_CAMERA0;
- check = TRUE;
break;
case '3':
err = camera_add_device_state_changed_cb(_camera_device_state_changed_cb,
@@ -1428,7 +1428,6 @@ static gboolean mode_change(gchar buf)
return -1;
}
- check = FALSE;
while (!check) {
g_print("\n\tEnter the Display Type\n");
g_print("\t'1' OVERLAY surface\n");