summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiyong Min <jiyong.min@samsung.com>2018-05-14 12:57:45 +0900
committerJiyong Min <jiyong.min@samsung.com>2018-05-14 12:58:43 +0900
commited403f132982a086622248b77a23d764a273044a (patch)
tree6914088c1a184b0b0a379757168293daf648cd06
parent5a61addd894a5a5e485aa1dc8bf5ae03b4cc246f (diff)
downloadmedia-controller-ed403f132982a086622248b77a23d764a273044a.tar.gz
media-controller-ed403f132982a086622248b77a23d764a273044a.tar.bz2
media-controller-ed403f132982a086622248b77a23d764a273044a.zip
Add getting request id
Change-Id: I9e523282d6510a465da1c79a32b3a0da4e069bac
-rwxr-xr-xinclude/media_controller_private.h1
-rwxr-xr-xsrc/media_controller_util.c22
2 files changed, 23 insertions, 0 deletions
diff --git a/include/media_controller_private.h b/include/media_controller_private.h
index 84105ca..dc99203 100755
--- a/include/media_controller_private.h
+++ b/include/media_controller_private.h
@@ -270,6 +270,7 @@ char* mc_util_get_interface_name(const char *type, const char *name);
int mc_util_make_filter_interface_name(const char *prefix, const char *filter, char **interface_name);
int mc_util_set_command_available(const char *name, const char *command_type, const char *command);
int mc_util_get_command_available(const char *name, const char *command_type, const char *command);
+int mc_util_get_request_id(unsigned int *req_id);
int mc_safe_strtoi(const char *buffer, int *value);
int mc_safe_strtoull(const char *buffer, unsigned long long *value);
diff --git a/src/media_controller_util.c b/src/media_controller_util.c
index 42964c8..9477505 100755
--- a/src/media_controller_util.c
+++ b/src/media_controller_util.c
@@ -23,6 +23,8 @@
//#define UNIT_TEST /* for testsuite */
#define MAX_NAME_LENGTH 255
+static GMutex mutex_req_id;
+
static void _mc_util_check_valid_name(const char *name, char **valid_name)
{
char old_word[MAX_NAME_LENGTH] = {0, };
@@ -174,6 +176,26 @@ int mc_util_get_command_available(const char *name, const char *command_type, co
return ret;
}
+int mc_util_get_request_id(unsigned int *req_id)
+{
+ int ret = MEDIA_CONTROLLER_ERROR_NONE;
+ static unsigned int request_id = 0;
+
+ mc_retvm_if(req_id == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "invalid parameter");
+
+ g_mutex_lock(&mutex_req_id);
+
+ if (request_id + 1 == UINT_MAX) {
+ request_id = 0;
+ }
+ request_id++;
+ *req_id = request_id;
+
+ g_mutex_unlock(&mutex_req_id);
+
+ return ret;
+}
+
int mc_safe_strtoi(const char *buffer, int *value)
{
char *end = NULL;