summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/camera_private.h8
-rw-r--r--packaging/capi-media-camera.spec2
-rw-r--r--src/camera.c235
3 files changed, 108 insertions, 137 deletions
diff --git a/include/camera_private.h b/include/camera_private.h
index ae540d0..ed4ae18 100644
--- a/include/camera_private.h
+++ b/include/camera_private.h
@@ -127,7 +127,7 @@ typedef struct _camera_msg_handler_info_s {
void *cb_info;
int running;
GCond cond;
- GMutex mutex;
+ GMutex lock;
GQueue *queue;
GThread *thread;
} camera_msg_handler_info_s;
@@ -157,7 +157,7 @@ typedef struct _camera_cb_info_s {
gint msg_recv_running;
gchar recv_msg[MUSE_MSG_MAX_LENGTH + 1];
GCond api_cond[MUSE_CAMERA_API_MAX];
- GMutex api_mutex[MUSE_CAMERA_API_MAX];
+ GMutex api_lock[MUSE_CAMERA_API_MAX];
gint api_activating[MUSE_CAMERA_API_MAX];
gint api_waiting[MUSE_CAMERA_API_MAX];
gint api_ret[MUSE_CAMERA_API_MAX];
@@ -177,7 +177,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];
+ GMutex user_cb_lock[MUSE_CAMERA_EVENT_TYPE_NUM];
gboolean invoke_preview_cb;
/* tbm */
@@ -188,7 +188,7 @@ typedef struct _camera_cb_info_s {
/* media packet */
media_format_h pkt_fmt;
- GMutex mp_data_mutex;
+ GMutex mp_data_lock;
/* preview */
camera_pixel_format_e preview_format;
diff --git a/packaging/capi-media-camera.spec b/packaging/capi-media-camera.spec
index 9e3a99e..ac211a6 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.4.116
+Version: 0.4.117
Release: 0
Group: Multimedia/API
License: Apache-2.0
diff --git a/src/camera.c b/src/camera.c
index 9c44551..66861d1 100644
--- a/src/camera.c
+++ b/src/camera.c
@@ -202,9 +202,9 @@ void _camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
return;
}
- g_mutex_lock(&(cb_info->api_mutex[api]));
+ g_mutex_lock(&(cb_info->api_lock[api]));
cb_info->api_waiting[api] += value;
- g_mutex_unlock(&(cb_info->api_mutex[api]));
+ g_mutex_unlock(&(cb_info->api_lock[api]));
CAM_LOG_DEBUG("api[%d], value[%d], waiting[%d]",
api, value, cb_info->api_waiting[api]);
@@ -220,12 +220,11 @@ static void __camera_device_state_changed_cb(GDBusConnection *connection,
camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
GList *tmp_list = NULL;
camera_cb_info *info = NULL;
-
- g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
+ g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&g_cam_dev_state_changed_cb_lock);
if (!g_cam_dev_state_changed_cb_list || !param) {
CAM_LOG_WARNING("no callback or NULL param %p", param);
- goto _DONE;
+ return;
}
/* get device and state */
@@ -253,9 +252,6 @@ static void __camera_device_state_changed_cb(GDBusConnection *connection,
tmp_list = tmp_list->next;
} while (tmp_list);
-
-_DONE:
- g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
}
@@ -891,14 +887,13 @@ int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *c
{
int ret = CAMERA_ERROR_NONE;
gint64 end_time;
+ g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&cb_info->api_lock[api]);
if (!cb_info->is_server_connected) {
CAM_LOG_ERROR("server is disconnected");
return CAMERA_ERROR_SERVICE_DISCONNECTED;
}
- g_mutex_lock(&(cb_info->api_mutex[api]));
-
CAM_LOG_INFO("api[%d] timeout[%ds] START:activating[%d]",
api, time_out, cb_info->api_activating[api]);
@@ -906,17 +901,16 @@ int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *c
while (cb_info->api_activating[api] <= 0) {
if (time_out == CAMERA_CB_NO_TIMEOUT) {
- g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
+ g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_lock[api]));
CAM_LOG_WARNING("api[%d] returned[0x%x]", api, cb_info->api_ret[api]);
- } else if (!g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
+ } else if (!g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_lock[api]), end_time)) {
CAM_LOG_ERROR("api[%d] TIMED OUT!", api);
- ret = CAMERA_ERROR_INVALID_OPERATION;
- goto _CB_RETURN_END;
+ return CAMERA_ERROR_INVALID_OPERATION;
}
if (!cb_info->is_server_connected) {
- ret = CAMERA_ERROR_SERVICE_DISCONNECTED;
- goto _CB_RETURN_END;
+ CAM_LOG_ERROR("server is disconnected");
+ return CAMERA_ERROR_SERVICE_DISCONNECTED;
}
if (cb_info->api_activating[api] <= 0)
@@ -933,11 +927,8 @@ int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *c
api, cb_info->api_activating[api]);
}
-_CB_RETURN_END:
- g_mutex_unlock(&(cb_info->api_mutex[api]));
-
if (ret != CAMERA_ERROR_NONE)
- CAM_LOG_ERROR("api %d : error 0x%x", api, ret);
+ CAM_LOG_ERROR("api[%d] : error 0x%x", api, ret);
return ret;
}
@@ -1528,15 +1519,16 @@ void _camera_media_packet_dispose(media_packet_h pkt, void *user_data)
if (tsurf)
tbm_surface_destroy(tsurf);
- g_mutex_lock(&cb_info->mp_data_mutex);
+ g_mutex_lock(&cb_info->mp_data_lock);
__camera_release_media_packet_data(mp_data, cb_info);
- g_mutex_unlock(&cb_info->mp_data_mutex);
+ g_mutex_unlock(&cb_info->mp_data_lock);
}
static void __camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event, int *tfd)
{
int param1 = 0;
int param2 = 0;
+ g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&cb_info->user_cb_lock[event]);
if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
CAM_LOG_ERROR("invalid parameter - camera msg %p, event %d", recv_msg, event);
@@ -1545,14 +1537,11 @@ static void __camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_
CAM_LOG_DEBUG("get camera msg[%s], event[%d]", recv_msg, event);
- 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]);
CAM_LOG_WARNING("NULL callback for event %d, return here", event);
return;
}
@@ -1724,8 +1713,6 @@ static void __camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_
CAM_LOG_WARNING("unhandled event %d", event);
break;
}
-
- g_mutex_unlock(&cb_info->user_cb_mutex[event]);
}
static gboolean __camera_idle_event_callback(gpointer data)
@@ -1786,12 +1773,12 @@ static gpointer __camera_msg_handler_func(gpointer data)
CAM_LOG_INFO("t:%d start[thread:%p]", type, thread);
- g_mutex_lock(&handler_info->mutex);
+ g_mutex_lock(&handler_info->lock);
while (g_atomic_int_get(&handler_info->running)) {
if (g_queue_is_empty(handler_info->queue)) {
CAM_LOG_VERBOSE("t[%d] signal wait...", type);
- g_cond_wait(&handler_info->cond, &handler_info->mutex);
+ g_cond_wait(&handler_info->cond, &handler_info->lock);
CAM_LOG_VERBOSE("t[%d] signal received", type);
if (g_atomic_int_get(&handler_info->running) == 0) {
@@ -1802,11 +1789,11 @@ static gpointer __camera_msg_handler_func(gpointer data)
cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
- g_mutex_unlock(&handler_info->mutex);
+ g_mutex_unlock(&handler_info->lock);
if (cam_msg == NULL) {
CAM_LOG_ERROR("t:%d NULL message", type);
- g_mutex_lock(&handler_info->mutex);
+ g_mutex_lock(&handler_info->lock);
continue;
}
@@ -1815,7 +1802,7 @@ static gpointer __camera_msg_handler_func(gpointer data)
if (api < MUSE_CAMERA_API_MAX) {
int ret = 0;
- g_mutex_lock(&cb_info->api_mutex[api]);
+ g_mutex_lock(&cb_info->api_lock[api]);
if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
if (cb_info->api_waiting[api] > 0) {
@@ -1840,7 +1827,7 @@ static gpointer __camera_msg_handler_func(gpointer data)
CAM_LOG_ERROR("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
}
- g_mutex_unlock(&cb_info->api_mutex[api]);
+ g_mutex_unlock(&cb_info->api_lock[api]);
} else if (api == MUSE_CAMERA_CB_EVENT) {
if (cam_msg->event == MUSE_CAMERA_EVENT_TYPE_INTERRUPTED) {
CAM_LOG_WARNING("INTERRUPTED, release thread for preview cb");
@@ -1886,7 +1873,7 @@ static gpointer __camera_msg_handler_func(gpointer data)
g_free(cam_msg);
- g_mutex_lock(&handler_info->mutex);
+ g_mutex_lock(&handler_info->lock);
}
/* remove remained event */
@@ -1901,7 +1888,7 @@ static gpointer __camera_msg_handler_func(gpointer data)
}
}
- g_mutex_unlock(&handler_info->mutex);
+ g_mutex_unlock(&handler_info->lock);
CAM_LOG_INFO("t:%d return[thread:%p]", type, thread);
@@ -1913,17 +1900,15 @@ static void __camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
{
camera_idle_event_s *cam_idle_event = NULL;
GList *list = NULL;
+ g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&g_cam_idle_event_lock);
if (cb_info == NULL) {
CAM_LOG_ERROR("cb_info is NULL");
return;
}
- g_mutex_lock(&g_cam_idle_event_lock);
-
if (cb_info->idle_event_list == NULL) {
CAM_LOG_INFO("No remained idle event");
- g_mutex_unlock(&g_cam_idle_event_lock);
return;
}
@@ -1958,8 +1943,6 @@ static void __camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
g_list_free(cb_info->idle_event_list);
cb_info->idle_event_list = NULL;
-
- g_mutex_unlock(&g_cam_idle_event_lock);
}
@@ -2001,20 +1984,20 @@ static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int ev
}
}
- g_mutex_lock(&cb_info->preview_cb_info.mutex);
+ g_mutex_lock(&cb_info->preview_cb_info.lock);
g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
g_cond_signal(&cb_info->preview_cb_info.cond);
- g_mutex_unlock(&cb_info->preview_cb_info.mutex);
+ g_mutex_unlock(&cb_info->preview_cb_info.lock);
} else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
- g_mutex_lock(&cb_info->capture_cb_info.mutex);
+ g_mutex_lock(&cb_info->capture_cb_info.lock);
g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
g_cond_signal(&cb_info->capture_cb_info.cond);
- g_mutex_unlock(&cb_info->capture_cb_info.mutex);
+ g_mutex_unlock(&cb_info->capture_cb_info.lock);
} else {
- g_mutex_lock(&cb_info->msg_handler_info.mutex);
+ g_mutex_lock(&cb_info->msg_handler_info.lock);
g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
g_cond_signal(&cb_info->msg_handler_info.cond);
- g_mutex_unlock(&cb_info->msg_handler_info.mutex);
+ g_mutex_unlock(&cb_info->msg_handler_info.lock);
}
cam_msg = NULL;
@@ -2067,7 +2050,7 @@ static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg, int *tfd)
return;
}
- g_mutex_lock(&cb_info->api_mutex[api]);
+ g_mutex_lock(&cb_info->api_lock[api]);
switch (api) {
case MUSE_CAMERA_API_CREATE:
@@ -2155,7 +2138,7 @@ static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg, int *tfd)
CAM_LOG_WARNING("no waiting for this api [%d]", api);
}
- g_mutex_unlock(&cb_info->api_mutex[api]);
+ g_mutex_unlock(&cb_info->api_lock[api]);
} else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
__camera_add_msg_to_queue(cb_info, api, event, event_class, msg, tfd);
} else {
@@ -2261,7 +2244,7 @@ static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
return false;
}
- g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&handler_info->mutex);
+ g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&handler_info->lock);
if (handler_info->thread) {
CAM_LOG_WARNING("t:%d thread[%p] is already created", type, handler_info->thread);
@@ -2306,7 +2289,7 @@ static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info
return;
}
- g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&handler_info->mutex);
+ g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&handler_info->lock);
if (!handler_info->thread) {
CAM_LOG_WARNING("thread[t:%d] is not created", handler_info->type);
@@ -2342,20 +2325,20 @@ static void __camera_mutex_cond_init(camera_cb_info_s *cb_info)
}
for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
- g_mutex_init(&cb_info->api_mutex[i]);
+ g_mutex_init(&cb_info->api_lock[i]);
g_cond_init(&cb_info->api_cond[i]);
}
for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
- g_mutex_init(&cb_info->user_cb_mutex[i]);
+ g_mutex_init(&cb_info->user_cb_lock[i]);
g_mutex_init(&cb_info->fd_lock);
- g_mutex_init(&cb_info->mp_data_mutex);
+ g_mutex_init(&cb_info->mp_data_lock);
g_mutex_init(&cb_info->bridge_lock);
- g_mutex_init(&cb_info->msg_handler_info.mutex);
- g_mutex_init(&cb_info->preview_cb_info.mutex);
- g_mutex_init(&cb_info->capture_cb_info.mutex);
+ g_mutex_init(&cb_info->msg_handler_info.lock);
+ g_mutex_init(&cb_info->preview_cb_info.lock);
+ g_mutex_init(&cb_info->capture_cb_info.lock);
g_cond_init(&cb_info->msg_handler_info.cond);
g_cond_init(&cb_info->preview_cb_info.cond);
g_cond_init(&cb_info->capture_cb_info.cond);
@@ -2373,22 +2356,22 @@ static void __camera_mutex_cond_clear(camera_cb_info_s *cb_info)
return;
}
- g_mutex_clear(&cb_info->msg_handler_info.mutex);
- g_mutex_clear(&cb_info->preview_cb_info.mutex);
- g_mutex_clear(&cb_info->capture_cb_info.mutex);
+ g_mutex_clear(&cb_info->msg_handler_info.lock);
+ g_mutex_clear(&cb_info->preview_cb_info.lock);
+ g_mutex_clear(&cb_info->capture_cb_info.lock);
g_cond_clear(&cb_info->msg_handler_info.cond);
g_cond_clear(&cb_info->preview_cb_info.cond);
g_cond_clear(&cb_info->capture_cb_info.cond);
g_mutex_clear(&cb_info->fd_lock);
- g_mutex_clear(&cb_info->mp_data_mutex);
+ g_mutex_clear(&cb_info->mp_data_lock);
g_mutex_clear(&cb_info->bridge_lock);
for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
- g_mutex_clear(&cb_info->user_cb_mutex[i]);
+ g_mutex_clear(&cb_info->user_cb_lock[i]);
for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
- g_mutex_clear(&cb_info->api_mutex[i]);
+ g_mutex_clear(&cb_info->api_lock[i]);
g_cond_clear(&cb_info->api_cond[i]);
}
@@ -3166,12 +3149,12 @@ int camera_start_face_detection(camera_h camera, camera_face_detected_cb callbac
_camera_msg_send(api, NULL, 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]);
+ g_mutex_lock(&pc->cb_info->user_cb_lock[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]);
+ g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
}
CAM_LOG_INFO("ret : 0x%x", ret);
@@ -3192,12 +3175,12 @@ int camera_stop_face_detection(camera_h camera)
_camera_msg_send(api, NULL, 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]);
+ g_mutex_lock(&pc->cb_info->user_cb_lock[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]);
+ g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
}
CAM_LOG_INFO("ret : 0x%x", ret);
@@ -3856,12 +3839,12 @@ int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *use
_camera_msg_send(api, NULL, 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_PREVIEW]);
+ g_mutex_lock(&pc->cb_info->user_cb_lock[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->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
+ g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
}
CAM_LOG_INFO("ret : 0x%x", ret);
@@ -3883,12 +3866,12 @@ int camera_unset_preview_cb(camera_h camera)
_camera_msg_send(api, NULL, 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_PREVIEW]);
+ g_mutex_lock(&pc->cb_info->user_cb_lock[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->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
+ g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
}
CAM_LOG_INFO("ret : 0x%x", ret);
@@ -3920,12 +3903,12 @@ int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_prev
_camera_msg_send(api, NULL, 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]);
+ g_mutex_lock(&pc->cb_info->user_cb_lock[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]);
+ g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
}
CAM_LOG_INFO("ret : 0x%x", ret);
@@ -3952,12 +3935,12 @@ int camera_unset_media_packet_preview_cb(camera_h camera)
_camera_msg_send(api, NULL, 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]);
+ g_mutex_lock(&pc->cb_info->user_cb_lock[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]);
+ g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
}
CAM_LOG_INFO("ret : 0x%x", ret);
@@ -3982,12 +3965,12 @@ int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callbac
_camera_msg_send(api, NULL, 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]);
+ g_mutex_lock(&pc->cb_info->user_cb_lock[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]);
+ g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
}
CAM_LOG_INFO("ret : 0x%x", ret);
@@ -4009,12 +3992,12 @@ int camera_unset_state_changed_cb(camera_h camera)
_camera_msg_send(api, NULL, 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]);
+ g_mutex_lock(&pc->cb_info->user_cb_lock[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]);
+ g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
}
CAM_LOG_INFO("ret : 0x%x", ret);
@@ -4039,12 +4022,12 @@ int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, v
_camera_msg_send(api, NULL, 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]);
+ g_mutex_lock(&pc->cb_info->user_cb_lock[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]);
+ g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
}
CAM_LOG_INFO("ret : 0x%x", ret);
@@ -4066,12 +4049,12 @@ int camera_unset_interrupted_cb(camera_h camera)
_camera_msg_send(api, NULL, 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]);
+ g_mutex_lock(&pc->cb_info->user_cb_lock[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]);
+ g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
}
CAM_LOG_INFO("ret : 0x%x", ret);
@@ -4096,12 +4079,12 @@ int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb
_camera_msg_send(api, NULL, 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]);
+ g_mutex_lock(&pc->cb_info->user_cb_lock[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]);
+ g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
}
CAM_LOG_INFO("ret : 0x%x", ret);
@@ -4123,12 +4106,12 @@ int camera_unset_interrupt_started_cb(camera_h camera)
_camera_msg_send(api, NULL, 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]);
+ g_mutex_lock(&pc->cb_info->user_cb_lock[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]);
+ g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
}
CAM_LOG_INFO("ret : 0x%x", ret);
@@ -4153,12 +4136,12 @@ int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callbac
_camera_msg_send(api, NULL, 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]);
+ g_mutex_lock(&pc->cb_info->user_cb_lock[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]);
+ g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
}
CAM_LOG_INFO("ret : 0x%x", ret);
@@ -4180,12 +4163,12 @@ int camera_unset_focus_changed_cb(camera_h camera)
_camera_msg_send(api, NULL, 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]);
+ g_mutex_lock(&pc->cb_info->user_cb_lock[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]);
+ g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
}
CAM_LOG_INFO("ret : 0x%x", ret);
@@ -4210,12 +4193,12 @@ int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_da
_camera_msg_send(api, NULL, 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]);
+ g_mutex_lock(&pc->cb_info->user_cb_lock[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]);
+ g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_ERROR]);
}
CAM_LOG_INFO("ret : 0x%x", ret);
@@ -4237,12 +4220,12 @@ int camera_unset_error_cb(camera_h camera)
_camera_msg_send(api, NULL, 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]);
+ g_mutex_lock(&pc->cb_info->user_cb_lock[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]);
+ g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_ERROR]);
}
CAM_LOG_INFO("ret : 0x%x", ret);
@@ -5972,12 +5955,12 @@ int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_pro
_camera_msg_send(api, NULL, 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]);
+ g_mutex_lock(&pc->cb_info->user_cb_lock[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]);
+ g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
}
CAM_LOG_INFO("ret : 0x%x", ret);
@@ -5999,12 +5982,12 @@ int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
_camera_msg_send(api, NULL, 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]);
+ g_mutex_lock(&pc->cb_info->user_cb_lock[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]);
+ g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
}
CAM_LOG_INFO("ret : 0x%x", ret);
@@ -6394,6 +6377,7 @@ int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback,
int ret = CAMERA_ERROR_NONE;
camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
camera_cb_info *info = NULL;
+ g_autoptr(GMutexLocker) locker = NULL;
if (!callback || !cb_id) {
CAM_LOG_ERROR("invalid pointer %p %p", callback, cb_id);
@@ -6407,13 +6391,12 @@ int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback,
return ret;
}
- g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
+ locker = g_mutex_locker_new(&g_cam_dev_state_changed_cb_lock);
info = g_new0(camera_cb_info, 1);
if (!info) {
CAM_LOG_ERROR("info failed");
- ret = CAMERA_ERROR_OUT_OF_MEMORY;
- goto _DONE;
+ return CAMERA_ERROR_OUT_OF_MEMORY;
}
info->id = ++g_cam_dev_state_changed_cb_id;
@@ -6465,8 +6448,6 @@ _DONE:
}
}
- g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
-
return ret;
}
@@ -6477,6 +6458,7 @@ int camera_remove_device_state_changed_cb(int cb_id)
camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
GList *tmp_list = NULL;
camera_cb_info *info = NULL;
+ g_autoptr(GMutexLocker) locker = NULL;
/* check camera support */
ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
@@ -6485,12 +6467,11 @@ int camera_remove_device_state_changed_cb(int cb_id)
return ret;
}
- g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
+ locker = g_mutex_locker_new(&g_cam_dev_state_changed_cb_lock);
if (!g_cam_dev_state_changed_cb_list) {
CAM_LOG_ERROR("there is no callback info");
- ret = CAMERA_ERROR_INVALID_OPERATION;
- goto _DONE;
+ return CAMERA_ERROR_INVALID_OPERATION;
}
tmp_list = g_cam_dev_state_changed_cb_list;
@@ -6526,17 +6507,13 @@ int camera_remove_device_state_changed_cb(int cb_id)
CAM_LOG_INFO("id %d callback removed", cb_id);
ret = CAMERA_ERROR_NONE;
- goto _DONE;
+ return CAMERA_ERROR_NONE;
}
} while (tmp_list);
CAM_LOG_ERROR("id %d callback not found", cb_id);
- ret = CAMERA_ERROR_INVALID_PARAMETER;
-_DONE:
- g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
-
- return ret;
+ return CAMERA_ERROR_INVALID_PARAMETER;
}
@@ -6546,31 +6523,28 @@ int camera_media_bridge_set_bridge(camera_h camera, media_bridge_h bridge)
int ret = CAMERA_ERROR_NONE;
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_BRIDGE;
+ g_autoptr(GMutexLocker) locker = NULL;
CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
- g_mutex_lock(&pc->cb_info->bridge_lock);
+ locker = g_mutex_locker_new(&pc->cb_info->bridge_lock);
if (pc->cb_info->bridge) {
CAM_LOG_ERROR("media bridge[%p] is already set", pc->cb_info->bridge);
- ret = CAMERA_ERROR_INVALID_OPERATION;
- goto _SET_MEDIA_BRIDGE_DONE;
+ return CAMERA_ERROR_INVALID_OPERATION;
}
_camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
if (ret != CAMERA_ERROR_NONE) {
CAM_LOG_ERROR("set media bridge failed[0x%x]", ret);
- goto _SET_MEDIA_BRIDGE_DONE;
+ return ret;
}
pc->cb_info->bridge = bridge;
CAM_LOG_INFO("[%p] set media bridge[%p]", camera, bridge);
-_SET_MEDIA_BRIDGE_DONE:
- g_mutex_unlock(&pc->cb_info->bridge_lock);
-
- return ret;
+ return CAMERA_ERROR_NONE;
}
@@ -6579,31 +6553,28 @@ int camera_media_bridge_unset_bridge(camera_h camera)
int ret = CAMERA_ERROR_NONE;
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_BRIDGE;
+ g_autoptr(GMutexLocker) locker = NULL;
CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
- g_mutex_lock(&pc->cb_info->bridge_lock);
+ locker = g_mutex_locker_new(&pc->cb_info->bridge_lock);
if (!pc->cb_info->bridge) {
CAM_LOG_ERROR("no media bridge");
- ret = CAMERA_ERROR_INVALID_OPERATION;
- goto _UNSET_MEDIA_BRIDGE_DONE;
+ return CAMERA_ERROR_INVALID_OPERATION;
}
_camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
if (ret != CAMERA_ERROR_NONE) {
CAM_LOG_ERROR("unset media bridge failed[0x%x]", ret);
- goto _UNSET_MEDIA_BRIDGE_DONE;
+ return ret;
}
CAM_LOG_INFO("[%p] unset media bridge[%p]", camera, pc->cb_info->bridge);
pc->cb_info->bridge = NULL;
-_UNSET_MEDIA_BRIDGE_DONE:
- g_mutex_unlock(&pc->cb_info->bridge_lock);
-
- return ret;
+ return CAMERA_ERROR_NONE;
}
//LCOV_EXCL_STOP
@@ -6637,12 +6608,12 @@ int camera_set_extra_preview_cb(camera_h camera, camera_extra_preview_cb callbac
_camera_msg_send(api, NULL, 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_EXTRA_PREVIEW]);
+ g_mutex_lock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = callback;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = user_data;
- g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
+ g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
}
CAM_LOG_INFO("ret : 0x%x", ret);
@@ -6669,12 +6640,12 @@ int camera_unset_extra_preview_cb(camera_h camera)
_camera_msg_send(api, NULL, 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_EXTRA_PREVIEW]);
+ g_mutex_lock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = NULL;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = NULL;
- g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
+ g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
}
CAM_LOG_INFO("ret : 0x%x", ret);