mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-06 13:29:56 -05:00
module: Create pa_module_exists()
This new function checks if a certain module name is available in the system.
This commit is contained in:
parent
dc4be17e07
commit
48d23d4863
3 changed files with 58 additions and 0 deletions
|
|
@ -1217,6 +1217,7 @@ PACTL_BINARY=${bindir}/pactl${EXEEXT}
|
||||||
AX_DEFINE_DIR(PACTL_BINARY, PACTL_BINARY, [Location of pactl binary])
|
AX_DEFINE_DIR(PACTL_BINARY, PACTL_BINARY, [Location of pactl binary])
|
||||||
|
|
||||||
AC_SUBST(PA_SOEXT, [.so])
|
AC_SUBST(PA_SOEXT, [.so])
|
||||||
|
AC_DEFINE(PA_SOEXT, [".so"], [Shared object extension])
|
||||||
|
|
||||||
AC_SUBST(pulseconfdir, ["${sysconfdir}/pulse"])
|
AC_SUBST(pulseconfdir, ["${sysconfdir}/pulse"])
|
||||||
AX_DEFINE_DIR(PA_DEFAULT_CONFIG_DIR, pulseconfdir, [Location of configuration files])
|
AX_DEFINE_DIR(PA_DEFAULT_CONFIG_DIR, pulseconfdir, [Location of configuration files])
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <ltdl.h>
|
||||||
|
|
||||||
#include <pulse/xmalloc.h>
|
#include <pulse/xmalloc.h>
|
||||||
#include <pulse/proplist.h>
|
#include <pulse/proplist.h>
|
||||||
|
|
@ -47,6 +48,60 @@
|
||||||
#define PA_SYMBOL_GET_N_USED "pa__get_n_used"
|
#define PA_SYMBOL_GET_N_USED "pa__get_n_used"
|
||||||
#define PA_SYMBOL_GET_DEPRECATE "pa__get_deprecated"
|
#define PA_SYMBOL_GET_DEPRECATE "pa__get_deprecated"
|
||||||
|
|
||||||
|
bool pa_module_exists(const char *name) {
|
||||||
|
const char *paths, *state = NULL;
|
||||||
|
char *n, *p, *pathname;
|
||||||
|
bool result;
|
||||||
|
|
||||||
|
pa_assert(name);
|
||||||
|
|
||||||
|
if (name[0] == PA_PATH_SEP_CHAR) {
|
||||||
|
result = access(name, F_OK) == 0 ? true : false;
|
||||||
|
pa_log_debug("Checking for existence of '%s': %s", name, result ? "success" : "failure");
|
||||||
|
if (result)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(paths = lt_dlgetsearchpath()))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
/* strip .so from the end of name, if present */
|
||||||
|
n = pa_xstrdup(name);
|
||||||
|
p = rindex(n, '.');
|
||||||
|
if (p && pa_streq(p, PA_SOEXT))
|
||||||
|
p[0] = 0;
|
||||||
|
|
||||||
|
while ((p = pa_split(paths, ":", &state))) {
|
||||||
|
pathname = pa_sprintf_malloc("%s" PA_PATH_SEP "%s" PA_SOEXT, p, n);
|
||||||
|
result = access(pathname, F_OK) == 0 ? true : false;
|
||||||
|
pa_log_debug("Checking for existence of '%s': %s", pathname, result ? "success" : "failure");
|
||||||
|
pa_xfree(pathname);
|
||||||
|
pa_xfree(p);
|
||||||
|
if (result) {
|
||||||
|
pa_xfree(n);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
state = NULL;
|
||||||
|
if (PA_UNLIKELY(pa_run_from_build_tree())) {
|
||||||
|
while ((p = pa_split(paths, ":", &state))) {
|
||||||
|
pathname = pa_sprintf_malloc("%s" PA_PATH_SEP ".libs" PA_PATH_SEP "%s" PA_SOEXT, p, n);
|
||||||
|
result = access(pathname, F_OK) == 0 ? true : false;
|
||||||
|
pa_log_debug("Checking for existence of '%s': %s", pathname, result ? "success" : "failure");
|
||||||
|
pa_xfree(pathname);
|
||||||
|
pa_xfree(p);
|
||||||
|
if (result) {
|
||||||
|
pa_xfree(n);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pa_xfree(n);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
pa_module* pa_module_load(pa_core *c, const char *name, const char *argument) {
|
pa_module* pa_module_load(pa_core *c, const char *name, const char *argument) {
|
||||||
pa_module *m = NULL;
|
pa_module *m = NULL;
|
||||||
bool (*load_once)(void);
|
bool (*load_once)(void);
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,8 @@ struct pa_module {
|
||||||
pa_proplist *proplist;
|
pa_proplist *proplist;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool pa_module_exists(const char *name);
|
||||||
|
|
||||||
pa_module* pa_module_load(pa_core *c, const char *name, const char *argument);
|
pa_module* pa_module_load(pa_core *c, const char *name, const char *argument);
|
||||||
|
|
||||||
void pa_module_unload(pa_core *c, pa_module *m, bool force);
|
void pa_module_unload(pa_core *c, pa_module *m, bool force);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue