#define DATA_WORKER_QDATA_MAX_SIZE (3840 * 2160 * 4) /* UHD BGRA8888 */
#define UNLIMITED_INSTANCE -1
-static GMutex dispatch_lock;
-
-static gboolean _ms_ipc_receive_message(int fd, char *buf, int msg_len);
-static gboolean _ms_ipc_data_processing(int fd, muse_recv_data_head_t *header, muse_channel_info_t *ch);
static void _ms_ipc_module_cleanup(muse_module_h m, void *jobj);
+static gboolean _ms_ipc_module_instance_creation_is_allowed(int module_idx);
static gpointer _ms_ipc_dispatch_worker(gpointer data);
+static gboolean _ms_ipc_receive_message(int fd, char *buf, int msg_len);
+static gboolean _ms_ipc_data_processing(int fd, muse_recv_data_head_t *header, muse_channel_info_t *ch);
static gpointer _ms_ipc_data_worker(gpointer data);
-static gboolean _ms_ipc_module_instance_creation_is_allowed(int module_idx);
static void _ms_ipc_module_cleanup(muse_module_h m, void *jobj)
{
m->disp_api = cmd;
case API_CREATE:
SECURE_LOGI("CREATE %p %d", m, fd);
- g_mutex_lock(&dispatch_lock);
+ ms_module_dispatch_lock(m);
if (muse_core_msg_object_get_value(MSG_KEY_MODULE_INDEX, jobj, MUSE_TYPE_INT, &idx)) {
m->idx = idx;
m->ch[MUSE_CHANNEL_MSG].dll_handle = ms_module_open(idx);
if (!_ms_ipc_module_instance_creation_is_allowed(idx) || !m->ch[MUSE_CHANNEL_MSG].data_thread) {
ms_cmd_dispatch(m, MUSE_MODULE_COMMAND_RESOURCE_NOT_AVAILABLE);
- g_mutex_unlock(&dispatch_lock);
+ ms_module_dispatch_unlock(m);
ms_exit_worker(m);
}
if (muse_core_msg_object_get_value(MSG_KEY_PID, jobj, MUSE_TYPE_INT, &pid) && m->pid != pid)
LOGD("module fd: %d dll_handle: %p", fd, m->ch[MUSE_CHANNEL_MSG].dll_handle);
dispatch_ret = ms_module_dispatch(m, cmd);
}
- g_mutex_unlock(&dispatch_lock);
+ ms_module_dispatch_unlock(m);
if (dispatch_ret != MM_ERROR_NONE) {
LOGE("create dispatch failed 0x%x, clean up module", dispatch_ret);
break;
case API_DESTROY:
SECURE_LOGI("DESTROY %p %d", m, fd);
- g_mutex_lock(&dispatch_lock);
+ ms_module_dispatch_lock(m);
dispatch_ret = ms_module_dispatch(m, cmd);
- g_mutex_unlock(&dispatch_lock);
+ ms_module_dispatch_unlock(m);
if (dispatch_ret == MM_ERROR_NONE)
_ms_ipc_module_cleanup(m, jobj);
else
m->ch[MUSE_CHANNEL_MSG].tbm_fd = tbm_fd[0];
if (!m->is_create_api_called) {
- g_mutex_lock(&dispatch_lock);
+ ms_module_dispatch_lock(m);
if (muse_core_msg_object_get_value(MSG_KEY_MODULE_INDEX, jobj, MUSE_TYPE_INT, &idx)) {
m->idx = idx;
m->ch[MUSE_CHANNEL_MSG].dll_handle = ms_module_open(idx);
if (!_ms_ipc_module_instance_creation_is_allowed(idx)) {
ms_cmd_dispatch(m, MUSE_MODULE_COMMAND_RESOURCE_NOT_AVAILABLE);
- g_mutex_unlock(&dispatch_lock);
+ ms_module_dispatch_unlock(m);
ms_exit_worker(m);
}
ms_connection_register(m);
if (!ms_module_close(m))
SECURE_LOGE("module %p close fail", m);
}
- g_mutex_unlock(&dispatch_lock);
+ ms_module_dispatch_unlock(m);
_ms_ipc_module_cleanup(m, jobj);
}
break;