summaryrefslogtreecommitdiff
path: root/src/modules/emotion/libvlc
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 /src/modules/emotion/libvlc
parent941ccc43247fe23aba125180e9787c851a79b4d3 (diff)
emotion/libvlc: set libvlc args from "EMOTION_LIBVLC_ARGS" env
Diffstat (limited to 'src/modules/emotion/libvlc')
-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,
1696 __FILE__, __FUNCTION__, __LINE__, fmt, args); 1696 __FILE__, __FUNCTION__, __LINE__, fmt, args);
1697} 1697}
1698 1698
1699static libvlc_instance_t *
1700libvlc_new_env_args(void)
1701{
1702 unsigned int argc = 0, i = 0;
1703 const char **argv = NULL;
1704 char *args_env, *args_dup = NULL, *str = NULL, *token, *saveptr;
1705 libvlc_instance_t *instance = NULL;
1706
1707 args_env = getenv("EMOTION_LIBVLC_ARGS");
1708 if (!args_env)
1709 goto fallback;
1710
1711 /* dup since strtok modify the str */
1712 args_dup = strdup(args_env);
1713 if (!args_dup)
1714 goto fallback;
1715
1716 /* call strtok to count the numbers of arguments */
1717 str = strdup(args_dup);
1718 if (!str)
1719 goto fallback;
1720
1721 token = strtok_r(str, " ", &saveptr);
1722 while (token)
1723 {
1724 argc++;
1725 token = strtok_r(NULL, " ", &saveptr);
1726 }
1727 if (!argc)
1728 goto fallback;
1729
1730 /* alloc argv */
1731 argv = malloc(argc * sizeof(char *));
1732 if (!argv)
1733 goto fallback;
1734
1735 /* call strtok to fill argv */
1736 free(str);
1737 str = strdup(args_dup);
1738 if (!str)
1739 goto fallback;
1740
1741 token = strtok_r(str, " ", &saveptr);
1742 while (token && i < argc)
1743 {
1744 argv[i++] = token;
1745 token = strtok_r(NULL, " ", &saveptr);
1746 }
1747
1748 for (i = 0; i < argc; ++i)
1749 INF("libvlc_argv[%d]: %s", i, argv[i]);
1750
1751 instance = libvlc_new(argc, argv);
1752
1753fallback:
1754 free(args_dup);
1755 free(str);
1756 free(argv);
1757 return instance ? instance : libvlc_new(0, NULL);
1758}
1759
1699Eina_Bool 1760Eina_Bool
1700libvlc_module_init(void) 1761libvlc_module_init(void)
1701{ 1762{
@@ -1716,7 +1777,7 @@ libvlc_module_init(void)
1716 return EINA_FALSE; 1777 return EINA_FALSE;
1717 } 1778 }
1718 1779
1719 libvlc = libvlc_new(0, NULL); 1780 libvlc = libvlc_new_env_args();
1720 if (!libvlc) 1781 if (!libvlc)
1721 { 1782 {
1722 CRI("could not create libvlc instance"); 1783 CRI("could not create libvlc instance");