diff --git a/spa/plugins/filter-graph/plugin_ladspa.c b/spa/plugins/filter-graph/plugin_ladspa.c index c8a1b4209..6a43eab24 100644 --- a/spa/plugins/filter-graph/plugin_ladspa.c +++ b/spa/plugins/filter-graph/plugin_ladspa.c @@ -233,20 +233,25 @@ static inline const char *split_walk(const char *str, const char *delimiter, siz return s; } -static int load_ladspa_plugin(struct plugin *impl, const char *path) +static void make_search_paths(const char **path, const char **search_dirs) +{ + const char *p; + + while ((p = strstr(*path, "../")) != NULL) + *path = p + 3; + + *search_dirs = getenv("LADSPA_PATH"); + if (!*search_dirs) + *search_dirs = "/usr/lib64/ladspa:/usr/lib/ladspa:" LIBDIR; +} + +static int load_ladspa_plugin(struct plugin *impl, const char *path, const char *search_dirs) { int res = -ENOENT; - const char *search_dirs, *p, *state = NULL; + const char *p, *state = NULL; char filename[PATH_MAX]; size_t len; - while ((p = strstr(path, "../")) != NULL) - path = p + 3; - - search_dirs = getenv("LADSPA_PATH"); - if (!search_dirs) - search_dirs = "/usr/lib64/ladspa:/usr/lib/ladspa:" LIBDIR; - /* * set the errno for the case when `ladspa_handle_load_by_path()` * is never called, which can only happen if the supplied @@ -314,7 +319,7 @@ impl_init(const struct spa_handle_factory *factory, struct plugin *impl; uint32_t i; int res; - const char *path = NULL; + const char *path = NULL, *search_dirs; handle->get_interface = impl_get_interface; handle->clear = impl_clear; @@ -332,9 +337,11 @@ impl_init(const struct spa_handle_factory *factory, if (path == NULL) return -EINVAL; - if ((res = load_ladspa_plugin(impl, path)) < 0) { - spa_log_error(impl->log, "failed to load plugin '%s': %s", - path, spa_strerror(res)); + make_search_paths(&path, &search_dirs); + + if ((res = load_ladspa_plugin(impl, path, search_dirs)) < 0) { + spa_log_error(impl->log, "failed to load plugin '%s.so' in '%s': %s", + path, search_dirs, spa_strerror(res)); return res; }