#include "voice_control_common.h"
#include "voice_control_key_defines.h"
+static pthread_mutex_t g_cmd_mutex = PTHREAD_MUTEX_INITIALIZER;
+#define CMD_MUTEX_LOCK() pthread_mutex_lock(&g_cmd_mutex)
+#define CMD_MUTEX_UNLOCK() pthread_mutex_unlock(&g_cmd_mutex)
+
static int g_feature_enabled = -1;
static bool g_privilege_allowed = false;
return VC_ERROR_PERMISSION_DENIED;
}
+ CMD_MUTEX_LOCK();
+
if (NULL == vc_command) {
SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL");
+ CMD_MUTEX_UNLOCK();
return VC_ERROR_INVALID_PARAMETER;
}
if (NULL == command) {
SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Not enough memory");
+ CMD_MUTEX_UNLOCK();
return VC_ERROR_OUT_OF_MEMORY;
}
SLOG(LOG_DEBUG, TAG_VCCMD, "[Create command][%p]", *vc_command);
+ CMD_MUTEX_UNLOCK();
return VC_ERROR_NONE;
}
return VC_ERROR_PERMISSION_DENIED;
}
+ CMD_MUTEX_LOCK();
+
if (NULL == vc_command) {
SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL");
+ CMD_MUTEX_UNLOCK();
return VC_ERROR_INVALID_PARAMETER;
}
iter = g_list_find(g_cmd_list, command);
if (NULL == iter) {
SLOG(LOG_ERROR, TAG_VCCMD, "Fail to command destroy : handle is not valid");
+ CMD_MUTEX_UNLOCK();
return VC_ERROR_INVALID_PARAMETER;
}
free(command);
command = NULL;
+ CMD_MUTEX_UNLOCK();
return VC_ERROR_NONE;
}