mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-14 08:56:37 -05:00
Don't hardcode plugin path
Use SPA_PLUGIN_DIR to get the plugin path. Install plugins in subdirectory to make it match the build tree.
This commit is contained in:
parent
763bd1100e
commit
4a6b1b42bc
20 changed files with 84 additions and 36 deletions
1
Makefile
1
Makefile
|
|
@ -8,6 +8,7 @@ clean:
|
|||
ninja-build -C build clean
|
||||
|
||||
run:
|
||||
SPA_PLUGIN_DIR=build/spa/plugins \
|
||||
PIPEWIRE_MODULE_DIR=build \
|
||||
PIPEWIRE_CONFIG_FILE=build/pipewire/daemon/pipewire.conf \
|
||||
build/pipewire/daemon/pipewire
|
||||
|
|
|
|||
|
|
@ -360,12 +360,15 @@
|
|||
/* Define to the version of this package. */
|
||||
#mesondefine PACKAGE_VERSION
|
||||
|
||||
/* directory where plugins are located */
|
||||
/* directory where modules are located */
|
||||
#mesondefine MODULEDIR
|
||||
|
||||
/* directory where config files are located */
|
||||
#mesondefine PIPEWIRE_CONFIG_DIR
|
||||
|
||||
/* directory where plugins are located */
|
||||
#mesondefine PLUGINDIR
|
||||
|
||||
/* Define to necessary symbol if this constant uses a non-standard name on
|
||||
your system. */
|
||||
#mesondefine PTHREAD_CREATE_JOINABLE
|
||||
|
|
|
|||
|
|
@ -53,9 +53,10 @@ cdata.set('PACKAGE_STRING', '"PipeWire @0@"'.format(pipewire_version))
|
|||
cdata.set('PACKAGE_TARNAME', '"pipewire"')
|
||||
cdata.set('PACKAGE_URL', '"http://pipewire.org"')
|
||||
cdata.set('PACKAGE_VERSION', '"@0@"'.format(pipewire_version))
|
||||
cdata.set('MODULEDIR', '"@0@/@1@/pipewire-@2@"'.format(pipewire_libdir,apiversion))
|
||||
cdata.set('MODULEDIR', '"@0@/pipewire-@1@"'.format(pipewire_libdir,apiversion))
|
||||
cdata.set('PIPEWIRE_CONFIG_DIR', '"@0@/pipewire"'.format(pipewire_sysconfdir))
|
||||
cdata.set('VERSION', '"@0@"'.format(pipewire_version))
|
||||
cdata.set('PLUGINDIR', '"@0@/spa"'.format(pipewire_libdir))
|
||||
# FIXME: --with-memory-alignment],[8,N,malloc,pagesize (default is 32)]) option
|
||||
cdata.set('MEMORY_ALIGNMENT_MALLOC', 1)
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,10 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
|
|
@ -37,21 +41,29 @@ static struct support_info {
|
|||
} support_info;
|
||||
|
||||
static bool
|
||||
open_support(const char *lib,
|
||||
open_support(const char *path,
|
||||
const char *lib,
|
||||
struct support_info *info)
|
||||
{
|
||||
if ((info->hnd = dlopen(lib, RTLD_NOW)) == NULL) {
|
||||
fprintf(stderr, "can't load %s: %s\n", lib, dlerror());
|
||||
return false;
|
||||
char *filename;
|
||||
|
||||
asprintf(&filename, "%s/%s.so", path, lib);
|
||||
|
||||
if ((info->hnd = dlopen(filename, RTLD_NOW)) == NULL) {
|
||||
fprintf(stderr, "can't load %s: %s\n", filename, dlerror());
|
||||
goto open_failed;
|
||||
}
|
||||
if ((info->enum_func = dlsym(info->hnd, SPA_HANDLE_FACTORY_ENUM_FUNC_NAME)) == NULL) {
|
||||
fprintf(stderr, "can't find enum function\n");
|
||||
goto no_symbol;
|
||||
}
|
||||
free(filename);
|
||||
return true;
|
||||
|
||||
no_symbol:
|
||||
dlclose(info->hnd);
|
||||
open_failed:
|
||||
free(filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -182,7 +194,10 @@ void pw_init(int *argc, char **argv[])
|
|||
if ((str = getenv("PIPEWIRE_DEBUG")))
|
||||
configure_debug(str);
|
||||
|
||||
if (open_support("build/spa/plugins/support/libspa-support.so", &support_info))
|
||||
if ((str = getenv("SPA_PLUGIN_DIR")) == NULL)
|
||||
str = PLUGINDIR;
|
||||
|
||||
if (open_support(str, "support/libspa-support", &support_info))
|
||||
configure_support(&support_info);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
#subdir('gst')
|
||||
subdir('spa')
|
||||
|
||||
pipewire_module_c_args = [
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
#include "pipewire/server/core.h"
|
||||
#include "pipewire/server/module.h"
|
||||
|
||||
#define AUDIOMIXER_LIB "build/spa/plugins/audiomixer/libspa-audiomixer.so"
|
||||
#define AUDIOMIXER_LIB "audiomixer/libspa-audiomixer"
|
||||
|
||||
struct impl {
|
||||
struct pw_core *core;
|
||||
|
|
@ -43,10 +43,17 @@ static const struct spa_handle_factory *find_factory(struct impl *impl)
|
|||
uint32_t index;
|
||||
const struct spa_handle_factory *factory = NULL;
|
||||
int res;
|
||||
char *filename;
|
||||
const char *dir;
|
||||
|
||||
if ((impl->hnd = dlopen(AUDIOMIXER_LIB, RTLD_NOW)) == NULL) {
|
||||
if ((dir = getenv("SPA_PLUIGIN_DIR")) == NULL)
|
||||
dir = PLUGINDIR;
|
||||
|
||||
asprintf(&filename, "%s/%s.so", dir, AUDIOMIXER_LIB);
|
||||
|
||||
if ((impl->hnd = dlopen(filename, RTLD_NOW)) == NULL) {
|
||||
pw_log_error("can't load %s: %s", AUDIOMIXER_LIB, dlerror());
|
||||
return NULL;
|
||||
goto open_failed;
|
||||
}
|
||||
if ((enum_func = dlsym(impl->hnd, SPA_HANDLE_FACTORY_ENUM_FUNC_NAME)) == NULL) {
|
||||
pw_log_error("can't find enum function");
|
||||
|
|
@ -62,12 +69,15 @@ static const struct spa_handle_factory *find_factory(struct impl *impl)
|
|||
if (strcmp(factory->name, "audiomixer") == 0)
|
||||
break;
|
||||
}
|
||||
free(filename);
|
||||
return factory;
|
||||
|
||||
enum_failed:
|
||||
no_symbol:
|
||||
dlclose(impl->hnd);
|
||||
impl->hnd = NULL;
|
||||
open_failed:
|
||||
free(filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,10 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <getopt.h>
|
||||
#include <limits.h>
|
||||
|
||||
|
|
@ -73,6 +77,7 @@ setup_video_node(struct pw_core *core, struct spa_node *spa_node, struct pw_prop
|
|||
|
||||
bool pipewire__module_init(struct pw_module *module, const char *args)
|
||||
{
|
||||
const char *dir;
|
||||
struct pw_properties *video_props = NULL, *audio_props = NULL;
|
||||
|
||||
if (args != NULL) {
|
||||
|
|
@ -118,17 +123,17 @@ bool pipewire__module_init(struct pw_module *module, const char *args)
|
|||
free(argv);
|
||||
pw_free_strv(tmp_argv);
|
||||
}
|
||||
if ((dir = getenv("SPA_PLUGIN_DIR")) == NULL)
|
||||
dir = PLUGINDIR;
|
||||
|
||||
pw_spa_monitor_load(module->core, dir, "alsa/libspa-alsa", "alsa-monitor", "alsa");
|
||||
|
||||
pw_spa_monitor_load(module->core, dir, "v4l2/libspa-v4l2", "v4l2-monitor", "v4l2");
|
||||
|
||||
pw_spa_monitor_load(module->core,
|
||||
"build/spa/plugins/alsa/libspa-alsa.so", "alsa-monitor", "alsa");
|
||||
pw_spa_monitor_load(module->core,
|
||||
"build/spa/plugins/v4l2/libspa-v4l2.so", "v4l2-monitor", "v4l2");
|
||||
audio_props = pw_properties_new("media.class", "Audio/Source", NULL);
|
||||
pw_spa_node_load(module->core,
|
||||
"build/spa/plugins/audiotestsrc/libspa-audiotestsrc.so",
|
||||
pw_spa_node_load(module->core, dir, "audiotestsrc/libspa-audiotestsrc",
|
||||
"audiotestsrc", "audiotestsrc", audio_props, NULL);
|
||||
pw_spa_node_load(module->core,
|
||||
"build/spa/plugins/videotestsrc/libspa-videotestsrc.so",
|
||||
pw_spa_node_load(module->core, dir, "videotestsrc/libspa-videotestsrc",
|
||||
"videotestsrc", "videotestsrc", video_props, setup_video_node);
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -200,6 +200,7 @@ static const struct spa_monitor_callbacks callbacks = {
|
|||
};
|
||||
|
||||
struct pw_spa_monitor *pw_spa_monitor_load(struct pw_core *core,
|
||||
const char *dir,
|
||||
const char *lib,
|
||||
const char *factory_name, const char *system_name)
|
||||
{
|
||||
|
|
@ -212,10 +213,13 @@ struct pw_spa_monitor *pw_spa_monitor_load(struct pw_core *core,
|
|||
uint32_t index;
|
||||
spa_handle_factory_enum_func_t enum_func;
|
||||
const struct spa_handle_factory *factory;
|
||||
char *filename;
|
||||
|
||||
if ((hnd = dlopen(lib, RTLD_NOW)) == NULL) {
|
||||
pw_log_error("can't load %s: %s", lib, dlerror());
|
||||
return NULL;
|
||||
asprintf(&filename, "%s/%s.so", dir, lib);
|
||||
|
||||
if ((hnd = dlopen(filename, RTLD_NOW)) == NULL) {
|
||||
pw_log_error("can't load %s: %s", filename, dlerror());
|
||||
goto open_failed;
|
||||
}
|
||||
if ((enum_func = dlsym(hnd, SPA_HANDLE_FACTORY_ENUM_FUNC_NAME)) == NULL) {
|
||||
pw_log_error("can't find enum function");
|
||||
|
|
@ -250,7 +254,7 @@ struct pw_spa_monitor *pw_spa_monitor_load(struct pw_core *core,
|
|||
this = &impl->this;
|
||||
pw_signal_init(&this->destroy_signal);
|
||||
this->monitor = iface;
|
||||
this->lib = strdup(lib);
|
||||
this->lib = filename;
|
||||
this->factory_name = strdup(factory_name);
|
||||
this->system_name = strdup(system_name);
|
||||
this->handle = handle;
|
||||
|
|
@ -281,6 +285,8 @@ struct pw_spa_monitor *pw_spa_monitor_load(struct pw_core *core,
|
|||
enum_failed:
|
||||
no_symbol:
|
||||
dlclose(hnd);
|
||||
open_failed:
|
||||
free(filename);
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ struct pw_spa_monitor {
|
|||
|
||||
struct pw_spa_monitor *
|
||||
pw_spa_monitor_load(struct pw_core *core,
|
||||
const char *dir,
|
||||
const char *lib,
|
||||
const char *factory_name, const char *system_name);
|
||||
void
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ struct impl {
|
|||
};
|
||||
|
||||
struct pw_spa_node *pw_spa_node_load(struct pw_core *core,
|
||||
const char *dir,
|
||||
const char *lib,
|
||||
const char *factory_name,
|
||||
const char *name,
|
||||
|
|
@ -49,10 +50,13 @@ struct pw_spa_node *pw_spa_node_load(struct pw_core *core,
|
|||
spa_handle_factory_enum_func_t enum_func;
|
||||
const struct spa_handle_factory *factory;
|
||||
void *iface;
|
||||
char *filename;
|
||||
|
||||
if ((hnd = dlopen(lib, RTLD_NOW)) == NULL) {
|
||||
pw_log_error("can't load %s: %s", lib, dlerror());
|
||||
return NULL;
|
||||
asprintf(&filename, "%s/%s.so", dir, lib);
|
||||
|
||||
if ((hnd = dlopen(filename, RTLD_NOW)) == NULL) {
|
||||
pw_log_error("can't load %s: %s", filename, dlerror());
|
||||
goto open_failed;
|
||||
}
|
||||
if ((enum_func = dlsym(hnd, SPA_HANDLE_FACTORY_ENUM_FUNC_NAME)) == NULL) {
|
||||
pw_log_error("can't find enum function");
|
||||
|
|
@ -98,7 +102,7 @@ struct pw_spa_node *pw_spa_node_load(struct pw_core *core,
|
|||
}
|
||||
|
||||
this->node = pw_node_new(core, NULL, name, false, spa_node, spa_clock, properties);
|
||||
this->lib = strdup(lib);
|
||||
this->lib = filename;
|
||||
this->factory_name = strdup(factory_name);
|
||||
this->handle = handle;
|
||||
|
||||
|
|
@ -111,6 +115,8 @@ struct pw_spa_node *pw_spa_node_load(struct pw_core *core,
|
|||
enum_failed:
|
||||
no_symbol:
|
||||
dlclose(hnd);
|
||||
open_failed:
|
||||
free(filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ typedef int (*setup_node_t) (struct pw_core *core,
|
|||
|
||||
struct pw_spa_node *
|
||||
pw_spa_node_load(struct pw_core *core,
|
||||
const char *dir,
|
||||
const char *lib,
|
||||
const char *factory_name,
|
||||
const char *name,
|
||||
|
|
|
|||
|
|
@ -10,4 +10,4 @@ spa_alsa = shared_library('spa-alsa',
|
|||
dependencies : [ alsa_dep, libudev_dep ],
|
||||
link_with : spalib,
|
||||
install : true,
|
||||
install_dir : '@0@/spa'.format(get_option('libdir')))
|
||||
install_dir : '@0@/spa/alsa'.format(get_option('libdir')))
|
||||
|
|
|
|||
|
|
@ -5,4 +5,4 @@ audiomixerlib = shared_library('spa-audiomixer',
|
|||
include_directories : [spa_inc, spa_libinc],
|
||||
link_with : spalib,
|
||||
install : true,
|
||||
install_dir : '@0@/spa'.format(get_option('libdir')))
|
||||
install_dir : '@0@/spa/audiomixer/'.format(get_option('libdir')))
|
||||
|
|
|
|||
|
|
@ -6,4 +6,4 @@ audiotestsrclib = shared_library('spa-audiotestsrc',
|
|||
dependencies : libm,
|
||||
link_with : spalib,
|
||||
install : true,
|
||||
install_dir : '@0@/spa'.format(get_option('libdir')))
|
||||
install_dir : '@0@/spa/audiotestsrc'.format(get_option('libdir')))
|
||||
|
|
|
|||
|
|
@ -8,4 +8,4 @@ ffmpeglib = shared_library('spa-ffmpeg',
|
|||
dependencies : [ avcodec_dep, avformat_dep ],
|
||||
link_with : spalib,
|
||||
install : true,
|
||||
install_dir : '@0@/spa'.format(get_option('libdir')))
|
||||
install_dir : '@0@/spa/ffmpeg'.format(get_option('libdir')))
|
||||
|
|
|
|||
|
|
@ -8,4 +8,4 @@ spa_support_lib = shared_library('spa-support',
|
|||
include_directories : [ spa_inc, spa_libinc],
|
||||
dependencies : threads_dep,
|
||||
install : true,
|
||||
install_dir : '@0@/spa'.format(get_option('libdir')))
|
||||
install_dir : '@0@/spa/support'.format(get_option('libdir')))
|
||||
|
|
|
|||
|
|
@ -6,4 +6,4 @@ testlib = shared_library('spa-test',
|
|||
dependencies : threads_dep,
|
||||
link_with : spalib,
|
||||
install : true,
|
||||
install_dir : '@0@/spa'.format(get_option('libdir')))
|
||||
install_dir : '@0@/spa/test'.format(get_option('libdir')))
|
||||
|
|
|
|||
|
|
@ -8,4 +8,4 @@ v4l2lib = shared_library('spa-v4l2',
|
|||
dependencies : [ v4l2_dep, libudev_dep ],
|
||||
link_with : spalib,
|
||||
install : true,
|
||||
install_dir : '@0@/spa'.format(get_option('libdir')))
|
||||
install_dir : '@0@/spa/v4l2'.format(get_option('libdir')))
|
||||
|
|
|
|||
|
|
@ -6,4 +6,4 @@ videotestsrclib = shared_library('spa-videotestsrc',
|
|||
dependencies : threads_dep,
|
||||
link_with : spalib,
|
||||
install : true,
|
||||
install_dir : '@0@/spa'.format(get_option('libdir')))
|
||||
install_dir : '@0@/spa/videotestsrc'.format(get_option('libdir')))
|
||||
|
|
|
|||
|
|
@ -5,4 +5,4 @@ volumelib = shared_library('spa-volume',
|
|||
include_directories : [spa_inc, spa_libinc],
|
||||
link_with : spalib,
|
||||
install : true,
|
||||
install_dir : '@0@/spa'.format(get_option('libdir')))
|
||||
install_dir : '@0@/spa/volume'.format(get_option('libdir')))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue