filter-chain: move the plugin to an audio-plugin

Make an interface of the audio plugins.
This commit is contained in:
Wim Taymans 2024-11-12 12:51:15 +01:00
parent c8c89f7517
commit 0a71911796
7 changed files with 429 additions and 363 deletions

View file

@ -0,0 +1,115 @@
/* PipeWire */
/* SPDX-FileCopyrightText: Copyright © 2021 Wim Taymans */
/* SPDX-License-Identifier: MIT */
#ifndef SPA_FGA_PLUGIN_H
#define SPA_FGA_PLUGIN_H
#include <stdint.h>
#include <stddef.h>
#include <spa/utils/defs.h>
#include <spa/utils/hook.h>
#include <spa/support/plugin.h>
#include "dsp-ops.h"
#define SPA_TYPE_INTERFACE_FILTER_GRAPH_AudioPlugin SPA_TYPE_INFO_INTERFACE_BASE "FilterGraph:AudioPlugin"
#define SPA_VERSION_FGA_PLUGIN 0
struct spa_fga_plugin { struct spa_interface iface; };
struct spa_fga_plugin_methods {
#define SPA_VERSION_FGA_PLUGIN_METHODS 0
uint32_t version;
const struct spa_fga_descriptor *(*make_desc) (void *plugin, const char *name);
void (*free) (void *plugin);
};
struct spa_fga_port {
uint32_t index;
const char *name;
#define SPA_FGA_PORT_INPUT (1ULL << 0)
#define SPA_FGA_PORT_OUTPUT (1ULL << 1)
#define SPA_FGA_PORT_CONTROL (1ULL << 2)
#define SPA_FGA_PORT_AUDIO (1ULL << 3)
uint64_t flags;
#define SPA_FGA_HINT_BOOLEAN (1ULL << 2)
#define SPA_FGA_HINT_SAMPLE_RATE (1ULL << 3)
#define SPA_FGA_HINT_INTEGER (1ULL << 5)
uint64_t hint;
float def;
float min;
float max;
};
#define SPA_FGA_IS_PORT_INPUT(x) ((x) & SPA_FGA_PORT_INPUT)
#define SPA_FGA_IS_PORT_OUTPUT(x) ((x) & SPA_FGA_PORT_OUTPUT)
#define SPA_FGA_IS_PORT_CONTROL(x) ((x) & SPA_FGA_PORT_CONTROL)
#define SPA_FGA_IS_PORT_AUDIO(x) ((x) & SPA_FGA_PORT_AUDIO)
struct spa_fga_descriptor {
const char *name;
#define SPA_FGA_DESCRIPTOR_SUPPORTS_NULL_DATA (1ULL << 0)
#define SPA_FGA_DESCRIPTOR_COPY (1ULL << 1)
uint64_t flags;
void (*free) (const struct spa_fga_descriptor *desc);
uint32_t n_ports;
struct spa_fga_port *ports;
void *(*instantiate) (const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor *desc,
unsigned long SampleRate, int index, const char *config);
void (*cleanup) (void *instance);
void (*connect_port) (void *instance, unsigned long port, float *data);
void (*control_changed) (void *instance);
void (*activate) (void *instance);
void (*deactivate) (void *instance);
void (*run) (void *instance, unsigned long SampleCount);
};
static inline void spa_fga_descriptor_free(const struct spa_fga_descriptor *desc)
{
if (desc->free)
desc->free(desc);
}
#define spa_fga_plugin_method_r(o,method,version,...) \
({ \
const void * _res = NULL; \
struct spa_fga_plugin *_o = o; \
spa_interface_call_fast_res(&_o->iface, \
struct spa_fga_plugin_methods, _res, \
method, version, ##__VA_ARGS__); \
_res; \
})
#define spa_fga_plugin_method(o,method,version,...) \
({ \
struct spa_fga_plugin *_o = o; \
spa_interface_call_fast(&_o->iface, \
struct spa_fga_plugin_methods, \
method, version, ##__VA_ARGS__); \
})
#define spa_fga_plugin_make_desc(o,...) spa_fga_plugin_method_r(o,make_desc,0,__VA_ARGS__)
#define spa_fga_plugin_free(o,...) spa_fga_plugin_method(o,free,0,##__VA_ARGS__)
typedef struct spa_fga_plugin *(spa_filter_graph_audio_plugin_load_func_t)(const struct spa_support *support,
uint32_t n_support, struct dsp_ops *dsp,
const char *path, const struct spa_dict *info);
#define SPA_FILTER_GRAPH_AUDIO_PLUGIN_LOAD_FUNC_NAME "spa_filter_graph_audio_plugin_load"
#endif /* PLUGIN_H */

View file

@ -18,7 +18,7 @@
#include <spa/support/log.h> #include <spa/support/log.h>
#include <spa/plugins/audioconvert/resample.h> #include <spa/plugins/audioconvert/resample.h>
#include "plugin.h" #include "audio-plugin.h"
#include "biquad.h" #include "biquad.h"
#include "pffft.h" #include "pffft.h"
@ -28,7 +28,7 @@
#define MAX_RATES 32u #define MAX_RATES 32u
struct plugin { struct plugin {
struct fc_plugin plugin; struct spa_fga_plugin plugin;
struct dsp_ops *dsp; struct dsp_ops *dsp;
struct spa_log *log; struct spa_log *log;
}; };
@ -52,7 +52,7 @@ struct builtin {
float accum; float accum;
}; };
static void *builtin_instantiate(const struct fc_plugin *plugin, const struct fc_descriptor * Descriptor, static void *builtin_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor * Descriptor,
unsigned long SampleRate, int index, const char *config) unsigned long SampleRate, int index, const char *config)
{ {
struct builtin *impl; struct builtin *impl;
@ -89,20 +89,20 @@ static void copy_run(void * Instance, unsigned long SampleCount)
dsp_ops_copy(impl->dsp, out, in, SampleCount); dsp_ops_copy(impl->dsp, out, in, SampleCount);
} }
static struct fc_port copy_ports[] = { static struct spa_fga_port copy_ports[] = {
{ .index = 0, { .index = 0,
.name = "Out", .name = "Out",
.flags = FC_PORT_OUTPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_OUTPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 1, { .index = 1,
.name = "In", .name = "In",
.flags = FC_PORT_INPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
} }
}; };
static const struct fc_descriptor copy_desc = { static const struct spa_fga_descriptor copy_desc = {
.name = "copy", .name = "copy",
.flags = FC_DESCRIPTOR_COPY, .flags = SPA_FGA_DESCRIPTOR_COPY,
.n_ports = 2, .n_ports = 2,
.ports = copy_ports, .ports = copy_ports,
@ -138,90 +138,90 @@ static void mixer_run(void * Instance, unsigned long SampleCount)
dsp_ops_mix_gain(impl->dsp, out, src, gains, n_src, SampleCount); dsp_ops_mix_gain(impl->dsp, out, src, gains, n_src, SampleCount);
} }
static struct fc_port mixer_ports[] = { static struct spa_fga_port mixer_ports[] = {
{ .index = 0, { .index = 0,
.name = "Out", .name = "Out",
.flags = FC_PORT_OUTPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_OUTPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 1, { .index = 1,
.name = "In 1", .name = "In 1",
.flags = FC_PORT_INPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 2, { .index = 2,
.name = "In 2", .name = "In 2",
.flags = FC_PORT_INPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 3, { .index = 3,
.name = "In 3", .name = "In 3",
.flags = FC_PORT_INPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 4, { .index = 4,
.name = "In 4", .name = "In 4",
.flags = FC_PORT_INPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 5, { .index = 5,
.name = "In 5", .name = "In 5",
.flags = FC_PORT_INPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 6, { .index = 6,
.name = "In 6", .name = "In 6",
.flags = FC_PORT_INPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 7, { .index = 7,
.name = "In 7", .name = "In 7",
.flags = FC_PORT_INPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 8, { .index = 8,
.name = "In 8", .name = "In 8",
.flags = FC_PORT_INPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 9, { .index = 9,
.name = "Gain 1", .name = "Gain 1",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
.def = 1.0f, .min = 0.0f, .max = 10.0f .def = 1.0f, .min = 0.0f, .max = 10.0f
}, },
{ .index = 10, { .index = 10,
.name = "Gain 2", .name = "Gain 2",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
.def = 1.0f, .min = 0.0f, .max = 10.0f .def = 1.0f, .min = 0.0f, .max = 10.0f
}, },
{ .index = 11, { .index = 11,
.name = "Gain 3", .name = "Gain 3",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
.def = 1.0f, .min = 0.0f, .max = 10.0f .def = 1.0f, .min = 0.0f, .max = 10.0f
}, },
{ .index = 12, { .index = 12,
.name = "Gain 4", .name = "Gain 4",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
.def = 1.0f, .min = 0.0f, .max = 10.0f .def = 1.0f, .min = 0.0f, .max = 10.0f
}, },
{ .index = 13, { .index = 13,
.name = "Gain 5", .name = "Gain 5",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
.def = 1.0f, .min = 0.0f, .max = 10.0f .def = 1.0f, .min = 0.0f, .max = 10.0f
}, },
{ .index = 14, { .index = 14,
.name = "Gain 6", .name = "Gain 6",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
.def = 1.0f, .min = 0.0f, .max = 10.0f .def = 1.0f, .min = 0.0f, .max = 10.0f
}, },
{ .index = 15, { .index = 15,
.name = "Gain 7", .name = "Gain 7",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
.def = 1.0f, .min = 0.0f, .max = 10.0f .def = 1.0f, .min = 0.0f, .max = 10.0f
}, },
{ .index = 16, { .index = 16,
.name = "Gain 8", .name = "Gain 8",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
.def = 1.0f, .min = 0.0f, .max = 10.0f .def = 1.0f, .min = 0.0f, .max = 10.0f
}, },
}; };
static const struct fc_descriptor mixer_desc = { static const struct spa_fga_descriptor mixer_desc = {
.name = "mixer", .name = "mixer",
.flags = FC_DESCRIPTOR_SUPPORTS_NULL_DATA, .flags = SPA_FGA_DESCRIPTOR_SUPPORTS_NULL_DATA,
.n_ports = 17, .n_ports = 17,
.ports = mixer_ports, .ports = mixer_ports,
@ -311,7 +311,7 @@ static void bq_raw_update(struct builtin *impl, float b0, float b1, float b2,
* ] * ]
* } * }
*/ */
static void *bq_instantiate(const struct fc_plugin *plugin, const struct fc_descriptor * Descriptor, static void *bq_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor * Descriptor,
unsigned long SampleRate, int index, const char *config) unsigned long SampleRate, int index, const char *config)
{ {
struct builtin *impl; struct builtin *impl;
@ -423,59 +423,59 @@ error:
} }
#define BQ_NUM_PORTS 11 #define BQ_NUM_PORTS 11
static struct fc_port bq_ports[] = { static struct spa_fga_port bq_ports[] = {
{ .index = 0, { .index = 0,
.name = "Out", .name = "Out",
.flags = FC_PORT_OUTPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_OUTPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 1, { .index = 1,
.name = "In", .name = "In",
.flags = FC_PORT_INPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 2, { .index = 2,
.name = "Freq", .name = "Freq",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
.hint = FC_HINT_SAMPLE_RATE, .hint = SPA_FGA_HINT_SAMPLE_RATE,
.def = 0.0f, .min = 0.0f, .max = 1.0f, .def = 0.0f, .min = 0.0f, .max = 1.0f,
}, },
{ .index = 3, { .index = 3,
.name = "Q", .name = "Q",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
.def = 0.0f, .min = 0.0f, .max = 10.0f, .def = 0.0f, .min = 0.0f, .max = 10.0f,
}, },
{ .index = 4, { .index = 4,
.name = "Gain", .name = "Gain",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
.def = 0.0f, .min = -120.0f, .max = 20.0f, .def = 0.0f, .min = -120.0f, .max = 20.0f,
}, },
{ .index = 5, { .index = 5,
.name = "b0", .name = "b0",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
.def = 1.0f, .min = -10.0f, .max = 10.0f, .def = 1.0f, .min = -10.0f, .max = 10.0f,
}, },
{ .index = 6, { .index = 6,
.name = "b1", .name = "b1",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
.def = 0.0f, .min = -10.0f, .max = 10.0f, .def = 0.0f, .min = -10.0f, .max = 10.0f,
}, },
{ .index = 7, { .index = 7,
.name = "b2", .name = "b2",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
.def = 0.0f, .min = -10.0f, .max = 10.0f, .def = 0.0f, .min = -10.0f, .max = 10.0f,
}, },
{ .index = 8, { .index = 8,
.name = "a0", .name = "a0",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
.def = 1.0f, .min = -10.0f, .max = 10.0f, .def = 1.0f, .min = -10.0f, .max = 10.0f,
}, },
{ .index = 9, { .index = 9,
.name = "a1", .name = "a1",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
.def = 0.0f, .min = -10.0f, .max = 10.0f, .def = 0.0f, .min = -10.0f, .max = 10.0f,
}, },
{ .index = 10, { .index = 10,
.name = "a2", .name = "a2",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
.def = 0.0f, .min = -10.0f, .max = 10.0f, .def = 0.0f, .min = -10.0f, .max = 10.0f,
}, },
@ -544,7 +544,7 @@ static void bq_run(void *Instance, unsigned long samples)
} }
/** bq_lowpass */ /** bq_lowpass */
static const struct fc_descriptor bq_lowpass_desc = { static const struct spa_fga_descriptor bq_lowpass_desc = {
.name = "bq_lowpass", .name = "bq_lowpass",
.n_ports = BQ_NUM_PORTS, .n_ports = BQ_NUM_PORTS,
@ -558,7 +558,7 @@ static const struct fc_descriptor bq_lowpass_desc = {
}; };
/** bq_highpass */ /** bq_highpass */
static const struct fc_descriptor bq_highpass_desc = { static const struct spa_fga_descriptor bq_highpass_desc = {
.name = "bq_highpass", .name = "bq_highpass",
.n_ports = BQ_NUM_PORTS, .n_ports = BQ_NUM_PORTS,
@ -572,7 +572,7 @@ static const struct fc_descriptor bq_highpass_desc = {
}; };
/** bq_bandpass */ /** bq_bandpass */
static const struct fc_descriptor bq_bandpass_desc = { static const struct spa_fga_descriptor bq_bandpass_desc = {
.name = "bq_bandpass", .name = "bq_bandpass",
.n_ports = BQ_NUM_PORTS, .n_ports = BQ_NUM_PORTS,
@ -586,7 +586,7 @@ static const struct fc_descriptor bq_bandpass_desc = {
}; };
/** bq_lowshelf */ /** bq_lowshelf */
static const struct fc_descriptor bq_lowshelf_desc = { static const struct spa_fga_descriptor bq_lowshelf_desc = {
.name = "bq_lowshelf", .name = "bq_lowshelf",
.n_ports = BQ_NUM_PORTS, .n_ports = BQ_NUM_PORTS,
@ -600,7 +600,7 @@ static const struct fc_descriptor bq_lowshelf_desc = {
}; };
/** bq_highshelf */ /** bq_highshelf */
static const struct fc_descriptor bq_highshelf_desc = { static const struct spa_fga_descriptor bq_highshelf_desc = {
.name = "bq_highshelf", .name = "bq_highshelf",
.n_ports = BQ_NUM_PORTS, .n_ports = BQ_NUM_PORTS,
@ -614,7 +614,7 @@ static const struct fc_descriptor bq_highshelf_desc = {
}; };
/** bq_peaking */ /** bq_peaking */
static const struct fc_descriptor bq_peaking_desc = { static const struct spa_fga_descriptor bq_peaking_desc = {
.name = "bq_peaking", .name = "bq_peaking",
.n_ports = BQ_NUM_PORTS, .n_ports = BQ_NUM_PORTS,
@ -628,7 +628,7 @@ static const struct fc_descriptor bq_peaking_desc = {
}; };
/** bq_notch */ /** bq_notch */
static const struct fc_descriptor bq_notch_desc = { static const struct spa_fga_descriptor bq_notch_desc = {
.name = "bq_notch", .name = "bq_notch",
.n_ports = BQ_NUM_PORTS, .n_ports = BQ_NUM_PORTS,
@ -643,7 +643,7 @@ static const struct fc_descriptor bq_notch_desc = {
/** bq_allpass */ /** bq_allpass */
static const struct fc_descriptor bq_allpass_desc = { static const struct spa_fga_descriptor bq_allpass_desc = {
.name = "bq_allpass", .name = "bq_allpass",
.n_ports = BQ_NUM_PORTS, .n_ports = BQ_NUM_PORTS,
@ -657,7 +657,7 @@ static const struct fc_descriptor bq_allpass_desc = {
}; };
/* bq_raw */ /* bq_raw */
static const struct fc_descriptor bq_raw_desc = { static const struct spa_fga_descriptor bq_raw_desc = {
.name = "bq_raw", .name = "bq_raw",
.n_ports = BQ_NUM_PORTS, .n_ports = BQ_NUM_PORTS,
@ -902,7 +902,7 @@ error:
#endif #endif
} }
static void * convolver_instantiate(const struct fc_plugin *plugin, const struct fc_descriptor * Descriptor, static void * convolver_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor * Descriptor,
unsigned long SampleRate, int index, const char *config) unsigned long SampleRate, int index, const char *config)
{ {
struct convolver_impl *impl; struct convolver_impl *impl;
@ -1082,14 +1082,14 @@ static void convolver_cleanup(void * Instance)
free(impl); free(impl);
} }
static struct fc_port convolve_ports[] = { static struct spa_fga_port convolve_ports[] = {
{ .index = 0, { .index = 0,
.name = "Out", .name = "Out",
.flags = FC_PORT_OUTPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_OUTPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 1, { .index = 1,
.name = "In", .name = "In",
.flags = FC_PORT_INPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
}, },
}; };
@ -1106,9 +1106,9 @@ static void convolve_run(void * Instance, unsigned long SampleCount)
convolver_run(impl->conv, impl->port[1], impl->port[0], SampleCount); convolver_run(impl->conv, impl->port[1], impl->port[0], SampleCount);
} }
static const struct fc_descriptor convolve_desc = { static const struct spa_fga_descriptor convolve_desc = {
.name = "convolver", .name = "convolver",
.flags = FC_DESCRIPTOR_SUPPORTS_NULL_DATA, .flags = SPA_FGA_DESCRIPTOR_SUPPORTS_NULL_DATA,
.n_ports = 2, .n_ports = 2,
.ports = convolve_ports, .ports = convolve_ports,
@ -1144,7 +1144,7 @@ static void delay_cleanup(void * Instance)
free(impl); free(impl);
} }
static void *delay_instantiate(const struct fc_plugin *plugin, const struct fc_descriptor * Descriptor, static void *delay_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor * Descriptor,
unsigned long SampleRate, int index, const char *config) unsigned long SampleRate, int index, const char *config)
{ {
struct plugin *pl = (struct plugin*) plugin; struct plugin *pl = (struct plugin*) plugin;
@ -1224,25 +1224,25 @@ static void delay_run(void * Instance, unsigned long SampleCount)
impl->delay_samples, out, in, SampleCount); impl->delay_samples, out, in, SampleCount);
} }
static struct fc_port delay_ports[] = { static struct spa_fga_port delay_ports[] = {
{ .index = 0, { .index = 0,
.name = "Out", .name = "Out",
.flags = FC_PORT_OUTPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_OUTPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 1, { .index = 1,
.name = "In", .name = "In",
.flags = FC_PORT_INPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 2, { .index = 2,
.name = "Delay (s)", .name = "Delay (s)",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
.def = 0.0f, .min = 0.0f, .max = 100.0f .def = 0.0f, .min = 0.0f, .max = 100.0f
}, },
}; };
static const struct fc_descriptor delay_desc = { static const struct spa_fga_descriptor delay_desc = {
.name = "delay", .name = "delay",
.flags = FC_DESCRIPTOR_SUPPORTS_NULL_DATA, .flags = SPA_FGA_DESCRIPTOR_SUPPORTS_NULL_DATA,
.n_ports = 3, .n_ports = 3,
.ports = delay_ports, .ports = delay_ports,
@ -1263,18 +1263,18 @@ static void invert_run(void * Instance, unsigned long SampleCount)
out[n] = -in[n]; out[n] = -in[n];
} }
static struct fc_port invert_ports[] = { static struct spa_fga_port invert_ports[] = {
{ .index = 0, { .index = 0,
.name = "Out", .name = "Out",
.flags = FC_PORT_OUTPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_OUTPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 1, { .index = 1,
.name = "In", .name = "In",
.flags = FC_PORT_INPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
}, },
}; };
static const struct fc_descriptor invert_desc = { static const struct spa_fga_descriptor invert_desc = {
.name = "invert", .name = "invert",
.n_ports = 2, .n_ports = 2,
@ -1303,38 +1303,38 @@ static void clamp_run(void * Instance, unsigned long SampleCount)
notify[0] = SPA_CLAMPF(ctrl[0], min, max); notify[0] = SPA_CLAMPF(ctrl[0], min, max);
} }
static struct fc_port clamp_ports[] = { static struct spa_fga_port clamp_ports[] = {
{ .index = 0, { .index = 0,
.name = "Out", .name = "Out",
.flags = FC_PORT_OUTPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_OUTPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 1, { .index = 1,
.name = "In", .name = "In",
.flags = FC_PORT_INPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 2, { .index = 2,
.name = "Notify", .name = "Notify",
.flags = FC_PORT_OUTPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_OUTPUT | SPA_FGA_PORT_CONTROL,
}, },
{ .index = 3, { .index = 3,
.name = "Control", .name = "Control",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
}, },
{ .index = 4, { .index = 4,
.name = "Min", .name = "Min",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
.def = 0.0f, .min = -100.0f, .max = 100.0f .def = 0.0f, .min = -100.0f, .max = 100.0f
}, },
{ .index = 5, { .index = 5,
.name = "Max", .name = "Max",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
.def = 1.0f, .min = -100.0f, .max = 100.0f .def = 1.0f, .min = -100.0f, .max = 100.0f
}, },
}; };
static const struct fc_descriptor clamp_desc = { static const struct spa_fga_descriptor clamp_desc = {
.name = "clamp", .name = "clamp",
.flags = FC_DESCRIPTOR_SUPPORTS_NULL_DATA, .flags = SPA_FGA_DESCRIPTOR_SUPPORTS_NULL_DATA,
.n_ports = SPA_N_ELEMENTS(clamp_ports), .n_ports = SPA_N_ELEMENTS(clamp_ports),
.ports = clamp_ports, .ports = clamp_ports,
@ -1360,38 +1360,38 @@ static void linear_run(void * Instance, unsigned long SampleCount)
notify[0] = ctrl[0] * mult + add; notify[0] = ctrl[0] * mult + add;
} }
static struct fc_port linear_ports[] = { static struct spa_fga_port linear_ports[] = {
{ .index = 0, { .index = 0,
.name = "Out", .name = "Out",
.flags = FC_PORT_OUTPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_OUTPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 1, { .index = 1,
.name = "In", .name = "In",
.flags = FC_PORT_INPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 2, { .index = 2,
.name = "Notify", .name = "Notify",
.flags = FC_PORT_OUTPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_OUTPUT | SPA_FGA_PORT_CONTROL,
}, },
{ .index = 3, { .index = 3,
.name = "Control", .name = "Control",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
}, },
{ .index = 4, { .index = 4,
.name = "Mult", .name = "Mult",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
.def = 1.0f, .min = -10.0f, .max = 10.0f .def = 1.0f, .min = -10.0f, .max = 10.0f
}, },
{ .index = 5, { .index = 5,
.name = "Add", .name = "Add",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
.def = 0.0f, .min = -10.0f, .max = 10.0f .def = 0.0f, .min = -10.0f, .max = 10.0f
}, },
}; };
static const struct fc_descriptor linear_desc = { static const struct spa_fga_descriptor linear_desc = {
.name = "linear", .name = "linear",
.flags = FC_DESCRIPTOR_SUPPORTS_NULL_DATA, .flags = SPA_FGA_DESCRIPTOR_SUPPORTS_NULL_DATA,
.n_ports = SPA_N_ELEMENTS(linear_ports), .n_ports = SPA_N_ELEMENTS(linear_ports),
.ports = linear_ports, .ports = linear_ports,
@ -1427,28 +1427,28 @@ static void recip_run(void * Instance, unsigned long SampleCount)
} }
} }
static struct fc_port recip_ports[] = { static struct spa_fga_port recip_ports[] = {
{ .index = 0, { .index = 0,
.name = "Out", .name = "Out",
.flags = FC_PORT_OUTPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_OUTPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 1, { .index = 1,
.name = "In", .name = "In",
.flags = FC_PORT_INPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 2, { .index = 2,
.name = "Notify", .name = "Notify",
.flags = FC_PORT_OUTPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_OUTPUT | SPA_FGA_PORT_CONTROL,
}, },
{ .index = 3, { .index = 3,
.name = "Control", .name = "Control",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
}, },
}; };
static const struct fc_descriptor recip_desc = { static const struct spa_fga_descriptor recip_desc = {
.name = "recip", .name = "recip",
.flags = FC_DESCRIPTOR_SUPPORTS_NULL_DATA, .flags = SPA_FGA_DESCRIPTOR_SUPPORTS_NULL_DATA,
.n_ports = SPA_N_ELEMENTS(recip_ports), .n_ports = SPA_N_ELEMENTS(recip_ports),
.ports = recip_ports, .ports = recip_ports,
@ -1476,33 +1476,33 @@ static void exp_run(void * Instance, unsigned long SampleCount)
notify[0] = powf(base, ctrl[0]); notify[0] = powf(base, ctrl[0]);
} }
static struct fc_port exp_ports[] = { static struct spa_fga_port exp_ports[] = {
{ .index = 0, { .index = 0,
.name = "Out", .name = "Out",
.flags = FC_PORT_OUTPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_OUTPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 1, { .index = 1,
.name = "In", .name = "In",
.flags = FC_PORT_INPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 2, { .index = 2,
.name = "Notify", .name = "Notify",
.flags = FC_PORT_OUTPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_OUTPUT | SPA_FGA_PORT_CONTROL,
}, },
{ .index = 3, { .index = 3,
.name = "Control", .name = "Control",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
}, },
{ .index = 4, { .index = 4,
.name = "Base", .name = "Base",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
.def = (float)M_E, .min = -10.0f, .max = 10.0f .def = (float)M_E, .min = -10.0f, .max = 10.0f
}, },
}; };
static const struct fc_descriptor exp_desc = { static const struct spa_fga_descriptor exp_desc = {
.name = "exp", .name = "exp",
.flags = FC_DESCRIPTOR_SUPPORTS_NULL_DATA, .flags = SPA_FGA_DESCRIPTOR_SUPPORTS_NULL_DATA,
.n_ports = SPA_N_ELEMENTS(exp_ports), .n_ports = SPA_N_ELEMENTS(exp_ports),
.ports = exp_ports, .ports = exp_ports,
@ -1533,43 +1533,43 @@ static void log_run(void * Instance, unsigned long SampleCount)
notify[0] = m2 * log2f(fabsf(ctrl[0] * m1)) / lb; notify[0] = m2 * log2f(fabsf(ctrl[0] * m1)) / lb;
} }
static struct fc_port log_ports[] = { static struct spa_fga_port log_ports[] = {
{ .index = 0, { .index = 0,
.name = "Out", .name = "Out",
.flags = FC_PORT_OUTPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_OUTPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 1, { .index = 1,
.name = "In", .name = "In",
.flags = FC_PORT_INPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 2, { .index = 2,
.name = "Notify", .name = "Notify",
.flags = FC_PORT_OUTPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_OUTPUT | SPA_FGA_PORT_CONTROL,
}, },
{ .index = 3, { .index = 3,
.name = "Control", .name = "Control",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
}, },
{ .index = 4, { .index = 4,
.name = "Base", .name = "Base",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
.def = (float)M_E, .min = 2.0f, .max = 100.0f .def = (float)M_E, .min = 2.0f, .max = 100.0f
}, },
{ .index = 5, { .index = 5,
.name = "M1", .name = "M1",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
.def = 1.0f, .min = -10.0f, .max = 10.0f .def = 1.0f, .min = -10.0f, .max = 10.0f
}, },
{ .index = 6, { .index = 6,
.name = "M2", .name = "M2",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
.def = 1.0f, .min = -10.0f, .max = 10.0f .def = 1.0f, .min = -10.0f, .max = 10.0f
}, },
}; };
static const struct fc_descriptor log_desc = { static const struct spa_fga_descriptor log_desc = {
.name = "log", .name = "log",
.flags = FC_DESCRIPTOR_SUPPORTS_NULL_DATA, .flags = SPA_FGA_DESCRIPTOR_SUPPORTS_NULL_DATA,
.n_ports = SPA_N_ELEMENTS(log_ports), .n_ports = SPA_N_ELEMENTS(log_ports),
.ports = log_ports, .ports = log_ports,
@ -1602,48 +1602,48 @@ static void mult_run(void * Instance, unsigned long SampleCount)
dsp_ops_mult(impl->dsp, out, src, n_src, SampleCount); dsp_ops_mult(impl->dsp, out, src, n_src, SampleCount);
} }
static struct fc_port mult_ports[] = { static struct spa_fga_port mult_ports[] = {
{ .index = 0, { .index = 0,
.name = "Out", .name = "Out",
.flags = FC_PORT_OUTPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_OUTPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 1, { .index = 1,
.name = "In 1", .name = "In 1",
.flags = FC_PORT_INPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 2, { .index = 2,
.name = "In 2", .name = "In 2",
.flags = FC_PORT_INPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 3, { .index = 3,
.name = "In 3", .name = "In 3",
.flags = FC_PORT_INPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 4, { .index = 4,
.name = "In 4", .name = "In 4",
.flags = FC_PORT_INPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 5, { .index = 5,
.name = "In 5", .name = "In 5",
.flags = FC_PORT_INPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 6, { .index = 6,
.name = "In 6", .name = "In 6",
.flags = FC_PORT_INPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 7, { .index = 7,
.name = "In 7", .name = "In 7",
.flags = FC_PORT_INPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 8, { .index = 8,
.name = "In 8", .name = "In 8",
.flags = FC_PORT_INPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
}, },
}; };
static const struct fc_descriptor mult_desc = { static const struct spa_fga_descriptor mult_desc = {
.name = "mult", .name = "mult",
.flags = FC_DESCRIPTOR_SUPPORTS_NULL_DATA, .flags = SPA_FGA_DESCRIPTOR_SUPPORTS_NULL_DATA,
.n_ports = SPA_N_ELEMENTS(mult_ports), .n_ports = SPA_N_ELEMENTS(mult_ports),
.ports = mult_ports, .ports = mult_ports,
@ -1679,40 +1679,40 @@ static void sine_run(void * Instance, unsigned long SampleCount)
} }
} }
static struct fc_port sine_ports[] = { static struct spa_fga_port sine_ports[] = {
{ .index = 0, { .index = 0,
.name = "Out", .name = "Out",
.flags = FC_PORT_OUTPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_OUTPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 1, { .index = 1,
.name = "Notify", .name = "Notify",
.flags = FC_PORT_OUTPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_OUTPUT | SPA_FGA_PORT_CONTROL,
}, },
{ .index = 2, { .index = 2,
.name = "Freq", .name = "Freq",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
.def = 440.0f, .min = 0.0f, .max = 1000000.0f .def = 440.0f, .min = 0.0f, .max = 1000000.0f
}, },
{ .index = 3, { .index = 3,
.name = "Ampl", .name = "Ampl",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
.def = 1.0, .min = 0.0f, .max = 10.0f .def = 1.0, .min = 0.0f, .max = 10.0f
}, },
{ .index = 4, { .index = 4,
.name = "Phase", .name = "Phase",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
.def = 0.0f, .min = (float)-M_PI, .max = (float)M_PI .def = 0.0f, .min = (float)-M_PI, .max = (float)M_PI
}, },
{ .index = 5, { .index = 5,
.name = "Offset", .name = "Offset",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
.def = 0.0f, .min = -10.0f, .max = 10.0f .def = 0.0f, .min = -10.0f, .max = 10.0f
}, },
}; };
static const struct fc_descriptor sine_desc = { static const struct spa_fga_descriptor sine_desc = {
.name = "sine", .name = "sine",
.flags = FC_DESCRIPTOR_SUPPORTS_NULL_DATA, .flags = SPA_FGA_DESCRIPTOR_SUPPORTS_NULL_DATA,
.n_ports = SPA_N_ELEMENTS(sine_ports), .n_ports = SPA_N_ELEMENTS(sine_ports),
.ports = sine_ports, .ports = sine_ports,
@ -1898,7 +1898,7 @@ static int parse_filters(struct plugin *pl, struct spa_json *iter, int rate,
* filtersX = [ ... ] # to load channel X * filtersX = [ ... ] # to load channel X
* } * }
*/ */
static void *param_eq_instantiate(const struct fc_plugin *plugin, const struct fc_descriptor * Descriptor, static void *param_eq_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor * Descriptor,
unsigned long SampleRate, int index, const char *config) unsigned long SampleRate, int index, const char *config)
{ {
struct plugin *pl = (struct plugin *) plugin; struct plugin *pl = (struct plugin *) plugin;
@ -1997,77 +1997,77 @@ static void param_eq_run(void * Instance, unsigned long SampleCount)
&impl->port[8], (const float**)impl->port, 8, SampleCount); &impl->port[8], (const float**)impl->port, 8, SampleCount);
} }
static struct fc_port param_eq_ports[] = { static struct spa_fga_port param_eq_ports[] = {
{ .index = 0, { .index = 0,
.name = "In 1", .name = "In 1",
.flags = FC_PORT_INPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 1, { .index = 1,
.name = "In 2", .name = "In 2",
.flags = FC_PORT_INPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 2, { .index = 2,
.name = "In 3", .name = "In 3",
.flags = FC_PORT_INPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 3, { .index = 3,
.name = "In 4", .name = "In 4",
.flags = FC_PORT_INPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 4, { .index = 4,
.name = "In 5", .name = "In 5",
.flags = FC_PORT_INPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 5, { .index = 5,
.name = "In 6", .name = "In 6",
.flags = FC_PORT_INPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 6, { .index = 6,
.name = "In 7", .name = "In 7",
.flags = FC_PORT_INPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 7, { .index = 7,
.name = "In 8", .name = "In 8",
.flags = FC_PORT_INPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 8, { .index = 8,
.name = "Out 1", .name = "Out 1",
.flags = FC_PORT_OUTPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_OUTPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 9, { .index = 9,
.name = "Out 2", .name = "Out 2",
.flags = FC_PORT_OUTPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_OUTPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 10, { .index = 10,
.name = "Out 3", .name = "Out 3",
.flags = FC_PORT_OUTPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_OUTPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 11, { .index = 11,
.name = "Out 4", .name = "Out 4",
.flags = FC_PORT_OUTPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_OUTPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 12, { .index = 12,
.name = "Out 5", .name = "Out 5",
.flags = FC_PORT_OUTPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_OUTPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 13, { .index = 13,
.name = "Out 6", .name = "Out 6",
.flags = FC_PORT_OUTPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_OUTPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 14, { .index = 14,
.name = "Out 7", .name = "Out 7",
.flags = FC_PORT_OUTPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_OUTPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 15, { .index = 15,
.name = "Out 8", .name = "Out 8",
.flags = FC_PORT_OUTPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_OUTPUT | SPA_FGA_PORT_AUDIO,
}, },
}; };
static const struct fc_descriptor param_eq_desc = { static const struct spa_fga_descriptor param_eq_desc = {
.name = "param_eq", .name = "param_eq",
.flags = FC_DESCRIPTOR_SUPPORTS_NULL_DATA, .flags = SPA_FGA_DESCRIPTOR_SUPPORTS_NULL_DATA,
.n_ports = SPA_N_ELEMENTS(param_eq_ports), .n_ports = SPA_N_ELEMENTS(param_eq_ports),
.ports = param_eq_ports, .ports = param_eq_ports,
@ -2078,7 +2078,7 @@ static const struct fc_descriptor param_eq_desc = {
.cleanup = free, .cleanup = free,
}; };
static const struct fc_descriptor * builtin_descriptor(unsigned long Index) static const struct spa_fga_descriptor * builtin_descriptor(unsigned long Index)
{ {
switch(Index) { switch(Index) {
case 0: case 0:
@ -2129,11 +2129,11 @@ static const struct fc_descriptor * builtin_descriptor(unsigned long Index)
return NULL; return NULL;
} }
static const struct fc_descriptor *builtin_make_desc(struct fc_plugin *plugin, const char *name) static const struct spa_fga_descriptor *builtin_plugin_make_desc(void *plugin, const char *name)
{ {
unsigned long i; unsigned long i;
for (i = 0; ;i++) { for (i = 0; ;i++) {
const struct fc_descriptor *d = builtin_descriptor(i); const struct spa_fga_descriptor *d = builtin_descriptor(i);
if (d == NULL) if (d == NULL)
break; break;
if (spa_streq(d->name, name)) if (spa_streq(d->name, name))
@ -2142,19 +2142,30 @@ static const struct fc_descriptor *builtin_make_desc(struct fc_plugin *plugin, c
return NULL; return NULL;
} }
static void builtin_plugin_unload(struct fc_plugin *p) static void builtin_plugin_free(void *p)
{ {
free(p); free(p);
} }
struct fc_plugin *load_builtin_plugin(const struct spa_support *support, uint32_t n_support, static struct spa_fga_plugin_methods impl_plugin = {
SPA_VERSION_FGA_PLUGIN_METHODS,
.make_desc = builtin_plugin_make_desc,
.free = builtin_plugin_free
};
struct spa_fga_plugin *load_builtin_plugin(const struct spa_support *support, uint32_t n_support,
struct dsp_ops *dsp, const char *plugin, const struct spa_dict *info) struct dsp_ops *dsp, const char *plugin, const struct spa_dict *info)
{ {
struct plugin *impl = calloc (1, sizeof (struct plugin)); struct plugin *impl = calloc (1, sizeof (struct plugin));
impl->plugin.make_desc = builtin_make_desc;
impl->plugin.unload = builtin_plugin_unload; impl->plugin.iface = SPA_INTERFACE_INIT(
SPA_TYPE_INTERFACE_FILTER_GRAPH_AudioPlugin,
SPA_VERSION_FGA_PLUGIN,
&impl_plugin, impl);
impl->dsp = dsp; impl->dsp = dsp;
pffft_select_cpu(dsp->cpu_flags); pffft_select_cpu(dsp->cpu_flags);
impl->log = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log); impl->log = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log);
return (struct fc_plugin *) impl;
return (struct spa_fga_plugin *) impl;
} }

View file

@ -15,7 +15,7 @@
#include "config.h" #include "config.h"
#include "plugin.h" #include "audio-plugin.h"
#include "filter-graph.h" #include "filter-graph.h"
#include <spa/utils/result.h> #include <spa/utils/result.h>
@ -56,9 +56,9 @@ SPA_LOG_TOPIC_DEFINE_STATIC(log_topic, "spa.filter-graph");
#define spa_filter_graph_emit_props_changed(hooks,...) spa_filter_graph_emit(hooks,props_changed, 0, __VA_ARGS__) #define spa_filter_graph_emit_props_changed(hooks,...) spa_filter_graph_emit(hooks,props_changed, 0, __VA_ARGS__)
struct fc_plugin *load_ladspa_plugin(const struct spa_support *support, uint32_t n_support, struct spa_fga_plugin *load_ladspa_plugin(const struct spa_support *support, uint32_t n_support,
struct dsp_ops *dsp, const char *path, const struct spa_dict *info); 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 spa_fga_plugin *load_builtin_plugin(const struct spa_support *support, uint32_t n_support,
struct dsp_ops *dsp, const char *path, const struct spa_dict *info); struct dsp_ops *dsp, const char *path, const struct spa_dict *info);
struct plugin { struct plugin {
@ -67,14 +67,14 @@ struct plugin {
char type[256]; char type[256];
char path[PATH_MAX]; char path[PATH_MAX];
struct fc_plugin *plugin; struct spa_fga_plugin *plugin;
struct spa_list descriptor_list; struct spa_list descriptor_list;
}; };
struct plugin_func { struct plugin_func {
struct spa_list link; struct spa_list link;
char type[256]; char type[256];
fc_plugin_load_func *func; spa_filter_graph_audio_plugin_load_func_t *func;
void *hndl; void *hndl;
}; };
@ -84,7 +84,7 @@ struct descriptor {
struct plugin *plugin; struct plugin *plugin;
char label[256]; char label[256];
const struct fc_descriptor *desc; const struct spa_fga_descriptor *desc;
uint32_t n_input; uint32_t n_input;
uint32_t n_output; uint32_t n_output;
@ -147,14 +147,14 @@ struct link {
}; };
struct graph_port { struct graph_port {
const struct fc_descriptor *desc; const struct spa_fga_descriptor *desc;
void **hndl; void **hndl;
uint32_t port; uint32_t port;
unsigned next:1; unsigned next:1;
}; };
struct graph_hndl { struct graph_hndl {
const struct fc_descriptor *desc; const struct spa_fga_descriptor *desc;
void **hndl; void **hndl;
}; };
@ -280,7 +280,7 @@ static int impl_process(void *object,
static float get_default(struct impl *impl, struct descriptor *desc, uint32_t p) static float get_default(struct impl *impl, struct descriptor *desc, uint32_t p)
{ {
struct fc_port *port = &desc->desc->ports[p]; struct spa_fga_port *port = &desc->desc->ports[p];
return port->def; return port->def;
} }
@ -304,7 +304,7 @@ static struct port *find_port(struct node *node, const char *name, int descripto
{ {
char *col, *node_name, *port_name, *str; char *col, *node_name, *port_name, *str;
struct port *ports; struct port *ports;
const struct fc_descriptor *d; const struct spa_fga_descriptor *d;
uint32_t i, n_ports, port_id = SPA_ID_INVALID; uint32_t i, n_ports, port_id = SPA_ID_INVALID;
str = strdupa(name); str = strdupa(name);
@ -334,16 +334,16 @@ static struct port *find_port(struct node *node, const char *name, int descripto
if (!spa_atou32(port_name, &port_id, 0)) if (!spa_atou32(port_name, &port_id, 0))
port_id = SPA_ID_INVALID; port_id = SPA_ID_INVALID;
if (FC_IS_PORT_INPUT(descriptor)) { if (SPA_FGA_IS_PORT_INPUT(descriptor)) {
if (FC_IS_PORT_CONTROL(descriptor)) { if (SPA_FGA_IS_PORT_CONTROL(descriptor)) {
ports = node->control_port; ports = node->control_port;
n_ports = node->desc->n_control; n_ports = node->desc->n_control;
} else { } else {
ports = node->input_port; ports = node->input_port;
n_ports = node->desc->n_input; n_ports = node->desc->n_input;
} }
} else if (FC_IS_PORT_OUTPUT(descriptor)) { } else if (SPA_FGA_IS_PORT_OUTPUT(descriptor)) {
if (FC_IS_PORT_CONTROL(descriptor)) { if (SPA_FGA_IS_PORT_CONTROL(descriptor)) {
ports = node->notify_port; ports = node->notify_port;
n_ports = node->desc->n_notify; n_ports = node->desc->n_notify;
} else { } else {
@ -371,8 +371,8 @@ static int impl_enum_prop_info(void *object, uint32_t idx, struct spa_pod_builde
struct port *port; struct port *port;
struct node *node; struct node *node;
struct descriptor *desc; struct descriptor *desc;
const struct fc_descriptor *d; const struct spa_fga_descriptor *d;
struct fc_port *p; struct spa_fga_port *p;
float def, min, max; float def, min, max;
char name[512]; char name[512];
uint32_t rate = impl->rate ? impl->rate : DEFAULT_RATE; uint32_t rate = impl->rate ? impl->rate : DEFAULT_RATE;
@ -386,7 +386,7 @@ static int impl_enum_prop_info(void *object, uint32_t idx, struct spa_pod_builde
d = desc->desc; d = desc->desc;
p = &d->ports[port->p]; p = &d->ports[port->p];
if (p->hint & FC_HINT_SAMPLE_RATE) { if (p->hint & SPA_FGA_HINT_SAMPLE_RATE) {
def = p->def * rate; def = p->def * rate;
min = p->min * rate; min = p->min * rate;
max = p->max * rate; max = p->max * rate;
@ -407,7 +407,7 @@ static int impl_enum_prop_info(void *object, uint32_t idx, struct spa_pod_builde
SPA_PROP_INFO_name, SPA_POD_String(name), SPA_PROP_INFO_name, SPA_POD_String(name),
0); 0);
spa_pod_builder_prop(b, SPA_PROP_INFO_type, 0); spa_pod_builder_prop(b, SPA_PROP_INFO_type, 0);
if (p->hint & FC_HINT_BOOLEAN) { if (p->hint & SPA_FGA_HINT_BOOLEAN) {
if (min == max) { if (min == max) {
spa_pod_builder_bool(b, def <= 0.0f ? false : true); spa_pod_builder_bool(b, def <= 0.0f ? false : true);
} else { } else {
@ -417,7 +417,7 @@ static int impl_enum_prop_info(void *object, uint32_t idx, struct spa_pod_builde
spa_pod_builder_bool(b, true); spa_pod_builder_bool(b, true);
spa_pod_builder_pop(b, &f[1]); spa_pod_builder_pop(b, &f[1]);
} }
} else if (p->hint & FC_HINT_INTEGER) { } else if (p->hint & SPA_FGA_HINT_INTEGER) {
if (min == max) { if (min == max) {
spa_pod_builder_int(b, (int32_t)def); spa_pod_builder_int(b, (int32_t)def);
} else { } else {
@ -464,8 +464,8 @@ static int impl_get_props(void *object, struct spa_pod_builder *b, const struct
struct port *port = graph->control_port[i]; struct port *port = graph->control_port[i];
struct node *node = port->node; struct node *node = port->node;
struct descriptor *desc = node->desc; struct descriptor *desc = node->desc;
const struct fc_descriptor *d = desc->desc; const struct spa_fga_descriptor *d = desc->desc;
struct fc_port *p = &d->ports[port->p]; struct spa_fga_port *p = &d->ports[port->p];
if (node->name[0] != '\0') if (node->name[0] != '\0')
snprintf(name, sizeof(name), "%s:%s", node->name, p->name); snprintf(name, sizeof(name), "%s:%s", node->name, p->name);
@ -473,9 +473,9 @@ static int impl_get_props(void *object, struct spa_pod_builder *b, const struct
snprintf(name, sizeof(name), "%s", p->name); snprintf(name, sizeof(name), "%s", p->name);
spa_pod_builder_string(b, name); spa_pod_builder_string(b, name);
if (p->hint & FC_HINT_BOOLEAN) { if (p->hint & SPA_FGA_HINT_BOOLEAN) {
spa_pod_builder_bool(b, port->control_data[0] <= 0.0f ? false : true); spa_pod_builder_bool(b, port->control_data[0] <= 0.0f ? false : true);
} else if (p->hint & FC_HINT_INTEGER) { } else if (p->hint & SPA_FGA_HINT_INTEGER) {
spa_pod_builder_int(b, (int32_t)port->control_data[0]); spa_pod_builder_int(b, (int32_t)port->control_data[0]);
} else { } else {
spa_pod_builder_float(b, port->control_data[0]); spa_pod_builder_float(b, port->control_data[0]);
@ -514,7 +514,7 @@ static int set_control_value(struct node *node, const char *name, float *value)
int count = 0; int count = 0;
uint32_t i, n_hndl; uint32_t i, n_hndl;
port = find_port(node, name, FC_PORT_INPUT | FC_PORT_CONTROL); port = find_port(node, name, SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL);
if (port == NULL) if (port == NULL)
return -ENOENT; return -ENOENT;
@ -577,7 +577,7 @@ static int impl_reset(void *object)
uint32_t i; uint32_t i;
for (i = 0; i < graph->n_hndl; i++) { for (i = 0; i < graph->n_hndl; i++) {
struct graph_hndl *hndl = &graph->hndl[i]; struct graph_hndl *hndl = &graph->hndl[i];
const struct fc_descriptor *d = hndl->desc; const struct spa_fga_descriptor *d = hndl->desc;
if (hndl->hndl == NULL || *hndl->hndl == NULL) if (hndl->hndl == NULL || *hndl->hndl == NULL)
continue; continue;
if (d->deactivate) if (d->deactivate)
@ -590,7 +590,7 @@ static int impl_reset(void *object)
static void node_control_changed(struct node *node) static void node_control_changed(struct node *node)
{ {
const struct fc_descriptor *d = node->desc->desc; const struct spa_fga_descriptor *d = node->desc->desc;
uint32_t i; uint32_t i;
if (!node->control_changed) if (!node->control_changed)
@ -740,7 +740,7 @@ static void plugin_unref(struct plugin *hndl)
if (--hndl->ref > 0) if (--hndl->ref > 0)
return; return;
fc_plugin_free(hndl->plugin); spa_fga_plugin_free(hndl->plugin);
spa_list_remove(&hndl->link); spa_list_remove(&hndl->link);
free(hndl); free(hndl);
@ -748,7 +748,7 @@ static void plugin_unref(struct plugin *hndl)
static struct plugin_func *add_plugin_func(struct impl *impl, const char *type, static struct plugin_func *add_plugin_func(struct impl *impl, const char *type,
fc_plugin_load_func *func, void *hndl) spa_filter_graph_audio_plugin_load_func_t *func, void *hndl)
{ {
struct plugin_func *pl; struct plugin_func *pl;
@ -785,9 +785,9 @@ static inline const char *split_walk(const char *str, const char *delimiter, siz
return s; return s;
} }
static fc_plugin_load_func *find_plugin_func(struct impl *impl, const char *type) static spa_filter_graph_audio_plugin_load_func_t *find_plugin_func(struct impl *impl, const char *type)
{ {
fc_plugin_load_func *func = NULL; spa_filter_graph_audio_plugin_load_func_t *func = NULL;
void *hndl = NULL; void *hndl = NULL;
int res; int res;
struct plugin_func *pl; struct plugin_func *pl;
@ -821,7 +821,7 @@ static fc_plugin_load_func *find_plugin_func(struct impl *impl, const char *type
errno = ENOENT; errno = ENOENT;
return NULL; return NULL;
} }
func = dlsym(hndl, FC_PLUGIN_LOAD_FUNC); func = dlsym(hndl, SPA_FILTER_GRAPH_AUDIO_PLUGIN_LOAD_FUNC_NAME);
if (func != NULL) { if (func != NULL) {
spa_log_info(impl->log, "opened plugin module %s", module); spa_log_info(impl->log, "opened plugin module %s", module);
pl = add_plugin_func(impl, type, func, hndl); pl = add_plugin_func(impl, type, func, hndl);
@ -841,9 +841,9 @@ error_close:
static struct plugin *plugin_load(struct impl *impl, const char *type, const char *path) static struct plugin *plugin_load(struct impl *impl, const char *type, const char *path)
{ {
struct fc_plugin *pl = NULL; struct spa_fga_plugin *pl = NULL;
struct plugin *hndl; struct plugin *hndl;
fc_plugin_load_func *plugin_func; spa_filter_graph_audio_plugin_load_func_t *plugin_func;
spa_list_for_each(hndl, &impl->plugin_list, link) { spa_list_for_each(hndl, &impl->plugin_list, link) {
if (spa_streq(hndl->type, type) && if (spa_streq(hndl->type, type) &&
@ -891,7 +891,7 @@ static void descriptor_unref(struct descriptor *desc)
spa_list_remove(&desc->link); spa_list_remove(&desc->link);
plugin_unref(desc->plugin); plugin_unref(desc->plugin);
if (desc->desc) if (desc->desc)
fc_descriptor_free(desc->desc); spa_fga_descriptor_free(desc->desc);
free(desc->input); free(desc->input);
free(desc->output); free(desc->output);
free(desc->control); free(desc->control);
@ -905,7 +905,7 @@ static struct descriptor *descriptor_load(struct impl *impl, const char *type,
{ {
struct plugin *hndl; struct plugin *hndl;
struct descriptor *desc; struct descriptor *desc;
const struct fc_descriptor *d; const struct spa_fga_descriptor *d;
uint32_t i, n_input, n_output, n_control, n_notify; uint32_t i, n_input, n_output, n_control, n_notify;
unsigned long p; unsigned long p;
int res; int res;
@ -934,7 +934,7 @@ static struct descriptor *descriptor_load(struct impl *impl, const char *type,
desc->plugin = hndl; desc->plugin = hndl;
spa_list_init(&desc->link); spa_list_init(&desc->link);
if ((d = hndl->plugin->make_desc(hndl->plugin, label)) == NULL) { if ((d = spa_fga_plugin_make_desc(hndl->plugin, label)) == NULL) {
spa_log_error(impl->log, "cannot find label %s", label); spa_log_error(impl->log, "cannot find label %s", label);
res = -ENOENT; res = -ENOENT;
goto exit; goto exit;
@ -944,16 +944,16 @@ static struct descriptor *descriptor_load(struct impl *impl, const char *type,
n_input = n_output = n_control = n_notify = 0; n_input = n_output = n_control = n_notify = 0;
for (p = 0; p < d->n_ports; p++) { for (p = 0; p < d->n_ports; p++) {
struct fc_port *fp = &d->ports[p]; struct spa_fga_port *fp = &d->ports[p];
if (FC_IS_PORT_AUDIO(fp->flags)) { if (SPA_FGA_IS_PORT_AUDIO(fp->flags)) {
if (FC_IS_PORT_INPUT(fp->flags)) if (SPA_FGA_IS_PORT_INPUT(fp->flags))
n_input++; n_input++;
else if (FC_IS_PORT_OUTPUT(fp->flags)) else if (SPA_FGA_IS_PORT_OUTPUT(fp->flags))
n_output++; n_output++;
} else if (FC_IS_PORT_CONTROL(fp->flags)) { } else if (SPA_FGA_IS_PORT_CONTROL(fp->flags)) {
if (FC_IS_PORT_INPUT(fp->flags)) if (SPA_FGA_IS_PORT_INPUT(fp->flags))
n_control++; n_control++;
else if (FC_IS_PORT_OUTPUT(fp->flags)) else if (SPA_FGA_IS_PORT_OUTPUT(fp->flags))
n_notify++; n_notify++;
} }
} }
@ -964,26 +964,26 @@ static struct descriptor *descriptor_load(struct impl *impl, const char *type,
desc->notify = calloc(n_notify, sizeof(unsigned long)); desc->notify = calloc(n_notify, sizeof(unsigned long));
for (p = 0; p < d->n_ports; p++) { for (p = 0; p < d->n_ports; p++) {
struct fc_port *fp = &d->ports[p]; struct spa_fga_port *fp = &d->ports[p];
if (FC_IS_PORT_AUDIO(fp->flags)) { if (SPA_FGA_IS_PORT_AUDIO(fp->flags)) {
if (FC_IS_PORT_INPUT(fp->flags)) { if (SPA_FGA_IS_PORT_INPUT(fp->flags)) {
spa_log_info(impl->log, "using port %lu ('%s') as input %d", p, spa_log_info(impl->log, "using port %lu ('%s') as input %d", p,
fp->name, desc->n_input); fp->name, desc->n_input);
desc->input[desc->n_input++] = p; desc->input[desc->n_input++] = p;
} }
else if (FC_IS_PORT_OUTPUT(fp->flags)) { else if (SPA_FGA_IS_PORT_OUTPUT(fp->flags)) {
spa_log_info(impl->log, "using port %lu ('%s') as output %d", p, spa_log_info(impl->log, "using port %lu ('%s') as output %d", p,
fp->name, desc->n_output); fp->name, desc->n_output);
desc->output[desc->n_output++] = p; desc->output[desc->n_output++] = p;
} }
} else if (FC_IS_PORT_CONTROL(fp->flags)) { } else if (SPA_FGA_IS_PORT_CONTROL(fp->flags)) {
if (FC_IS_PORT_INPUT(fp->flags)) { if (SPA_FGA_IS_PORT_INPUT(fp->flags)) {
spa_log_info(impl->log, "using port %lu ('%s') as control %d", p, spa_log_info(impl->log, "using port %lu ('%s') as control %d", p,
fp->name, desc->n_control); fp->name, desc->n_control);
desc->control[desc->n_control++] = p; desc->control[desc->n_control++] = p;
} }
else if (FC_IS_PORT_OUTPUT(fp->flags)) { else if (SPA_FGA_IS_PORT_OUTPUT(fp->flags)) {
spa_log_info(impl->log, "using port %lu ('%s') as notify %d", p, spa_log_info(impl->log, "using port %lu ('%s') as notify %d", p,
fp->name, desc->n_notify); fp->name, desc->n_notify);
desc->notify[desc->n_notify++] = p; desc->notify[desc->n_notify++] = p;
@ -1119,13 +1119,13 @@ static int parse_link(struct graph *graph, struct spa_json *json)
def_out_node = spa_list_first(&graph->node_list, struct node, link); def_out_node = spa_list_first(&graph->node_list, struct node, link);
def_in_node = spa_list_last(&graph->node_list, struct node, link); def_in_node = spa_list_last(&graph->node_list, struct node, link);
out_port = find_port(def_out_node, output, FC_PORT_OUTPUT); out_port = find_port(def_out_node, output, SPA_FGA_PORT_OUTPUT);
in_port = find_port(def_in_node, input, FC_PORT_INPUT); in_port = find_port(def_in_node, input, SPA_FGA_PORT_INPUT);
if (out_port == NULL && out_port == NULL) { if (out_port == NULL && out_port == NULL) {
/* try control ports */ /* try control ports */
out_port = find_port(def_out_node, output, FC_PORT_OUTPUT | FC_PORT_CONTROL); out_port = find_port(def_out_node, output, SPA_FGA_PORT_OUTPUT | SPA_FGA_PORT_CONTROL);
in_port = find_port(def_in_node, input, FC_PORT_INPUT | FC_PORT_CONTROL); in_port = find_port(def_in_node, input, SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL);
} }
if (in_port == NULL || out_port == NULL) { if (in_port == NULL || out_port == NULL) {
if (out_port == NULL) if (out_port == NULL)
@ -1235,7 +1235,7 @@ static int parse_volume(struct graph *graph, struct spa_json *json, bool capture
else else
def_control = spa_list_last(&graph->node_list, struct node, link); def_control = spa_list_last(&graph->node_list, struct node, link);
port = find_port(def_control, control, FC_PORT_INPUT | FC_PORT_CONTROL); port = find_port(def_control, control, SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL);
if (port == NULL) { if (port == NULL) {
spa_log_error(impl->log, "unknown control port %s", control); spa_log_error(impl->log, "unknown control port %s", control);
return -ENOENT; return -ENOENT;
@ -1402,7 +1402,7 @@ static int load_node(struct graph *graph, struct spa_json *json)
static void node_cleanup(struct node *node) static void node_cleanup(struct node *node)
{ {
const struct fc_descriptor *d = node->desc->desc; const struct spa_fga_descriptor *d = node->desc->desc;
struct impl *impl = node->graph->impl; struct impl *impl = node->graph->impl;
uint32_t i; uint32_t i;
@ -1421,7 +1421,7 @@ static int port_ensure_data(struct port *port, uint32_t i, uint32_t max_samples)
{ {
float *data; float *data;
struct node *node = port->node; struct node *node = port->node;
const struct fc_descriptor *d = node->desc->desc; const struct spa_fga_descriptor *d = node->desc->desc;
struct impl *impl = node->graph->impl; struct impl *impl = node->graph->impl;
if ((data = port->audio_mem[i]) == NULL) { if ((data = port->audio_mem[i]) == NULL) {
@ -1488,8 +1488,8 @@ static int impl_activate(void *object, const struct spa_fraction *rate)
struct port *port; struct port *port;
struct link *link; struct link *link;
struct descriptor *desc; struct descriptor *desc;
const struct fc_descriptor *d; const struct spa_fga_descriptor *d;
const struct fc_plugin *p; const struct spa_fga_plugin *p;
uint32_t i, j, max_samples = impl->quantum_limit; uint32_t i, j, max_samples = impl->quantum_limit;
int res; int res;
float *sd, *dd; float *sd, *dd;
@ -1524,7 +1524,7 @@ static int impl_activate(void *object, const struct spa_fraction *rate)
spa_list_for_each(node, &graph->node_list, link) { spa_list_for_each(node, &graph->node_list, link) {
desc = node->desc; desc = node->desc;
d = desc->desc; d = desc->desc;
if (d->flags & FC_DESCRIPTOR_SUPPORTS_NULL_DATA) { if (d->flags & SPA_FGA_DESCRIPTOR_SUPPORTS_NULL_DATA) {
sd = dd = NULL; sd = dd = NULL;
} }
else { else {
@ -1625,7 +1625,7 @@ static int setup_graph(struct graph *graph, struct spa_json *inputs, struct spa_
uint32_t i, j, n_nodes, n_input, n_output, n_control, n_hndl = 0; uint32_t i, j, n_nodes, n_input, n_output, n_control, n_hndl = 0;
int res; int res;
struct descriptor *desc; struct descriptor *desc;
const struct fc_descriptor *d; const struct spa_fga_descriptor *d;
char v[256]; char v[256];
bool allow_unused; bool allow_unused;
@ -1649,8 +1649,8 @@ static int setup_graph(struct graph *graph, struct spa_json *inputs, struct spa_
/* we allow unconnected ports when not explicitly given and the nodes support /* we allow unconnected ports when not explicitly given and the nodes support
* NULL data */ * NULL data */
allow_unused = inputs == NULL && outputs == NULL && allow_unused = inputs == NULL && outputs == NULL &&
SPA_FLAG_IS_SET(first->desc->desc->flags, FC_DESCRIPTOR_SUPPORTS_NULL_DATA) && SPA_FLAG_IS_SET(first->desc->desc->flags, SPA_FGA_DESCRIPTOR_SUPPORTS_NULL_DATA) &&
SPA_FLAG_IS_SET(last->desc->desc->flags, FC_DESCRIPTOR_SUPPORTS_NULL_DATA); SPA_FLAG_IS_SET(last->desc->desc->flags, SPA_FGA_DESCRIPTOR_SUPPORTS_NULL_DATA);
if (n_input == 0) { if (n_input == 0) {
spa_log_error(impl->log, "no inputs"); spa_log_error(impl->log, "no inputs");
@ -1733,7 +1733,7 @@ static int setup_graph(struct graph *graph, struct spa_json *inputs, struct spa_
gp = &graph->input[graph->n_input++]; gp = &graph->input[graph->n_input++];
gp->desc = NULL; gp->desc = NULL;
spa_log_info(impl->log, "ignore input port %d", graph->n_input); spa_log_info(impl->log, "ignore input port %d", graph->n_input);
} else if ((port = find_port(first, v, FC_PORT_INPUT)) == NULL) { } else if ((port = find_port(first, v, SPA_FGA_PORT_INPUT)) == NULL) {
res = -ENOENT; res = -ENOENT;
spa_log_error(impl->log, "input port %s not found", v); spa_log_error(impl->log, "input port %s not found", v);
goto error; goto error;
@ -1756,7 +1756,7 @@ static int setup_graph(struct graph *graph, struct spa_json *inputs, struct spa_
goto error; goto error;
} }
if (d->flags & FC_DESCRIPTOR_COPY) { if (d->flags & SPA_FGA_DESCRIPTOR_COPY) {
for (j = 0; j < desc->n_output; j++) { for (j = 0; j < desc->n_output; j++) {
struct port *p = &port->node->output_port[j]; struct port *p = &port->node->output_port[j];
struct link *link; struct link *link;
@ -1812,7 +1812,7 @@ static int setup_graph(struct graph *graph, struct spa_json *inputs, struct spa_
if (spa_streq(v, "null")) { if (spa_streq(v, "null")) {
gp->desc = NULL; gp->desc = NULL;
spa_log_info(impl->log, "silence output port %d", graph->n_output); spa_log_info(impl->log, "silence output port %d", graph->n_output);
} else if ((port = find_port(last, v, FC_PORT_OUTPUT)) == NULL) { } else if ((port = find_port(last, v, SPA_FGA_PORT_OUTPUT)) == NULL) {
res = -ENOENT; res = -ENOENT;
spa_log_error(impl->log, "output port %s not found", v); spa_log_error(impl->log, "output port %s not found", v);
goto error; goto error;

View file

@ -13,11 +13,11 @@
#include <spa/utils/string.h> #include <spa/utils/string.h>
#include <spa/support/log.h> #include <spa/support/log.h>
#include "plugin.h" #include "audio-plugin.h"
#include "ladspa.h" #include "ladspa.h"
struct plugin { struct plugin {
struct fc_plugin plugin; struct spa_fga_plugin plugin;
struct spa_log *log; struct spa_log *log;
@ -26,11 +26,11 @@ struct plugin {
}; };
struct descriptor { struct descriptor {
struct fc_descriptor desc; struct spa_fga_descriptor desc;
const LADSPA_Descriptor *d; const LADSPA_Descriptor *d;
}; };
static void *ladspa_instantiate(const struct fc_plugin *plugin, const struct fc_descriptor *desc, static void *ladspa_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor *desc,
unsigned long SampleRate, int index, const char *config) unsigned long SampleRate, int index, const char *config)
{ {
struct descriptor *d = (struct descriptor *)desc; struct descriptor *d = (struct descriptor *)desc;
@ -50,7 +50,7 @@ static const LADSPA_Descriptor *find_desc(LADSPA_Descriptor_Function desc_func,
return NULL; return NULL;
} }
static float get_default(struct fc_port *port, LADSPA_PortRangeHintDescriptor hint, static float get_default(struct spa_fga_port *port, LADSPA_PortRangeHintDescriptor hint,
LADSPA_Data lower, LADSPA_Data upper) LADSPA_Data lower, LADSPA_Data upper)
{ {
LADSPA_Data def; LADSPA_Data def;
@ -104,7 +104,7 @@ static float get_default(struct fc_port *port, LADSPA_PortRangeHintDescriptor hi
return def; return def;
} }
static void ladspa_port_update_ranges(struct descriptor *dd, struct fc_port *port) static void ladspa_port_update_ranges(struct descriptor *dd, struct spa_fga_port *port)
{ {
const LADSPA_Descriptor *d = dd->d; const LADSPA_Descriptor *d = dd->d;
unsigned long p = port->index; unsigned long p = port->index;
@ -120,14 +120,14 @@ static void ladspa_port_update_ranges(struct descriptor *dd, struct fc_port *por
port->max = upper; port->max = upper;
} }
static void ladspa_free(const struct fc_descriptor *desc) static void ladspa_free(const struct spa_fga_descriptor *desc)
{ {
struct descriptor *d = (struct descriptor*)desc; struct descriptor *d = (struct descriptor*)desc;
free(d->desc.ports); free(d->desc.ports);
free(d); free(d);
} }
static const struct fc_descriptor *ladspa_make_desc(struct fc_plugin *plugin, const char *name) static const struct spa_fga_descriptor *ladspa_plugin_make_desc(void *plugin, const char *name)
{ {
struct plugin *p = (struct plugin *)plugin; struct plugin *p = (struct plugin *)plugin;
struct descriptor *desc; struct descriptor *desc;
@ -154,7 +154,7 @@ static const struct fc_descriptor *ladspa_make_desc(struct fc_plugin *plugin, co
desc->desc.flags = 0; desc->desc.flags = 0;
desc->desc.n_ports = d->PortCount; desc->desc.n_ports = d->PortCount;
desc->desc.ports = calloc(desc->desc.n_ports, sizeof(struct fc_port)); desc->desc.ports = calloc(desc->desc.n_ports, sizeof(struct spa_fga_port));
for (i = 0; i < desc->desc.n_ports; i++) { for (i = 0; i < desc->desc.n_ports; i++) {
desc->desc.ports[i].index = i; desc->desc.ports[i].index = i;
@ -165,7 +165,7 @@ static const struct fc_descriptor *ladspa_make_desc(struct fc_plugin *plugin, co
return &desc->desc; return &desc->desc;
} }
static void ladspa_unload(struct fc_plugin *plugin) static void ladspa_plugin_free(void *plugin)
{ {
struct plugin *p = (struct plugin *)plugin; struct plugin *p = (struct plugin *)plugin;
if (p->handle) if (p->handle)
@ -173,7 +173,13 @@ static void ladspa_unload(struct fc_plugin *plugin)
free(p); free(p);
} }
static struct fc_plugin *ladspa_handle_load_by_path(struct spa_log *log, const char *path) static struct spa_fga_plugin_methods impl_plugin = {
SPA_VERSION_FGA_PLUGIN_METHODS,
.make_desc = ladspa_plugin_make_desc,
.free = ladspa_plugin_free
};
static struct spa_fga_plugin *ladspa_handle_load_by_path(struct spa_log *log, const char *path)
{ {
struct plugin *p; struct plugin *p;
int res; int res;
@ -204,8 +210,11 @@ static struct fc_plugin *ladspa_handle_load_by_path(struct spa_log *log, const c
p->log = log; p->log = log;
p->handle = handle; p->handle = handle;
p->desc_func = desc_func; p->desc_func = desc_func;
p->plugin.make_desc = ladspa_make_desc;
p->plugin.unload = ladspa_unload; p->plugin.iface = SPA_INTERFACE_INIT(
SPA_TYPE_INTERFACE_FILTER_GRAPH_AudioPlugin,
SPA_VERSION_FGA_PLUGIN,
&impl_plugin, p);
return &p->plugin; return &p->plugin;
@ -230,10 +239,10 @@ static inline const char *split_walk(const char *str, const char *delimiter, siz
return s; return s;
} }
struct fc_plugin *load_ladspa_plugin(const struct spa_support *support, uint32_t n_support, struct spa_fga_plugin *load_ladspa_plugin(const struct spa_support *support, uint32_t n_support,
struct dsp_ops *dsp, const char *plugin, const struct spa_dict *info) struct dsp_ops *dsp, const char *plugin, const struct spa_dict *info)
{ {
struct fc_plugin *pl = NULL; struct spa_fga_plugin *pl = NULL;
struct spa_log *log; struct spa_log *log;
log = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log); log = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log);

View file

@ -34,7 +34,7 @@
#endif #endif
#include "plugin.h" #include "audio-plugin.h"
static struct context *_context; static struct context *_context;
@ -216,13 +216,13 @@ static void context_unref(struct context *context)
} }
struct plugin { struct plugin {
struct fc_plugin plugin; struct spa_fga_plugin plugin;
struct context *c; struct context *c;
const LilvPlugin *p; const LilvPlugin *p;
}; };
struct descriptor { struct descriptor {
struct fc_descriptor desc; struct spa_fga_descriptor desc;
struct plugin *p; struct plugin *p;
}; };
@ -280,7 +280,7 @@ work_schedule(LV2_Worker_Schedule_Handle handle, uint32_t size, const void *data
return LV2_WORKER_SUCCESS; return LV2_WORKER_SUCCESS;
} }
static void *lv2_instantiate(const struct fc_plugin *plugin, const struct fc_descriptor *desc, static void *lv2_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor *desc,
unsigned long SampleRate, int index, const char *config) unsigned long SampleRate, int index, const char *config)
{ {
struct descriptor *d = (struct descriptor*)desc; struct descriptor *d = (struct descriptor*)desc;
@ -385,7 +385,7 @@ static void lv2_run(void *instance, unsigned long SampleCount)
i->work_iface->end_run(i->instance); i->work_iface->end_run(i->instance);
} }
static void lv2_free(const struct fc_descriptor *desc) static void lv2_free(const struct spa_fga_descriptor *desc)
{ {
struct descriptor *d = (struct descriptor*)desc; struct descriptor *d = (struct descriptor*)desc;
free((char*)d->desc.name); free((char*)d->desc.name);
@ -393,7 +393,7 @@ static void lv2_free(const struct fc_descriptor *desc)
free(d); free(d);
} }
static const struct fc_descriptor *lv2_make_desc(struct fc_plugin *plugin, const char *name) static const struct spa_fga_descriptor *lv2_plugin_make_desc(void *plugin, const char *name)
{ {
struct plugin *p = (struct plugin *)plugin; struct plugin *p = (struct plugin *)plugin;
struct context *c = p->c; struct context *c = p->c;
@ -419,7 +419,7 @@ static const struct fc_descriptor *lv2_make_desc(struct fc_plugin *plugin, const
desc->desc.flags = 0; desc->desc.flags = 0;
desc->desc.n_ports = lilv_plugin_get_num_ports(p->p); desc->desc.n_ports = lilv_plugin_get_num_ports(p->p);
desc->desc.ports = calloc(desc->desc.n_ports, sizeof(struct fc_port)); desc->desc.ports = calloc(desc->desc.n_ports, sizeof(struct spa_fga_port));
mins = alloca(desc->desc.n_ports * sizeof(float)); mins = alloca(desc->desc.n_ports * sizeof(float));
maxes = alloca(desc->desc.n_ports * sizeof(float)); maxes = alloca(desc->desc.n_ports * sizeof(float));
@ -430,20 +430,20 @@ static const struct fc_descriptor *lv2_make_desc(struct fc_plugin *plugin, const
for (i = 0; i < desc->desc.n_ports; i++) { for (i = 0; i < desc->desc.n_ports; i++) {
const LilvPort *port = lilv_plugin_get_port_by_index(p->p, i); const LilvPort *port = lilv_plugin_get_port_by_index(p->p, i);
const LilvNode *symbol = lilv_port_get_symbol(p->p, port); const LilvNode *symbol = lilv_port_get_symbol(p->p, port);
struct fc_port *fp = &desc->desc.ports[i]; struct spa_fga_port *fp = &desc->desc.ports[i];
fp->index = i; fp->index = i;
fp->name = strdup(lilv_node_as_string(symbol)); fp->name = strdup(lilv_node_as_string(symbol));
fp->flags = 0; fp->flags = 0;
if (lilv_port_is_a(p->p, port, c->lv2_InputPort)) if (lilv_port_is_a(p->p, port, c->lv2_InputPort))
fp->flags |= FC_PORT_INPUT; fp->flags |= SPA_FGA_PORT_INPUT;
if (lilv_port_is_a(p->p, port, c->lv2_OutputPort)) if (lilv_port_is_a(p->p, port, c->lv2_OutputPort))
fp->flags |= FC_PORT_OUTPUT; fp->flags |= SPA_FGA_PORT_OUTPUT;
if (lilv_port_is_a(p->p, port, c->lv2_ControlPort)) if (lilv_port_is_a(p->p, port, c->lv2_ControlPort))
fp->flags |= FC_PORT_CONTROL; fp->flags |= SPA_FGA_PORT_CONTROL;
if (lilv_port_is_a(p->p, port, c->lv2_AudioPort)) if (lilv_port_is_a(p->p, port, c->lv2_AudioPort))
fp->flags |= FC_PORT_AUDIO; fp->flags |= SPA_FGA_PORT_AUDIO;
fp->hint = 0; fp->hint = 0;
fp->min = mins[i]; fp->min = mins[i];
@ -453,15 +453,21 @@ static const struct fc_descriptor *lv2_make_desc(struct fc_plugin *plugin, const
return &desc->desc; return &desc->desc;
} }
static void lv2_unload(struct fc_plugin *plugin) static void lv2_plugin_free(void *plugin)
{ {
struct plugin *p = (struct plugin *)plugin; struct plugin *p = (struct plugin *)plugin;
context_unref(p->c); context_unref(p->c);
free(p); free(p);
} }
static struct spa_fga_plugin_methods impl_plugin = {
SPA_VERSION_FGA_PLUGIN_METHODS,
.make_desc = lv2_plugin_make_desc,
.free = lv2_plugin_free
};
SPA_EXPORT SPA_EXPORT
struct fc_plugin *pipewire__filter_chain_plugin_load(const struct spa_support *support, uint32_t n_support, struct spa_fga_plugin *spa_filter_graph_audio_plugin_load(const struct spa_support *support, uint32_t n_support,
struct dsp_ops *dsp, const char *plugin_uri, const struct spa_dict *info) struct dsp_ops *dsp, const char *plugin_uri, const struct spa_dict *info)
{ {
struct context *c; struct context *c;
@ -500,8 +506,10 @@ struct fc_plugin *pipewire__filter_chain_plugin_load(const struct spa_support *s
p->p = plugin; p->p = plugin;
p->c = c; p->c = c;
p->plugin.make_desc = lv2_make_desc; p->plugin.iface = SPA_INTERFACE_INIT(
p->plugin.unload = lv2_unload; SPA_TYPE_INTERFACE_FILTER_GRAPH_AudioPlugin,
SPA_VERSION_FGA_PLUGIN,
&impl_plugin, p);
return &p->plugin; return &p->plugin;

View file

@ -1,86 +0,0 @@
/* PipeWire */
/* SPDX-FileCopyrightText: Copyright © 2021 Wim Taymans */
/* SPDX-License-Identifier: MIT */
#ifndef PLUGIN_H
#define PLUGIN_H
#include <stdint.h>
#include <stddef.h>
#include <spa/support/plugin.h>
#include "dsp-ops.h"
struct fc_plugin {
const struct fc_descriptor *(*make_desc)(struct fc_plugin *plugin, const char *name);
void (*unload) (struct fc_plugin *plugin);
};
struct fc_port {
uint32_t index;
const char *name;
#define FC_PORT_INPUT (1ULL << 0)
#define FC_PORT_OUTPUT (1ULL << 1)
#define FC_PORT_CONTROL (1ULL << 2)
#define FC_PORT_AUDIO (1ULL << 3)
uint64_t flags;
#define FC_HINT_BOOLEAN (1ULL << 2)
#define FC_HINT_SAMPLE_RATE (1ULL << 3)
#define FC_HINT_INTEGER (1ULL << 5)
uint64_t hint;
float def;
float min;
float max;
};
#define FC_IS_PORT_INPUT(x) ((x) & FC_PORT_INPUT)
#define FC_IS_PORT_OUTPUT(x) ((x) & FC_PORT_OUTPUT)
#define FC_IS_PORT_CONTROL(x) ((x) & FC_PORT_CONTROL)
#define FC_IS_PORT_AUDIO(x) ((x) & FC_PORT_AUDIO)
struct fc_descriptor {
const char *name;
#define FC_DESCRIPTOR_SUPPORTS_NULL_DATA (1ULL << 0)
#define FC_DESCRIPTOR_COPY (1ULL << 1)
uint64_t flags;
void (*free) (const struct fc_descriptor *desc);
uint32_t n_ports;
struct fc_port *ports;
void *(*instantiate) (const struct fc_plugin *plugin, const struct fc_descriptor *desc,
unsigned long SampleRate, int index, const char *config);
void (*cleanup) (void *instance);
void (*connect_port) (void *instance, unsigned long port, float *data);
void (*control_changed) (void *instance);
void (*activate) (void *instance);
void (*deactivate) (void *instance);
void (*run) (void *instance, unsigned long SampleCount);
};
static inline void fc_plugin_free(struct fc_plugin *plugin)
{
if (plugin->unload)
plugin->unload(plugin);
}
static inline void fc_descriptor_free(const struct fc_descriptor *desc)
{
if (desc->free)
desc->free(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 struct spa_dict *info);
#endif /* PLUGIN_H */

View file

@ -6,7 +6,7 @@
#include <spa/support/loop.h> #include <spa/support/loop.h>
#include <spa/support/log.h> #include <spa/support/log.h>
#include "plugin.h" #include "audio-plugin.h"
#include "convolver.h" #include "convolver.h"
#include "dsp-ops.h" #include "dsp-ops.h"
#include "pffft.h" #include "pffft.h"
@ -14,7 +14,7 @@
#include <mysofa.h> #include <mysofa.h>
struct plugin { struct plugin {
struct fc_plugin plugin; struct spa_fga_plugin plugin;
struct dsp_ops *dsp; struct dsp_ops *dsp;
struct spa_log *log; struct spa_log *log;
@ -40,7 +40,7 @@ struct spatializer_impl {
struct convolver *r_conv[3]; struct convolver *r_conv[3];
}; };
static void * spatializer_instantiate(const struct fc_plugin *plugin, const struct fc_descriptor * Descriptor, static void * spatializer_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor * Descriptor,
unsigned long SampleRate, int index, const char *config) unsigned long SampleRate, int index, const char *config)
{ {
struct spatializer_impl *impl; struct spatializer_impl *impl;
@ -356,38 +356,38 @@ static void spatializer_deactivate(void * Instance)
impl->interpolate = false; impl->interpolate = false;
} }
static struct fc_port spatializer_ports[] = { static struct spa_fga_port spatializer_ports[] = {
{ .index = 0, { .index = 0,
.name = "Out L", .name = "Out L",
.flags = FC_PORT_OUTPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_OUTPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 1, { .index = 1,
.name = "Out R", .name = "Out R",
.flags = FC_PORT_OUTPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_OUTPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 2, { .index = 2,
.name = "In", .name = "In",
.flags = FC_PORT_INPUT | FC_PORT_AUDIO, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
}, },
{ .index = 3, { .index = 3,
.name = "Azimuth", .name = "Azimuth",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
.def = 0.0f, .min = 0.0f, .max = 360.0f .def = 0.0f, .min = 0.0f, .max = 360.0f
}, },
{ .index = 4, { .index = 4,
.name = "Elevation", .name = "Elevation",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
.def = 0.0f, .min = -90.0f, .max = 90.0f .def = 0.0f, .min = -90.0f, .max = 90.0f
}, },
{ .index = 5, { .index = 5,
.name = "Radius", .name = "Radius",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL, .flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_CONTROL,
.def = 1.0f, .min = 0.0f, .max = 100.0f .def = 1.0f, .min = 0.0f, .max = 100.0f
}, },
}; };
static const struct fc_descriptor spatializer_desc = { static const struct spa_fga_descriptor spatializer_desc = {
.name = "spatializer", .name = "spatializer",
.n_ports = 6, .n_ports = 6,
@ -401,7 +401,7 @@ static const struct fc_descriptor spatializer_desc = {
.cleanup = spatializer_cleanup, .cleanup = spatializer_cleanup,
}; };
static const struct fc_descriptor * sofa_descriptor(unsigned long Index) static const struct spa_fga_descriptor * sofa_descriptor(unsigned long Index)
{ {
switch(Index) { switch(Index) {
case 0: case 0:
@ -411,11 +411,11 @@ static const struct fc_descriptor * sofa_descriptor(unsigned long Index)
} }
static const struct fc_descriptor *sofa_make_desc(struct fc_plugin *plugin, const char *name) static const struct spa_fga_descriptor *sofa_plugin_make_desc(void *plugin, const char *name)
{ {
unsigned long i; unsigned long i;
for (i = 0; ;i++) { for (i = 0; ;i++) {
const struct fc_descriptor *d = sofa_descriptor(i); const struct spa_fga_descriptor *d = sofa_descriptor(i);
if (d == NULL) if (d == NULL)
break; break;
if (spa_streq(d->name, name)) if (spa_streq(d->name, name))
@ -424,19 +424,28 @@ static const struct fc_descriptor *sofa_make_desc(struct fc_plugin *plugin, cons
return NULL; return NULL;
} }
static void sofa_plugin_unload(struct fc_plugin *p) static void sofa_plugin_free(void *plugin)
{ {
free(p); struct plugin *impl = plugin;
free(impl);
} }
static struct spa_fga_plugin_methods impl_plugin = {
SPA_VERSION_FGA_PLUGIN_METHODS,
.make_desc = sofa_plugin_make_desc,
.free = sofa_plugin_free
};
SPA_EXPORT SPA_EXPORT
struct fc_plugin *pipewire__filter_chain_plugin_load(const struct spa_support *support, uint32_t n_support, struct spa_fga_plugin *spa_filter_graph_audio_plugin_load(const struct spa_support *support, uint32_t n_support,
struct dsp_ops *dsp, const char *plugin, const struct spa_dict *info) struct dsp_ops *dsp, const char *plugin, const struct spa_dict *info)
{ {
struct plugin *impl = calloc(1, sizeof (struct plugin)); struct plugin *impl = calloc(1, sizeof (struct plugin));
impl->plugin.make_desc = sofa_make_desc; impl->plugin.iface = SPA_INTERFACE_INIT(
impl->plugin.unload = sofa_plugin_unload; SPA_TYPE_INTERFACE_FILTER_GRAPH_AudioPlugin,
SPA_VERSION_FGA_PLUGIN,
&impl_plugin, impl);
impl->quantum_limit = 8192u; impl->quantum_limit = 8192u;
@ -453,5 +462,5 @@ struct fc_plugin *pipewire__filter_chain_plugin_load(const struct spa_support *s
impl->main_loop = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Loop); impl->main_loop = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Loop);
impl->log = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log); impl->log = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log);
return (struct fc_plugin *) impl; return (struct spa_fga_plugin *) impl;
} }