summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeongmo Yang <jm80.yang@samsung.com>2016-10-28 20:06:44 +0900
committerJeongmo Yang <jm80.yang@samsung.com>2016-10-28 20:06:44 +0900
commitc7c5cfc62a4a5402b45e6bfa148023a60a0e8955 (patch)
tree53449b9a5fa4b26dfb437fb4ca10197969a1e5fd
parentdd7433939a07f2746e4afedce2f2610a0e480f1c (diff)
downloadcamera-c7c5cfc62a4a5402b45e6bfa148023a60a0e8955.tar.gz
camera-c7c5cfc62a4a5402b45e6bfa148023a60a0e8955.tar.bz2
camera-c7c5cfc62a4a5402b45e6bfa148023a60a0e8955.zip
Code optimization for get_device/flash_state function
Previously, message receive thread and unused code is executed. This commit removes them. [Version] 0.2.80 [Profile] Common [Issue Type] Optimization [Dependency module] N/A [Test] [M(T) - Boot=(OK), sdb=(OK), Home=(OK), Touch=(OK), Version=tizen-mobile_20161027.1] Change-Id: I584b337294ddd6155f61b1f7f253159746c47fd3 Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
-rw-r--r--packaging/capi-media-camera.spec2
-rw-r--r--src/camera.c71
2 files changed, 33 insertions, 40 deletions
diff --git a/packaging/capi-media-camera.spec b/packaging/capi-media-camera.spec
index 20b31be..ed21092 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.79
+Version: 0.2.80
Release: 0
Group: Multimedia/API
License: Apache-2.0
diff --git a/src/camera.c b/src/camera.c
index ec8a607..5dabe2c 100644
--- a/src/camera.c
+++ b/src/camera.c
@@ -2093,7 +2093,7 @@ static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info
}
-static camera_cb_info_s *_camera_client_callback_new(gint sockfd, bool need_msg_handler_thread)
+static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
{
camera_cb_info_s *cb_info = NULL;
gint i = 0;
@@ -2119,27 +2119,25 @@ static camera_cb_info_s *_camera_client_callback_new(gint sockfd, bool need_msg_
g_mutex_init(&cb_info->evas_mutex);
#endif /* TIZEN_FEATURE_EVAS_RENDERER */
- if (need_msg_handler_thread) {
- /* message handler thread */
- if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
- CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
- LOGE("msg_handler_info failed");
- goto ErrorExit;
- }
+ /* message handler thread */
+ if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
+ CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
+ LOGE("msg_handler_info failed");
+ goto ErrorExit;
+ }
- /* message handler thread for preview callback */
- if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
- CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
- LOGE("preview_cb_info failed");
- goto ErrorExit;
- }
+ /* message handler thread for preview callback */
+ if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
+ CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
+ LOGE("preview_cb_info failed");
+ goto ErrorExit;
+ }
- /* message handler thread for capture callback */
- if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
- CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
- LOGE("capture_cb_info failed");
- goto ErrorExit;
- }
+ /* message handler thread for capture callback */
+ if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
+ CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
+ LOGE("capture_cb_info failed");
+ goto ErrorExit;
}
cb_info->fd = sockfd;
@@ -2323,10 +2321,9 @@ int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
int _camera_independent_request(int api, int device_type, const char *key, int *value)
{
int ret = CAMERA_ERROR_NONE;
- int send_ret = 0;
int sock_fd = -1;
char *msg = NULL;
- camera_cb_info_s *cb_info = NULL;
+ char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
/* create muse connection */
if (!key || !value) {
@@ -2350,40 +2347,36 @@ int _camera_independent_request(int api, int device_type, const char *key, int *
goto _REQUEST_EXIT;
}
- send_ret = muse_core_ipc_send_msg(sock_fd, msg);
+ ret = muse_core_ipc_send_msg(sock_fd, msg);
muse_core_msg_json_factory_free(msg);
msg = NULL;
- if (send_ret < 0) {
+ if (ret < 0) {
LOGE("send msg failed");
ret = CAMERA_ERROR_INVALID_OPERATION;
goto _REQUEST_EXIT;
}
- cb_info = _camera_client_callback_new(sock_fd, false);
- if (!cb_info) {
- LOGE("cb_info alloc failed");
- ret = CAMERA_ERROR_OUT_OF_MEMORY;
+ ret = muse_core_ipc_recv_msg(sock_fd, recv_msg);
+ if (ret <= 0) {
+ LOGE("recv msg failed %d", errno);
+ ret = CAMERA_ERROR_INVALID_OPERATION;
goto _REQUEST_EXIT;
}
- sock_fd = -1;
-
- ret = _camera_client_wait_for_cb_return(api, cb_info, CAMERA_CB_TIMEOUT);
+ if (!muse_camera_msg_get(ret, recv_msg)) {
+ LOGE("failed to get return value from msg [%s]", recv_msg);
+ ret = CAMERA_ERROR_INVALID_OPERATION;
+ goto _REQUEST_EXIT;
+ }
if (ret == CAMERA_ERROR_NONE)
- muse_core_msg_json_deserialize(key, cb_info->recv_msg, NULL, value, NULL, MUSE_TYPE_ANY);
+ muse_core_msg_json_deserialize(key, recv_msg, NULL, value, NULL, MUSE_TYPE_ANY);
LOGD("api %d - value %d", api, *value);
_REQUEST_EXIT:
- /* release resources */
- if (cb_info) {
- _camera_client_callback_destroy(cb_info);
- cb_info = NULL;
- }
-
if (sock_fd > -1) {
muse_core_connection_close(sock_fd);
sock_fd = -1;
@@ -2458,7 +2451,7 @@ int camera_create(camera_device_e device, camera_h *camera)
goto ErrorExit;
}
- pc->cb_info = _camera_client_callback_new(sock_fd, true);
+ pc->cb_info = _camera_client_callback_new(sock_fd);
if (pc->cb_info == NULL) {
LOGE("cb_info alloc failed");
ret = CAMERA_ERROR_OUT_OF_MEMORY;