static GDBusConnection *g_cam_dev_state_changed_cb_conn;
static guint g_cam_dev_state_changed_cb_subscribe_id;
+
static void __global(void *data, struct wl_registry *registry,
uint32_t name, const char *interface, uint32_t version)
{
}
+static void __camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
+{
+ if (!cb_info ||
+ api < 0 || api >= MUSE_CAMERA_API_MAX) {
+ LOGE("invalid param %p %d", cb_info, api);
+ return;
+ }
+
+ g_mutex_lock(&(cb_info->api_mutex[api]));
+ cb_info->api_waiting[api] += value;
+ g_mutex_unlock(&(cb_info->api_mutex[api]));
+
+ /*LOGD("api %d, value %d, waiting %d",
+ api, value, cb_info->api_waiting[api]);*/
+
+ return;
+}
+
+
static void __camera_device_state_changed_cb(GDBusConnection *connection,
const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
const gchar *signal_name, GVariant *param, gpointer user_data)
/*LOGD("send msg %s", msg);*/
if (cb_info->is_server_connected) {
+ __camera_update_api_waiting(cb_info, api, 1);
+
g_mutex_lock(&cb_info->fd_lock);
send_ret = muse_core_ipc_send_msg(cb_info->fd, msg);
g_mutex_unlock(&cb_info->fd_lock);
*ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
}
+ __camera_update_api_waiting(cb_info, api, -1);
+
muse_core_msg_json_factory_free(msg);
return;
/*LOGD("send msg %s", msg);*/
if (cb_info->is_server_connected) {
+ __camera_update_api_waiting(cb_info, api, 1);
+
g_mutex_lock(&cb_info->fd_lock);
send_ret = muse_core_ipc_send_msg(cb_info->fd, msg);
g_mutex_unlock(&cb_info->fd_lock);
*ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
}
+ __camera_update_api_waiting(cb_info, api, -1);
+
muse_core_msg_json_factory_free(msg);
return;
g_mutex_lock(&cb_info->api_mutex[api]);
if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
- cb_info->api_ret[api] = ret;
- cb_info->api_activating[api] = 1;
+ if (cb_info->api_waiting[api] > 0) {
+ cb_info->api_ret[api] = ret;
+ cb_info->api_activating[api] = 1;
- /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
+ /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
- g_cond_signal(&cb_info->api_cond[api]);
+ g_cond_signal(&cb_info->api_cond[api]);
+ } else {
+ LOGW("no waiting for this api [%d]", api);
+ }
} else {
LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
}
g_mutex_lock(&cb_info->api_mutex[api]);
- cb_info->api_ret[api] = ret;
- cb_info->api_activating[api] = 1;
-
switch (api) {
case MUSE_CAMERA_API_CREATE:
if (ret != CAMERA_ERROR_NONE) {
break;
}
- g_cond_signal(&cb_info->api_cond[api]);
+ if (cb_info->api_waiting[api] > 0) {
+ cb_info->api_ret[api] = ret;
+ cb_info->api_activating[api] = 1;
+
+ g_cond_signal(&cb_info->api_cond[api]);
+ } else {
+ LOGW("no waiting for this api [%d]", api);
+ }
+
g_mutex_unlock(&cb_info->api_mutex[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);
goto ErrorExit;
}
+ cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
+
for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
g_mutex_init(&cb_info->api_mutex[i]);
g_cond_init(&cb_info->api_cond[i]);
LOGD("cb info : %d", pc->cb_info->fd);
ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
+
+ pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
+
if (ret == CAMERA_ERROR_NONE) {
intptr_t handle = 0;
muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
}
if (pc->cb_info->is_server_connected) {
+ __camera_update_api_waiting(pc->cb_info, api, 1);
+
g_mutex_lock(&pc->cb_info->fd_lock);
send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
g_mutex_unlock(&pc->cb_info->fd_lock);
ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
}
+ __camera_update_api_waiting(pc->cb_info, api, -1);
+
muse_core_msg_json_factory_free(msg);
LOGD("wayland parent id : %d, window %d,%d,%dx%d",
}
if (pc->cb_info->is_server_connected) {
+ __camera_update_api_waiting(pc->cb_info, api, 1);
+
g_mutex_lock(&pc->cb_info->fd_lock);
send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
g_mutex_unlock(&pc->cb_info->fd_lock);
ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
}
+ __camera_update_api_waiting(pc->cb_info, api, -1);
+
muse_core_msg_json_factory_free(msg);
LOGD("ret : 0x%x", ret);
}
if (pc->cb_info->is_server_connected) {
+ __camera_update_api_waiting(pc->cb_info, api, 1);
+
g_mutex_lock(&pc->cb_info->fd_lock);
send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
g_mutex_unlock(&pc->cb_info->fd_lock);
ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
}
+ __camera_update_api_waiting(pc->cb_info, api, -1);
+
muse_core_msg_json_factory_free(msg);
LOGD("ret : 0x%x", ret);