summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Guillem <thomas@gllm.fr>2016-03-25 09:05:35 +0100
committerJean-Philippe Andre <jp.andre@samsung.com>2016-03-28 16:40:02 +0900
commitf5296e8afc680e5c35c08ebb126f4f3636d32dd5 (patch)
tree4d03148dd76d872fafb8f9144182f1b09b9c81c5
parent941ccc43247fe23aba125180e9787c851a79b4d3 (diff)
downloadefl-f5296e8afc680e5c35c08ebb126f4f3636d32dd5.tar.gz
emotion/libvlc: set libvlc args from "EMOTION_LIBVLC_ARGS" env
-rw-r--r--src/modules/emotion/libvlc/emotion_libvlc.c63
1 files changed, 62 insertions, 1 deletions
diff --git a/src/modules/emotion/libvlc/emotion_libvlc.c b/src/modules/emotion/libvlc/emotion_libvlc.c
index 4f4ffb31b9..c18d5eddb9 100644
--- a/src/modules/emotion/libvlc/emotion_libvlc.c
+++ b/src/modules/emotion/libvlc/emotion_libvlc.c
@@ -1696,6 +1696,67 @@ libvlc_log(void *data EINA_UNUSED, int level,
__FILE__, __FUNCTION__, __LINE__, fmt, args);
}
+static libvlc_instance_t *
+libvlc_new_env_args(void)
+{
+ unsigned int argc = 0, i = 0;
+ const char **argv = NULL;
+ char *args_env, *args_dup = NULL, *str = NULL, *token, *saveptr;
+ libvlc_instance_t *instance = NULL;
+
+ args_env = getenv("EMOTION_LIBVLC_ARGS");
+ if (!args_env)
+ goto fallback;
+
+ /* dup since strtok modify the str */
+ args_dup = strdup(args_env);
+ if (!args_dup)
+ goto fallback;
+
+ /* call strtok to count the numbers of arguments */
+ str = strdup(args_dup);
+ if (!str)
+ goto fallback;
+
+ token = strtok_r(str, " ", &saveptr);
+ while (token)
+ {
+ argc++;
+ token = strtok_r(NULL, " ", &saveptr);
+ }
+ if (!argc)
+ goto fallback;
+
+ /* alloc argv */
+ argv = malloc(argc * sizeof(char *));
+ if (!argv)
+ goto fallback;
+
+ /* call strtok to fill argv */
+ free(str);
+ str = strdup(args_dup);
+ if (!str)
+ goto fallback;
+
+ token = strtok_r(str, " ", &saveptr);
+ while (token && i < argc)
+ {
+ argv[i++] = token;
+ token = strtok_r(NULL, " ", &saveptr);
+ }
+
+ for (i = 0; i < argc; ++i)
+ INF("libvlc_argv[%d]: %s", i, argv[i]);
+
+ instance = libvlc_new(argc, argv);
+
+fallback:
+ free(args_dup);
+ free(str);
+ free(argv);
+ return instance ? instance : libvlc_new(0, NULL);
+}
+
Eina_Bool
libvlc_module_init(void)
{
@@ -1716,7 +1777,7 @@ libvlc_module_init(void)
return EINA_FALSE;
}
- libvlc = libvlc_new(0, NULL);
+ libvlc = libvlc_new_env_args();
if (!libvlc)
{
CRI("could not create libvlc instance");