}
-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;
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;
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) {
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;
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;