filter-chain: move the filter-graph to plugins

This commit is contained in:
Wim Taymans 2024-11-13 11:10:49 +01:00
parent 2e157f7248
commit 567b484386
27 changed files with 122 additions and 132 deletions

View file

@ -16,7 +16,7 @@ clean:
ninja -C $(BUILD_ROOT) clean
run: all
SPA_PLUGIN_DIR=$(BUILD_ROOT)/spa/plugins:$(BUILD_ROOT)/src/modules \
SPA_PLUGIN_DIR=$(BUILD_ROOT)/spa/plugins \
SPA_DATA_DIR=$(SOURCE_ROOT)/spa/plugins \
PIPEWIRE_MODULE_DIR=$(BUILD_ROOT)/src/modules \
PATH=$(BUILD_ROOT)/src/examples:$(PATH) \

View file

@ -37,7 +37,7 @@ fi
# the config file read by the daemon
export PIPEWIRE_CONFIG_DIR="${BUILDDIR}/src/daemon"
# the directory with SPA plugins
export SPA_PLUGIN_DIR="${BUILDDIR}/spa/plugins:${BUILDDIR}/src/modules"
export SPA_PLUGIN_DIR="${BUILDDIR}/spa/plugins"
export SPA_DATA_DIR="${SCRIPT_DIR}/spa/plugins"
# the directory with pipewire modules
export PIPEWIRE_MODULE_DIR="${BUILDDIR}/src/modules"

View file

