diff --git a/bin/cachegen.c b/bin/cachegen.c index e73e4a5734..6fef55d830 100644 --- a/bin/cachegen.c +++ b/bin/cachegen.c @@ -91,25 +91,22 @@ int main (int argc, char *argv[]) { /* Note that FromLocale() can be used before libvlc is initialized */ const char *path = FromLocale (argv[i]); - char *arg; - if (asprintf (&arg, "--plugin-path=%s", path) == -1) + if (setenv ("VLC_PLUGIN_PATH", path, 1)) abort (); - const char *vlc_argv[5]; + const char *vlc_argv[4]; int vlc_argc = 0; vlc_argv[vlc_argc++] = "--quiet"; if (force) vlc_argv[vlc_argc++] = "--reset-plugins-cache"; - vlc_argv[vlc_argc++] = arg; vlc_argv[vlc_argc++] = "--"; /* end of options */ vlc_argv[vlc_argc] = NULL; libvlc_instance_t *vlc = libvlc_new (vlc_argc, vlc_argv); if (vlc != NULL) libvlc_release (vlc); - free (arg); if (vlc == NULL) fprintf (stderr, "No plugins in %s\n", path); LocaleFree (path); diff --git a/bin/vlc.c b/bin/vlc.c index 3a49287324..4299bdf622 100644 --- a/bin/vlc.c +++ b/bin/vlc.c @@ -100,6 +100,10 @@ int main( int i_argc, const char *ppsz_argv[] ) setenv ("GNOME_DISABLE_CRASH_DIALOG", "1", 1); # 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 * change the environment while the process is multi-threaded. That could * 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[] ) pthread_sigmask (SIG_SETMASK, &set, NULL); /* 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; argv[argc++] = "--no-ignore-config"; argv[argc++] = "--media-library"; -#ifdef TOP_BUILDDIR - argv[argc++] = FromLocale ("--plugin-path="TOP_BUILDDIR"/modules"); -#endif #ifdef TOP_SRCDIR argv[argc++] = FromLocale ("--data-path="TOP_SRCDIR"/share"); #endif diff --git a/extras/analyser/zsh_completion.sh b/extras/analyser/zsh_completion.sh index d901b1c94b..f10f4bf0a2 100755 --- a/extras/analyser/zsh_completion.sh +++ b/extras/analyser/zsh_completion.sh @@ -22,6 +22,9 @@ esac #Distributors can run BUILDDIR=XXX ./zsh_completion.sh [ -z "$BUILDDIR" ] && BUILDDIR=../../ +VLC_PLUGIN_PATH="$BUILDDIR" +export VLC_PLUGIN_PATH + function find_libvlc { [ -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 @@ -66,15 +69,15 @@ eval $ZSH_BUILD || exit 1 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 " ERROR: the generation failed.... :( Please press enter to verify that all the VLC modules are shown" read i - ./zsh_gen --plugin-path=$BUILDDIR -vv --list + ./zsh_gen -vv --list echo " 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 ./zsh_gen --plugin-path=$BUILDDIR -vv exit 1 diff --git a/src/libvlc.c b/src/libvlc.c index f0cec42353..53775ce877 100644 --- a/src/libvlc.c +++ b/src/libvlc.c @@ -473,8 +473,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, if( module_count <= 1 ) { - msg_Err( p_libvlc, "No modules were found, refusing to start. Check " - "that you properly gave a module path with --plugin-path."); + msg_Err( p_libvlc, "No plugins found! Check your VLC installation."); b_exit = true; i_ret = VLC_ENOITEM; } diff --git a/src/modules/modules.c b/src/modules/modules.c index d9d19defce..aa758d779d 100644 --- a/src/modules/modules.c +++ b/src/modules/modules.c @@ -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 */ - paths = var_InheritString( p_this, "plugin-path" ); + paths = getenv( "VLC_PLUGIN_PATH" ); if( paths == NULL ) return; + paths = strdup( paths ); /* don't harm the environment ! :) */ + if( unlikely(paths == NULL) ) + return; + for( char *buf, *path = strtok_r( paths, PATH_SEP, &buf ); path != NULL; path = strtok_r( NULL, PATH_SEP, &buf ) ) @@ -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->b_loaded = false; - /* If plugin-path contains duplicate entries... */ + /* If VLC_PLUGIN_PATH contains duplicate entries... */ if( p_module->next != NULL ) return 0; /* already taken care of that one */ diff --git a/test/libvlc/test.h b/test/libvlc/test.h index 2a6c84b6e8..fc41f51582 100644 --- a/test/libvlc/test.h +++ b/test/libvlc/test.h @@ -53,7 +53,6 @@ static const char * test_defaults_args[] = { "-I", "dummy", "--no-media-library", - "--plugin-path=../modules", "--vout=dummy", "--aout=dummy" }; @@ -75,6 +74,7 @@ static inline void test_init (void) { (void)test_default_sample; /* This one may not be used */ alarm (10); /* Make sure "make check" does not get stuck */ + setenv( "VLC_PLUGIN_PATH", "../modules", 1 ); } #endif /* TEST_H */