int camera_create(camera_device_e device, camera_h *camera)
{
int sock_fd = -1;
- char *sndMsg;
+ char *send_msg = NULL;
+ int send_ret = 0;
int ret = CAMERA_ERROR_NONE;
int pid = 0;
camera_cli_s *pc = NULL;
pid = getpid();
- sndMsg = muse_core_msg_json_factory_new(api,
+ send_msg = muse_core_msg_json_factory_new(api,
MUSE_TYPE_INT, "module", muse_module,
MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
MUSE_TYPE_INT, "pid", pid,
0);
- muse_core_ipc_send_msg(sock_fd, sndMsg);
- muse_core_msg_json_factory_free(sndMsg);
+ if (!send_msg) {
+ LOGE("NULL msg");
+ ret = CAMERA_ERROR_OUT_OF_MEMORY;
+ goto ErrorExit;
+ }
+
+ send_ret = muse_core_ipc_send_msg(sock_fd, send_msg);
+
+ muse_core_msg_json_factory_free(send_msg);
+ send_msg = NULL;
+
+ if (send_ret < 0) {
+ LOGE("send msg failed %d", errno);
+ ret = CAMERA_ERROR_INVALID_OPERATION;
+ goto ErrorExit;
+ }
pc = g_new0(camera_cli_s, 1);
if (pc == NULL) {
goto ErrorExit;
}
+ sock_fd = -1;
+
LOGD("cb info : %d", pc->cb_info->fd);
ret = _client_wait_for_cb_return(api, pc->cb_info, CALLBACK_TIME_OUT);
tbm_bufmgr_deinit(bufmgr);
bufmgr = NULL;
+ if (sock_fd > -1) {
+ muse_core_connection_close(sock_fd);
+ sock_fd = -1;
+ }
+
if (pc) {
- _client_callback_destroy(pc->cb_info);
- pc->cb_info = NULL;
+ if (pc->cb_info) {
+ _client_callback_destroy(pc->cb_info);
+ pc->cb_info = NULL;
+ }
g_free(pc);
pc = NULL;
}