@ -2238,7 +2238,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
return 1;
}
struct spa_handle_factory spa_fga_plugin_builtin_factory = {
static struct spa_handle_factory spa_fga_plugin_builtin_factory = {
SPA_VERSION_HANDLE_FACTORY,
"filter.graph.plugin.builtin",
NULL,

View file

@ -29,9 +29,9 @@
#include <spa/pod/builder.h>
#include <spa/debug/types.h>
#include <spa/debug/log.h>
#include <spa/filter-graph/filter-graph.h>
#include "audio-plugin.h"
#include "filter-graph.h"
#include "audio-dsp-impl.h"
#undef SPA_LOG_TOPIC_DEFAULT
@ -762,8 +762,7 @@ static struct plugin *plugin_load(struct impl *impl, const char *type, const cha
}
spa_scnprintf(module, sizeof(module),
//"filter-graph/libspa-filter-graph-plugin-%s", type);
"libspa-filter-graph-plugin-%s", type);
"filter-graph/libspa-filter-graph-plugin-%s", type);
spa_scnprintf(factory_name, sizeof(factory_name),
"filter.graph.plugin.%s", type);
spa_scnprintf(dsp_ptr, sizeof(dsp_ptr),
@ -818,9 +817,9 @@ static void descriptor_unref(struct descriptor *desc)
return;
spa_list_remove(&desc->link);
plugin_unref(desc->plugin);
if (desc->desc)
spa_fga_descriptor_free(desc->desc);
plugin_unref(desc->plugin);
free(desc->input);
free(desc->output);
free(desc->control);
@ -2089,7 +2088,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
return 1;
}
struct spa_handle_factory spa_filter_graph_factory = {
static struct spa_handle_factory spa_filter_graph_factory = {
SPA_VERSION_HANDLE_FACTORY,
"filter.graph",
NULL,

View file

@ -358,7 +358,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
return 1;
}
struct spa_handle_factory spa_fga_plugin_ladspa_factory = {
static struct spa_handle_factory spa_fga_plugin_ladspa_factory = {
SPA_VERSION_HANDLE_FACTORY,
"filter.graph.plugin.ladspa",
NULL,

View file

@ -0,0 +1,107 @@
plugin_dependencies = []
if get_option('spa-plugins').allowed()
plugin_dependencies += audioconvert_dep
endif
simd_cargs = []
simd_dependencies = []
if have_sse
filter_graph_sse = static_library('filter_graph_sse',
['pffft.c',
'audio-dsp-sse.c' ],
include_directories : [configinc],
c_args : [sse_args, '-O3', '-DHAVE_SSE'],
dependencies : [ spa_dep ],
install : false
)
simd_cargs += ['-DHAVE_SSE']
simd_dependencies += filter_graph_sse
endif
if have_avx
filter_graph_avx = static_library('filter_graph_avx',
['audio-dsp-avx.c' ],
include_directories : [configinc],
c_args : [avx_args, fma_args,'-O3', '-DHAVE_AVX'],
dependencies : [ spa_dep ],
install : false
)
simd_cargs += ['-DHAVE_AVX']
simd_dependencies += filter_graph_avx
endif
if have_neon
filter_graph_neon = static_library('filter_graph_neon',
['pffft.c' ],
c_args : [neon_args, '-O3', '-DHAVE_NEON'],
dependencies : [ spa_dep ],
install : false
)
simd_cargs += ['-DHAVE_NEON']
simd_dependencies += filter_graph_neon
endif
filter_graph_c = static_library('filter_graph_c',
['pffft.c',
'audio-dsp.c',
'audio-dsp-c.c' ],
include_directories : [configinc],
c_args : [simd_cargs, '-O3', '-DPFFFT_SIMD_DISABLE'],
dependencies : [ spa_dep, fftw_dep],
install : false
)
simd_dependencies += filter_graph_c
spa_filter_graph = shared_library('spa-filter-graph',
['biquad.c',
'filter-graph.c' ],
include_directories : [configinc],
dependencies : [ spa_dep, sndfile_dep, plugin_dependencies, mathlib ],
install : true,
install_dir : spa_plugindir / 'filter-graph',
link_with: simd_dependencies
)
filter_graph_dependencies = [
spa_dep, mathlib, sndfile_dep, plugin_dependencies
]
spa_filter_graph_plugin_builtin = shared_library('spa-filter-graph-plugin-builtin',
[ 'builtin_plugin.c',
'convolver.c' ],
include_directories : [configinc],
install : true,
install_dir : spa_plugindir / 'filter-graph',
dependencies : [ filter_graph_dependencies ]
)
spa_filter_graph_plugin_ladspa = shared_library('spa-filter-graph-plugin-ladspa',
[ 'ladspa_plugin.c' ],
include_directories : [configinc],
install : true,
install : true,
install_dir : spa_plugindir / 'filter-graph',
dependencies : [ filter_graph_dependencies ]
)
if libmysofa_dep.found()
spa_filter_graph_plugin_sofa = shared_library('spa-filter-graph-plugin-sofa',
[ 'sofa_plugin.c',
'convolver.c' ],
include_directories : [configinc],
install : true,
install_dir : spa_plugindir / 'filter-graph',
dependencies : [ filter_graph_dependencies, libmysofa_dep ]
)
endif
if lilv_lib.found()
spa_filter_graph_plugin_lv2 = shared_library('spa-filter-graph-plugin-lv2',
[ 'lv2_plugin.c' ],
include_directories : [configinc],
install : true,
install_dir : spa_plugindir / 'filter-graph',
dependencies : [ filter_graph_dependencies, lilv_lib ]
)
endif

View file

@ -528,7 +528,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
return 1;
}
struct spa_handle_factory spa_fga_sofa_plugin_factory = {
static struct spa_handle_factory spa_fga_sofa_plugin_factory = {
SPA_VERSION_HANDLE_FACTORY,
"filter.graph.plugin.sofa",
NULL,

View file

@ -55,3 +55,4 @@ if libcamera_dep.found()
endif
subdir('aec')
subdir('filter-graph')

View file

@ -84,6 +84,7 @@ context.spa-libs = {
api.jack.* = jack/libspa-jack
support.* = support/libspa-support
video.convert.* = videoconvert/libspa-videoconvert
#filter.graph = filter-graph/libspa-filter-graph
#videotestsrc = videotestsrc/libspa-videotestsrc
#audiotestsrc = audiotestsrc/libspa-audiotestsrc
}

View file

@ -71,122 +71,15 @@ pipewire_module_loopback = shared_library('pipewire-module-loopback',
dependencies : [spa_dep, mathlib, dl_lib, pipewire_dep],
)
plugin_dependencies = []
if get_option('spa-plugins').allowed()
plugin_dependencies += audioconvert_dep
endif
simd_cargs = []
simd_dependencies = []
if have_sse
filter_graph_sse = static_library('filter_graph_sse',
['module-filter-chain/pffft.c',
'module-filter-chain/audio-dsp-sse.c' ],
include_directories : [configinc],
c_args : [sse_args, '-O3', '-DHAVE_SSE'],
dependencies : [ spa_dep ],
install : false
)
simd_cargs += ['-DHAVE_SSE']
simd_dependencies += filter_graph_sse
endif
if have_avx
filter_graph_avx = static_library('filter_graph_avx',
['module-filter-chain/audio-dsp-avx.c' ],
include_directories : [configinc],
c_args : [avx_args, fma_args,'-O3', '-DHAVE_AVX'],
dependencies : [ spa_dep ],
install : false
)
simd_cargs += ['-DHAVE_AVX']
simd_dependencies += filter_graph_avx
endif
if have_neon
filter_graph_neon = static_library('filter_graph_neon',
['module-filter-chain/pffft.c' ],
c_args : [neon_args, '-O3', '-DHAVE_NEON'],
dependencies : [ spa_dep ],
install : false
)
simd_cargs += ['-DHAVE_NEON']
simd_dependencies += filter_graph_neon
endif
filter_graph_c = static_library('filter_graph_c',
['module-filter-chain/pffft.c',
'module-filter-chain/audio-dsp.c',
'module-filter-chain/audio-dsp-c.c' ],
include_directories : [configinc],
c_args : [simd_cargs, '-O3', '-DPFFFT_SIMD_DISABLE'],
dependencies : [ spa_dep, fftw_dep],
install : false
)
simd_dependencies += filter_graph_c
filter_graph = static_library('filter_graph',
['module-filter-chain/biquad.c',
'module-filter-chain/filter-graph.c' ],
include_directories : [configinc],
dependencies : [ spa_dep, sndfile_dep, plugin_dependencies ],
install : false
)
simd_dependencies += filter_graph
filter_graph_dependencies = [
spa_dep, mathlib, dl_lib, sndfile_dep, plugin_dependencies
]
pipewire_module_filter_chain = shared_library('pipewire-module-filter-chain',
[ 'module-filter-chain.c' ],
include_directories : [configinc],
install : true,
install_dir : modules_install_dir,
install_rpath: modules_install_dir,
link_with : simd_dependencies,
dependencies : [spa_dep, mathlib, dl_lib, pipewire_dep],
)
pipewire_module_filter_graph_builtin = shared_library('spa-filter-graph-plugin-builtin',
[ 'module-filter-chain/builtin_plugin.c',
'module-filter-chain/convolver.c' ],
include_directories : [configinc],
install : true,
install_dir : spa_plugindir / 'filter-graph',
dependencies : [ filter_graph_dependencies ]
)
pipewire_module_filter_graph_ladspa = shared_library('spa-filter-graph-plugin-ladspa',
[ 'module-filter-chain/ladspa_plugin.c' ],
include_directories : [configinc],
install : true,
install : true,
install_dir : spa_plugindir / 'filter-graph',
dependencies : [ filter_graph_dependencies ]
)
if libmysofa_dep.found()
pipewire_module_filter_graph_sofa = shared_library('spa-filter-graph-plugin-sofa',
[ 'module-filter-chain/sofa_plugin.c',
'module-filter-chain/convolver.c' ],
include_directories : [configinc],
install : true,
install_dir : spa_plugindir / 'filter-graph',
dependencies : [ filter_graph_dependencies, libmysofa_dep ]
)
endif
if lilv_lib.found()
pipewire_module_filter_graph_lv2 = shared_library('spa-filter-graph-plugin-lv2',
[ 'module-filter-chain/lv2_plugin.c' ],
include_directories : [configinc],
install : true,
install_dir : spa_plugindir / 'filter-graph',
dependencies : [ filter_graph_dependencies, lilv_lib ]
)
endif
pipewire_module_combine_stream = shared_library('pipewire-module-combine-stream',
[ 'module-combine-stream.c' ],
include_directories : [configinc],

View file

@ -17,11 +17,10 @@
#include <spa/param/tag-utils.h>
#include <spa/param/audio/raw-json.h>
#include <spa/pod/dynamic.h>
#include <spa/filter-graph/filter-graph.h>
#include <pipewire/impl.h>
#include "module-filter-chain/filter-graph.h"
#define NAME "filter-chain"
PW_LOG_TOPIC_STATIC(mod_topic, "mod." NAME);
@ -1168,8 +1167,7 @@ static void impl_destroy(struct impl *impl)
pw_core_disconnect(impl->core);
if (impl->handle)
spa_handle_clear(impl->handle);
free(impl->handle);
pw_unload_spa_handle(impl->handle);
pw_properties_free(impl->capture_props);
pw_properties_free(impl->playback_props);
@ -1222,8 +1220,6 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
uint32_t pid = getpid();
const char *str;
int res;
const struct spa_support *support;
uint32_t n_support;
void *iface = NULL;
PW_LOG_TOPIC_INIT(mod_topic);
@ -1330,20 +1326,13 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
pw_properties_setf(props, "filter-graph.n_inputs", "%d", impl->capture_info.channels);
pw_properties_setf(props, "filter-graph.n_outputs", "%d", impl->playback_info.channels);
impl->handle = calloc(1, spa_handle_factory_get_size(&spa_filter_graph_factory, &props->dict));
pw_properties_set(props, SPA_KEY_LIBRARY_NAME, "filter-graph/libspa-filter-graph");
impl->handle = pw_context_load_spa_handle(impl->context, "filter.graph", &props->dict);
if (impl->handle == NULL) {
res = -errno;
goto error;
}
support = pw_context_get_support(impl->context, &n_support);
if ((res = spa_handle_factory_init(&spa_filter_graph_factory,
impl->handle, &props->dict,
support, n_support)) < 0) {
pw_log_debug("can't make factory instance: %d (%s)",
res, spa_strerror(res));
goto error;
}
res = spa_handle_get_interface(impl->handle, SPA_TYPE_INTERFACE_FilterGraph, &iface);
if (res < 0 || iface == NULL)
goto error;