mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
filter-chain: pass dict in plugin load function
So that we can pass some more properties around and remove the quantum_limit hardcoded value.
This commit is contained in:
parent
270669be0d
commit
3a167d4be1
6 changed files with 26 additions and 15 deletions
|
|
@ -620,9 +620,9 @@ static const struct spa_dict_item module_props[] = {
|
|||
#define DEFAULT_RATE 48000
|
||||
|
||||
struct fc_plugin *load_ladspa_plugin(const struct spa_support *support, uint32_t n_support,
|
||||
struct dsp_ops *dsp, const char *path, const char *config);
|
||||
struct dsp_ops *dsp, const char *path, const struct spa_dict *info);
|
||||
struct fc_plugin *load_builtin_plugin(const struct spa_support *support, uint32_t n_support,
|
||||
struct dsp_ops *dsp, const char *path, const char *config);
|
||||
struct dsp_ops *dsp, const char *path, const struct spa_dict *info);
|
||||
|
||||
struct plugin {
|
||||
struct spa_list link;
|
||||
|
|
@ -762,6 +762,7 @@ struct impl {
|
|||
struct pw_context *context;
|
||||
|
||||
struct pw_impl_module *module;
|
||||
struct pw_properties *props;
|
||||
|
||||
struct spa_hook module_listener;
|
||||
|
||||
|
|
@ -1722,7 +1723,7 @@ static struct plugin *plugin_load(struct impl *impl, const char *type, const cha
|
|||
pw_log_error("can't load plugin type '%s': %m", type);
|
||||
pl = NULL;
|
||||
} else {
|
||||
pl = plugin_func(support, n_support, &impl->dsp, path, NULL);
|
||||
pl = plugin_func(support, n_support, &impl->dsp, path, &impl->props->dict);
|
||||
}
|
||||
if (pl == NULL)
|
||||
goto exit;
|
||||
|
|
@ -2908,6 +2909,7 @@ static void impl_destroy(struct impl *impl)
|
|||
spa_list_consume(pl, &impl->plugin_func_list, link)
|
||||
free_plugin_func(pl);
|
||||
|
||||
pw_properties_free(impl->props);
|
||||
free(impl->silence_data);
|
||||
free(impl->discard_data);
|
||||
free(impl);
|
||||
|
|
@ -3007,6 +3009,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
pw_log_error( "can't create properties: %m");
|
||||
goto error;
|
||||
}
|
||||
impl->props = props;
|
||||
|
||||
impl->capture_props = pw_properties_new(NULL, NULL);
|
||||
impl->playback_props = pw_properties_new(NULL, NULL);
|
||||
|
|
@ -3031,6 +3034,8 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
pw_context_get_properties(impl->context),
|
||||
"default.clock.quantum-limit", 8192u);
|
||||
|
||||
pw_properties_setf(props, "clock.quantum-limit", "%u", impl->quantum_limit);
|
||||
|
||||
impl->silence_data = calloc(impl->quantum_limit, sizeof(float));
|
||||
if (impl->silence_data == NULL) {
|
||||
res = -errno;
|
||||
|
|
@ -3132,7 +3137,6 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
pw_log_error("can't connect: %m");
|
||||
goto error;
|
||||
}
|
||||
pw_properties_free(props);
|
||||
|
||||
pw_proxy_add_listener((struct pw_proxy*)impl->core,
|
||||
&impl->core_proxy_listener,
|
||||
|
|
@ -3150,7 +3154,6 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
return 0;
|
||||
|
||||
error:
|
||||
pw_properties_free(props);
|
||||
impl_destroy(impl);
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1760,7 +1760,7 @@ static void builtin_plugin_unload(struct fc_plugin *p)
|
|||
}
|
||||
|
||||
struct fc_plugin *load_builtin_plugin(const struct spa_support *support, uint32_t n_support,
|
||||
struct dsp_ops *dsp, const char *plugin, const char *config)
|
||||
struct dsp_ops *dsp, const char *plugin, const struct spa_dict *info)
|
||||
{
|
||||
struct plugin *impl = calloc (1, sizeof (struct plugin));
|
||||
impl->plugin.make_desc = builtin_make_desc;
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ exit:
|
|||
}
|
||||
|
||||
struct fc_plugin *load_ladspa_plugin(const struct spa_support *support, uint32_t n_support,
|
||||
struct dsp_ops *dsp, const char *plugin, const char *config)
|
||||
struct dsp_ops *dsp, const char *plugin, const struct spa_dict *info)
|
||||
{
|
||||
struct fc_plugin *pl = NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -460,7 +460,7 @@ static void lv2_unload(struct fc_plugin *plugin)
|
|||
|
||||
SPA_EXPORT
|
||||
struct fc_plugin *pipewire__filter_chain_plugin_load(const struct spa_support *support, uint32_t n_support,
|
||||
struct dsp_ops *ops, const char *plugin_uri, const char *config)
|
||||
struct dsp_ops *dsp, const char *plugin_uri, const struct spa_dict *info)
|
||||
{
|
||||
struct context *c;
|
||||
const LilvPlugins *plugins;
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ static inline void fc_descriptor_free(const struct fc_descriptor *desc)
|
|||
#define FC_PLUGIN_LOAD_FUNC "pipewire__filter_chain_plugin_load"
|
||||
|
||||
typedef struct fc_plugin *(fc_plugin_load_func)(const struct spa_support *support, uint32_t n_support,
|
||||
struct dsp_ops *dsp, const char *path, const char *config);
|
||||
struct dsp_ops *dsp, const char *path, const struct spa_dict *info);
|
||||
|
||||
|
||||
#endif /* PLUGIN_H */
|
||||
|
|
|
|||
|
|
@ -14,13 +14,12 @@
|
|||
|
||||
#include <mysofa.h>
|
||||
|
||||
#define MAX_SAMPLES 8192u
|
||||
|
||||
struct plugin {
|
||||
struct fc_plugin plugin;
|
||||
struct dsp_ops *dsp_ops;
|
||||
struct spa_loop *data_loop;
|
||||
struct spa_loop *main_loop;
|
||||
uint32_t quantum_limit;
|
||||
};
|
||||
|
||||
struct spatializer_impl {
|
||||
|
|
@ -180,8 +179,8 @@ static void * spatializer_instantiate(const struct fc_plugin *plugin, const stru
|
|||
pw_log_info("using n_samples:%u %d:%d blocksize sofa:%s", impl->n_samples,
|
||||
impl->blocksize, impl->tailsize, filename);
|
||||
|
||||
impl->tmp[0] = calloc(MAX_SAMPLES, sizeof(float));
|
||||
impl->tmp[1] = calloc(MAX_SAMPLES, sizeof(float));
|
||||
impl->tmp[0] = calloc(impl->plugin->quantum_limit, sizeof(float));
|
||||
impl->tmp[1] = calloc(impl->plugin->quantum_limit, sizeof(float));
|
||||
impl->rate = SampleRate;
|
||||
return impl;
|
||||
error:
|
||||
|
|
@ -280,7 +279,7 @@ static void spatializer_run(void * Instance, unsigned long SampleCount)
|
|||
struct spatializer_impl *impl = Instance;
|
||||
|
||||
if (impl->interpolate) {
|
||||
uint32_t len = SPA_MIN(SampleCount, MAX_SAMPLES);
|
||||
uint32_t len = SPA_MIN(SampleCount, impl->plugin->quantum_limit);
|
||||
struct free_data free_data;
|
||||
float *l = impl->tmp[0], *r = impl->tmp[1];
|
||||
|
||||
|
|
@ -425,12 +424,21 @@ static void sofa_plugin_unload(struct fc_plugin *p)
|
|||
|
||||
SPA_EXPORT
|
||||
struct fc_plugin *pipewire__filter_chain_plugin_load(const struct spa_support *support, uint32_t n_support,
|
||||
struct dsp_ops *dsp, const char *plugin, const char *config)
|
||||
struct dsp_ops *dsp, const char *plugin, const struct spa_dict *info)
|
||||
{
|
||||
struct plugin *impl = calloc(1, sizeof (struct plugin));
|
||||
|
||||
impl->plugin.make_desc = sofa_make_desc;
|
||||
impl->plugin.unload = sofa_plugin_unload;
|
||||
|
||||
impl->quantum_limit = 8192u;
|
||||
|
||||
for (uint32_t i = 0; info && i < info->n_items; i++) {
|
||||
const char *k = info->items[i].key;
|
||||
const char *s = info->items[i].value;
|
||||
if (spa_streq(k, "clock.quantum-limit"))
|
||||
spa_atou32(s, &impl->quantum_limit, 0);
|
||||
}
|
||||
impl->dsp_ops = dsp;
|
||||
pffft_select_cpu(dsp->cpu_flags);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue