Commit 549ce2ca authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Override the plugins path with an environment variable...

...rather than with a command line option. This enables extending the
set of plugins paths globally, for all LibVLC applications.

Using an environment variable seems more logical than a command line
option considering that the module bank is shared by all VLC instances
in the process. In other words, it did not belong as a parameter to
libvlc_new().
parent 06028f48
...@@ -91,25 +91,22 @@ int main (int argc, char *argv[]) ...@@ -91,25 +91,22 @@ int main (int argc, char *argv[])
{ {
/* Note that FromLocale() can be used before libvlc is initialized */ /* Note that FromLocale() can be used before libvlc is initialized */
const char *path = FromLocale (argv[i]); const char *path = FromLocale (argv[i]);
char *arg;
if (asprintf (&arg, "--plugin-path=%s", path) == -1) if (setenv ("VLC_PLUGIN_PATH", path, 1))
abort (); abort ();
const char *vlc_argv[5]; const char *vlc_argv[4];
int vlc_argc = 0; int vlc_argc = 0;
vlc_argv[vlc_argc++] = "--quiet"; vlc_argv[vlc_argc++] = "--quiet";
if (force) if (force)
vlc_argv[vlc_argc++] = "--reset-plugins-cache"; vlc_argv[vlc_argc++] = "--reset-plugins-cache";
vlc_argv[vlc_argc++] = arg;
vlc_argv[vlc_argc++] = "--"; /* end of options */ vlc_argv[vlc_argc++] = "--"; /* end of options */
vlc_argv[vlc_argc] = NULL; vlc_argv[vlc_argc] = NULL;
libvlc_instance_t *vlc = libvlc_new (vlc_argc, vlc_argv); libvlc_instance_t *vlc = libvlc_new (vlc_argc, vlc_argv);
if (vlc != NULL) if (vlc != NULL)
libvlc_release (vlc); libvlc_release (vlc);
free (arg);
if (vlc == NULL) if (vlc == NULL)
fprintf (stderr, "No plugins in %s\n", path); fprintf (stderr, "No plugins in %s\n", path);
LocaleFree (path); LocaleFree (path);
......
...@@ -100,6 +100,10 @@ int main( int i_argc, const char *ppsz_argv[] ) ...@@ -100,6 +100,10 @@ int main( int i_argc, const char *ppsz_argv[] )
setenv ("GNOME_DISABLE_CRASH_DIALOG", "1", 1); setenv ("GNOME_DISABLE_CRASH_DIALOG", "1", 1);
# endif # endif
# ifdef TOP_BUILDDIR
setenv ("VLC_PLUGIN_PATH", TOP_BUILDDIR"/modules", 1);
# endif
/* Clear the X.Org startup notification ID. Otherwise the UI might try to /* Clear the X.Org startup notification ID. Otherwise the UI might try to
* change the environment while the process is multi-threaded. That could * change the environment while the process is multi-threaded. That could
* crash. Screw you X.Org. Next time write a thread-safe specification. */ * crash. Screw you X.Org. Next time write a thread-safe specification. */
...@@ -174,14 +178,11 @@ int main( int i_argc, const char *ppsz_argv[] ) ...@@ -174,14 +178,11 @@ int main( int i_argc, const char *ppsz_argv[] )
pthread_sigmask (SIG_SETMASK, &set, NULL); pthread_sigmask (SIG_SETMASK, &set, NULL);
/* Note that FromLocale() can be used before libvlc is initialized */ /* Note that FromLocale() can be used before libvlc is initialized */
const char *argv[i_argc + 4]; const char *argv[i_argc + 3];
int argc = 0; int argc = 0;
argv[argc++] = "--no-ignore-config"; argv[argc++] = "--no-ignore-config";
argv[argc++] = "--media-library"; argv[argc++] = "--media-library";
#ifdef TOP_BUILDDIR
argv[argc++] = FromLocale ("--plugin-path="TOP_BUILDDIR"/modules");
#endif
#ifdef TOP_SRCDIR #ifdef TOP_SRCDIR
argv[argc++] = FromLocale ("--data-path="TOP_SRCDIR"/share"); argv[argc++] = FromLocale ("--data-path="TOP_SRCDIR"/share");
#endif #endif
......
...@@ -22,6 +22,9 @@ esac ...@@ -22,6 +22,9 @@ esac
#Distributors can run BUILDDIR=XXX ./zsh_completion.sh #Distributors can run BUILDDIR=XXX ./zsh_completion.sh
[ -z "$BUILDDIR" ] && BUILDDIR=../../ [ -z "$BUILDDIR" ] && BUILDDIR=../../
VLC_PLUGIN_PATH="$BUILDDIR"
export VLC_PLUGIN_PATH
function find_libvlc { function find_libvlc {
[ -z "$SUFFIX" ] && return 0 # linking will fail if lib isn't found [ -z "$SUFFIX" ] && return 0 # linking will fail if lib isn't found
for i in $BUILDDIR/src/.libs/libvlc.$SUFFIX $BUILDDIR/src/libvlc.$SUFFIX; do for i in $BUILDDIR/src/.libs/libvlc.$SUFFIX $BUILDDIR/src/libvlc.$SUFFIX; do
...@@ -66,15 +69,15 @@ eval $ZSH_BUILD || exit 1 ...@@ -66,15 +69,15 @@ eval $ZSH_BUILD || exit 1
printf "Generating zsh completion in _vlc ... " printf "Generating zsh completion in _vlc ... "
if ! ./zsh_gen --plugin-path=$BUILDDIR >_vlc 2>/dev/null; then if ! ./zsh_gen >_vlc 2>/dev/null; then
echo " echo "
ERROR: the generation failed.... :( ERROR: the generation failed.... :(
Please press enter to verify that all the VLC modules are shown" Please press enter to verify that all the VLC modules are shown"
read i read i
./zsh_gen --plugin-path=$BUILDDIR -vv --list ./zsh_gen -vv --list
echo " echo "
If they are shown, press enter to see if you can debug the problem If they are shown, press enter to see if you can debug the problem
It will be reproduced by running \"./zsh_gen --plugin-path=$BUILDDIR -vvv\"" It will be reproduced by running \"./zsh_gen -vvv\""
read i read i
./zsh_gen --plugin-path=$BUILDDIR -vv ./zsh_gen --plugin-path=$BUILDDIR -vv
exit 1 exit 1
......
...@@ -473,8 +473,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, ...@@ -473,8 +473,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
if( module_count <= 1 ) if( module_count <= 1 )
{ {
msg_Err( p_libvlc, "No modules were found, refusing to start. Check " msg_Err( p_libvlc, "No plugins found! Check your VLC installation.");
"that you properly gave a module path with --plugin-path.");
b_exit = true; b_exit = true;
i_ret = VLC_ENOITEM; i_ret = VLC_ENOITEM;
} }
......
...@@ -853,10 +853,14 @@ static void AllocateAllPlugins( vlc_object_t *p_this, module_bank_t *p_bank ) ...@@ -853,10 +853,14 @@ static void AllocateAllPlugins( vlc_object_t *p_this, module_bank_t *p_bank )
} }
/* If the user provided a plugin path, we add it to the list */ /* If the user provided a plugin path, we add it to the list */
paths = var_InheritString( p_this, "plugin-path" ); paths = getenv( "VLC_PLUGIN_PATH" );
if( paths == NULL ) if( paths == NULL )
return; return;
paths = strdup( paths ); /* don't harm the environment ! :) */
if( unlikely(paths == NULL) )
return;
for( char *buf, *path = strtok_r( paths, PATH_SEP, &buf ); for( char *buf, *path = strtok_r( paths, PATH_SEP, &buf );
path != NULL; path != NULL;
path = strtok_r( NULL, PATH_SEP, &buf ) ) path = strtok_r( NULL, PATH_SEP, &buf ) )
...@@ -966,7 +970,7 @@ static int AllocatePluginFile( vlc_object_t * p_this, module_bank_t *p_bank, ...@@ -966,7 +970,7 @@ static int AllocatePluginFile( vlc_object_t * p_this, module_bank_t *p_bank,
p_module = p_cache_entry->p_module; p_module = p_cache_entry->p_module;
p_module->b_loaded = false; p_module->b_loaded = false;
/* If plugin-path contains duplicate entries... */ /* If VLC_PLUGIN_PATH contains duplicate entries... */
if( p_module->next != NULL ) if( p_module->next != NULL )
return 0; /* already taken care of that one */ return 0; /* already taken care of that one */
......
...@@ -53,7 +53,6 @@ static const char * test_defaults_args[] = { ...@@ -53,7 +53,6 @@ static const char * test_defaults_args[] = {
"-I", "-I",
"dummy", "dummy",
"--no-media-library", "--no-media-library",
"--plugin-path=../modules",
"--vout=dummy", "--vout=dummy",
"--aout=dummy" "--aout=dummy"
}; };
...@@ -75,6 +74,7 @@ static inline void test_init (void) ...@@ -75,6 +74,7 @@ static inline void test_init (void)
{ {
(void)test_default_sample; /* This one may not be used */ (void)test_default_sample; /* This one may not be used */
alarm (10); /* Make sure "make check" does not get stuck */ alarm (10); /* Make sure "make check" does not get stuck */
setenv( "VLC_PLUGIN_PATH", "../modules", 1 );
} }
#endif /* TEST_H */ #endif /* TEST_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment