mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-06-30 13:14:16 -04:00
filter-graph: return result from instatiate
Instead of returning a handle (and errno on NULL), return a result code and store the handle in a return variable. This makes it easier to handle the errors but also makes it possible to return multiple handles later.
This commit is contained in:
parent
978e8c1a4b
commit
b3eb2eabb8
9 changed files with 191 additions and 194 deletions
|
|
@ -62,8 +62,8 @@ struct spa_fga_descriptor {
|
|||
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);
|
||||
int (*instantiate) (const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor *desc,
|
||||
uint32_t rate, int index, const char *config, void **hndl);
|
||||
|
||||
void (*cleanup) (void *instance);
|
||||
|
||||
|
|
|
|||
|
|
@ -1685,9 +1685,9 @@ static int impl_activate(void *object, const struct spa_dict *props)
|
|||
for (i = 0; i < node->n_hndl; i++) {
|
||||
spa_log_info(impl->log, "instantiate %s %s[%d] rate:%lu", d->name, node->name, i, impl->rate);
|
||||
errno = EINVAL;
|
||||
if ((node->hndl[i] = d->instantiate(p, d, impl->rate, i, node->config)) == NULL) {
|
||||
spa_log_error(impl->log, "cannot create plugin instance %d rate:%lu: %m", i, impl->rate);
|
||||
res = -errno;
|
||||
if ((res = d->instantiate(p, d, impl->rate, i, node->config, &node->hndl[i])) < 0) {
|
||||
spa_log_error(impl->log, "cannot create plugin instance %d rate:%lu: %s",
|
||||
i, impl->rate, spa_strerror(res));
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,22 +69,23 @@ struct builtin {
|
|||
float hold;
|
||||
};
|
||||
|
||||
static void *builtin_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor * Descriptor,
|
||||
unsigned long SampleRate, int index, const char *config)
|
||||
static int builtin_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor * Descriptor,
|
||||
uint32_t rate, int index, const char *config, void **hndl)
|
||||
{
|
||||
struct plugin *pl = SPA_CONTAINER_OF(plugin, struct plugin, plugin);
|
||||
struct builtin *impl;
|
||||
|
||||
impl = calloc(1, sizeof(*impl));
|
||||
if (impl == NULL)
|
||||
return NULL;
|
||||
return -errno;
|
||||
|
||||
impl->plugin = pl;
|
||||
impl->rate = SampleRate;
|
||||
impl->rate = rate;
|
||||
impl->dsp = impl->plugin->dsp;
|
||||
impl->log = impl->plugin->log;
|
||||
|
||||
return impl;
|
||||
*hndl = impl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void builtin_connect_port(void *Instance, unsigned long Port, void * DataLocation)
|
||||
|
|
@ -335,8 +336,8 @@ static void bq_raw_update(struct builtin *impl, float b0, float b1, float b2,
|
|||
* ]
|
||||
* }
|
||||
*/
|
||||
static void *bq_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor * Descriptor,
|
||||
unsigned long SampleRate, int index, const char *config)
|
||||
static int bq_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor * Descriptor,
|
||||
uint32_t rate, int index, const char *config, void **hndl)
|
||||
{
|
||||
struct plugin *pl = SPA_CONTAINER_OF(plugin, struct plugin, plugin);
|
||||
struct builtin *impl;
|
||||
|
|
@ -348,16 +349,16 @@ static void *bq_instantiate(const struct spa_fga_plugin *plugin, const struct sp
|
|||
|
||||
impl = calloc(1, sizeof(*impl));
|
||||
if (impl == NULL)
|
||||
return NULL;
|
||||
return -errno;
|
||||
|
||||
impl->plugin = pl;
|
||||
impl->log = impl->plugin->log;
|
||||
impl->dsp = impl->plugin->dsp;
|
||||
impl->rate = SampleRate;
|
||||
impl->rate = rate;
|
||||
impl->b0 = impl->a0 = 1.0f;
|
||||
impl->type = bq_type_from_name(Descriptor->name);
|
||||
if (impl->type != BQ_NONE)
|
||||
return impl;
|
||||
goto done;
|
||||
|
||||
if (config == NULL) {
|
||||
spa_log_error(impl->log, "biquads:bq_raw requires a config section");
|
||||
|
|
@ -428,8 +429,8 @@ static void *bq_instantiate(const struct spa_fga_plugin *plugin, const struct sp
|
|||
spa_log_warn(impl->log, "biquads: ignoring coefficients key: '%s'", key);
|
||||
}
|
||||
}
|
||||
if (labs((long)rate - (long)SampleRate) <
|
||||
labs((long)best_rate - (long)SampleRate)) {
|
||||
if (labs((long)rate - (long)rate) <
|
||||
labs((long)best_rate - (long)rate)) {
|
||||
best_rate = rate;
|
||||
bq_raw_update(impl, b0, b1, b2, a0, a1, a2);
|
||||
}
|
||||
|
|
@ -439,12 +440,12 @@ static void *bq_instantiate(const struct spa_fga_plugin *plugin, const struct sp
|
|||
spa_log_warn(impl->log, "biquads: ignoring config key: '%s'", key);
|
||||
}
|
||||
}
|
||||
|
||||
return impl;
|
||||
done:
|
||||
*hndl = impl;
|
||||
return 0;
|
||||
error:
|
||||
free(impl);
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
#define BQ_NUM_PORTS 11
|
||||
|
|
@ -1139,8 +1140,8 @@ error:
|
|||
return res;
|
||||
}
|
||||
|
||||
static void * convolver_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor * Descriptor,
|
||||
unsigned long SampleRate, int index, const char *config)
|
||||
static int convolver_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor * Descriptor,
|
||||
uint32_t rate, int index, const char *config, void **hndl)
|
||||
{
|
||||
struct plugin *pl = SPA_CONTAINER_OF(plugin, struct plugin, plugin);
|
||||
struct convolver_impl *impl = NULL;
|
||||
|
|
@ -1152,42 +1153,39 @@ static void * convolver_instantiate(const struct spa_fga_plugin *plugin, const s
|
|||
float latency = -1.0f;
|
||||
struct impulse ir = IMPULSE_INIT(index);
|
||||
|
||||
errno = EINVAL;
|
||||
if (config == NULL) {
|
||||
spa_log_error(pl->log, "convolver: requires a config section");
|
||||
return NULL;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (spa_json_begin_object(&it[0], config, strlen(config)) <= 0) {
|
||||
spa_log_error(pl->log, "convolver:config must be an object");
|
||||
return NULL;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
while ((len = spa_json_object_next(&it[0], key, sizeof(key), &val)) > 0) {
|
||||
if (spa_streq(key, "blocksize")) {
|
||||
if (spa_json_parse_int(val, len, &blocksize) <= 0) {
|
||||
spa_log_error(pl->log, "convolver:blocksize requires a number");
|
||||
return NULL;
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
else if (spa_streq(key, "tailsize")) {
|
||||
if (spa_json_parse_int(val, len, &tailsize) <= 0) {
|
||||
spa_log_error(pl->log, "convolver:tailsize requires a number");
|
||||
return NULL;
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
else if (spa_streq(key, "latency")) {
|
||||
if (spa_json_parse_float(val, len, &latency) <= 0) {
|
||||
spa_log_error(pl->log, "convolver:latency requires a number");
|
||||
return NULL;
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
spa_json_begin_object(&it[0], config, strlen(config));
|
||||
if ((res = convolver_read_impulse(pl, &it[0], SampleRate, &ir)) < 0) {
|
||||
errno = -res;
|
||||
return NULL;
|
||||
}
|
||||
if ((res = convolver_read_impulse(pl, &it[0], rate, &ir)) < 0)
|
||||
return res;
|
||||
|
||||
if (blocksize <= 0)
|
||||
blocksize = SPA_CLAMP(ir.n_samples, 64, 256);
|
||||
|
|
@ -1199,12 +1197,12 @@ static void * convolver_instantiate(const struct spa_fga_plugin *plugin, const s
|
|||
|
||||
impl = calloc(1, sizeof(*impl));
|
||||
if (impl == NULL)
|
||||
goto error;
|
||||
goto error_errno;
|
||||
|
||||
impl->plugin = pl;
|
||||
impl->log = pl->log;
|
||||
impl->dsp = pl->dsp;
|
||||
impl->rate = SampleRate;
|
||||
impl->rate = rate;
|
||||
if (latency < 0.0f)
|
||||
impl->latency = ir.latency;
|
||||
else
|
||||
|
|
@ -1212,15 +1210,19 @@ static void * convolver_instantiate(const struct spa_fga_plugin *plugin, const s
|
|||
|
||||
impl->conv = convolver_new(impl->dsp, blocksize, tailsize, ir.samples, ir.n_samples);
|
||||
if (impl->conv == NULL)
|
||||
goto error;
|
||||
goto error_errno;
|
||||
|
||||
*hndl = impl;
|
||||
|
||||
impulse_clear(&ir);
|
||||
|
||||
return impl;
|
||||
error:
|
||||
return 0;
|
||||
|
||||
error_errno:
|
||||
res = -errno;
|
||||
impulse_clear(&ir);
|
||||
free(impl);
|
||||
return NULL;
|
||||
return res;
|
||||
}
|
||||
|
||||
static void convolver_connect_port(void * Instance, unsigned long Port,
|
||||
|
|
@ -1292,8 +1294,8 @@ static const struct spa_fga_descriptor convolve_desc = {
|
|||
};
|
||||
|
||||
/** convolver2 */
|
||||
static void * convolver2_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor * Descriptor,
|
||||
unsigned long SampleRate, int index, const char *config)
|
||||
static int convolver2_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor * Descriptor,
|
||||
uint32_t rate, int index, const char *config, void **hndl)
|
||||
{
|
||||
struct plugin *pl = SPA_CONTAINER_OF(plugin, struct plugin, plugin);
|
||||
struct convolver_impl *impl = NULL;
|
||||
|
|
@ -1307,40 +1309,39 @@ static void * convolver2_instantiate(const struct spa_fga_plugin *plugin, const
|
|||
struct convolver_ir cir[8];
|
||||
int n_ir = 0;
|
||||
|
||||
errno = EINVAL;
|
||||
if (config == NULL) {
|
||||
spa_log_error(pl->log, "convolver: requires a config section");
|
||||
return NULL;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (spa_json_begin_object(&it[0], config, strlen(config)) <= 0) {
|
||||
spa_log_error(pl->log, "convolver:config must be an object");
|
||||
return NULL;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
while ((len = spa_json_object_next(&it[0], key, sizeof(key), &val)) > 0) {
|
||||
if (spa_streq(key, "blocksize")) {
|
||||
if (spa_json_parse_int(val, len, &blocksize) <= 0) {
|
||||
spa_log_error(pl->log, "convolver2:blocksize requires a number");
|
||||
return NULL;
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
else if (spa_streq(key, "tailsize")) {
|
||||
if (spa_json_parse_int(val, len, &tailsize) <= 0) {
|
||||
spa_log_error(pl->log, "convolver2:tailsize requires a number");
|
||||
return NULL;
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
else if (spa_streq(key, "latency")) {
|
||||
if (spa_json_parse_float(val, len, &latency) <= 0) {
|
||||
spa_log_error(pl->log, "convolver2:latency requires a number");
|
||||
return NULL;
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
else if (spa_streq(key, "impulses")) {
|
||||
if (!spa_json_is_array(val, len)) {
|
||||
spa_log_error(pl->log, "convolver2:impulses require an array");
|
||||
return NULL;
|
||||
return -EINVAL;
|
||||
}
|
||||
spa_json_enter(&it[0], &it[1]);
|
||||
while (spa_json_enter_object(&it[1], &it[2]) > 0) {
|
||||
|
|
@ -1349,8 +1350,8 @@ static void * convolver2_instantiate(const struct spa_fga_plugin *plugin, const
|
|||
goto error;
|
||||
}
|
||||
ir[n_ir] = IMPULSE_INIT(n_ir);
|
||||
if ((res = convolver_read_impulse(pl, &it[2], SampleRate, &ir[n_ir])) < 0)
|
||||
return NULL;
|
||||
if ((res = convolver_read_impulse(pl, &it[2], rate, &ir[n_ir])) < 0)
|
||||
return res;
|
||||
|
||||
max_samples = SPA_MAX(max_samples, ir[n_ir].n_samples);
|
||||
cir[n_ir].ir = ir[n_ir].samples;
|
||||
|
|
@ -1382,7 +1383,7 @@ static void * convolver2_instantiate(const struct spa_fga_plugin *plugin, const
|
|||
impl->plugin = pl;
|
||||
impl->log = pl->log;
|
||||
impl->dsp = pl->dsp;
|
||||
impl->rate = SampleRate;
|
||||
impl->rate = rate;
|
||||
if (latency < 0.0f)
|
||||
impl->latency = ir[0].latency;
|
||||
else
|
||||
|
|
@ -1392,13 +1393,14 @@ static void * convolver2_instantiate(const struct spa_fga_plugin *plugin, const
|
|||
if (impl->conv == NULL)
|
||||
goto error;
|
||||
|
||||
*hndl = impl;
|
||||
|
||||
return impl;
|
||||
return 0;
|
||||
error:
|
||||
for (i = 0; i < n_ir; i++)
|
||||
impulse_clear(&ir[i]);
|
||||
free(impl);
|
||||
return NULL;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static void convolver2_run(void * Instance, unsigned long SampleCount)
|
||||
|
|
@ -1502,8 +1504,8 @@ static void delay_cleanup(void * Instance)
|
|||
free(impl);
|
||||
}
|
||||
|
||||
static void *delay_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor * Descriptor,
|
||||
unsigned long SampleRate, int index, const char *config)
|
||||
static int delay_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor * Descriptor,
|
||||
uint32_t rate, int index, const char *config, void **hndl)
|
||||
{
|
||||
struct plugin *pl = SPA_CONTAINER_OF(plugin, struct plugin, plugin);
|
||||
struct delay_impl *impl;
|
||||
|
|
@ -1515,25 +1517,24 @@ static void *delay_instantiate(const struct spa_fga_plugin *plugin, const struct
|
|||
|
||||
if (config == NULL) {
|
||||
spa_log_error(pl->log, "delay: requires a config section");
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (spa_json_begin_object(&it[0], config, strlen(config)) <= 0) {
|
||||
spa_log_error(pl->log, "delay:config must be an object");
|
||||
return NULL;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
while ((len = spa_json_object_next(&it[0], key, sizeof(key), &val)) > 0) {
|
||||
if (spa_streq(key, "max-delay")) {
|
||||
if (spa_json_parse_float(val, len, &max_delay) <= 0) {
|
||||
spa_log_error(pl->log, "delay:max-delay requires a number");
|
||||
return NULL;
|
||||
return -EINVAL;
|
||||
}
|
||||
} else if (spa_streq(key, "latency")) {
|
||||
if (spa_json_parse_float(val, len, &latency) <= 0) {
|
||||
spa_log_error(pl->log, "delay:latency requires a number");
|
||||
return NULL;
|
||||
return -EINVAL;
|
||||
}
|
||||
} else {
|
||||
spa_log_warn(pl->log, "delay: ignoring config key: '%s'", key);
|
||||
|
|
@ -1546,12 +1547,12 @@ static void *delay_instantiate(const struct spa_fga_plugin *plugin, const struct
|
|||
|
||||
impl = calloc(1, sizeof(*impl));
|
||||
if (impl == NULL)
|
||||
return NULL;
|
||||
return -errno;
|
||||
|
||||
impl->plugin = pl;
|
||||
impl->dsp = pl->dsp;
|
||||
impl->log = pl->log;
|
||||
impl->rate = SampleRate;
|
||||
impl->rate = rate;
|
||||
impl->buffer_samples = SPA_ROUND_UP_N((uint32_t)(max_delay * impl->rate), 64);
|
||||
impl->latency = latency * impl->rate;
|
||||
spa_log_info(impl->log, "max-delay:%f seconds rate:%lu samples:%d latency:%f",
|
||||
|
|
@ -1561,14 +1562,15 @@ static void *delay_instantiate(const struct spa_fga_plugin *plugin, const struct
|
|||
if (spa_overflow_mul((size_t)impl->buffer_samples, (size_t)2, &buf_count) ||
|
||||
spa_overflow_add(buf_count, (size_t)64, &buf_count)) {
|
||||
delay_cleanup(impl);
|
||||
return NULL;
|
||||
return -ERANGE;
|
||||
}
|
||||
impl->buffer = calloc(buf_count, sizeof(float));
|
||||
if (impl->buffer == NULL) {
|
||||
delay_cleanup(impl);
|
||||
return NULL;
|
||||
return -errno;
|
||||
}
|
||||
return impl;
|
||||
*hndl = impl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void delay_connect_port(void * Instance, unsigned long Port,
|
||||
|
|
@ -2300,8 +2302,8 @@ static int parse_filters(struct plugin *pl, struct spa_json *iter, int rate,
|
|||
* filtersX = [ ... ] # to load channel X
|
||||
* }
|
||||
*/
|
||||
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)
|
||||
static int param_eq_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor * Descriptor,
|
||||
uint32_t rate, int index, const char *config, void **hndl)
|
||||
{
|
||||
struct plugin *pl = SPA_CONTAINER_OF(plugin, struct plugin, plugin);
|
||||
struct spa_json it[3];
|
||||
|
|
@ -2313,23 +2315,22 @@ static void *param_eq_instantiate(const struct spa_fga_plugin *plugin, const str
|
|||
|
||||
if (config == NULL) {
|
||||
spa_log_error(pl->log, "param_eq: requires a config section");
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (spa_json_begin_object(&it[0], config, strlen(config)) <= 0) {
|
||||
spa_log_error(pl->log, "param_eq: config must be an object");
|
||||
return NULL;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
impl = calloc(1, sizeof(*impl));
|
||||
if (impl == NULL)
|
||||
return NULL;
|
||||
return -errno;
|
||||
|
||||
impl->plugin = pl;
|
||||
impl->dsp = pl->dsp;
|
||||
impl->log = pl->log;
|
||||
impl->rate = SampleRate;
|
||||
impl->rate = rate;
|
||||
for (i = 0; i < SPA_N_ELEMENTS(impl->bq); i++)
|
||||
biquad_set(&impl->bq[i], BQ_NONE, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
|
|
@ -2379,10 +2380,11 @@ static void *param_eq_instantiate(const struct spa_fga_plugin *plugin, const str
|
|||
sizeof(struct biquad) * PARAM_EQ_MAX);
|
||||
}
|
||||
}
|
||||
return impl;
|
||||
*hndl = impl;
|
||||
return 0;
|
||||
error:
|
||||
free(impl);
|
||||
return NULL;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static void param_eq_connect_port(void * Instance, unsigned long Port,
|
||||
|
|
@ -2664,21 +2666,22 @@ struct dcblock_impl {
|
|||
struct dcblock dc[8];
|
||||
};
|
||||
|
||||
static void *dcblock_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor * Descriptor,
|
||||
unsigned long SampleRate, int index, const char *config)
|
||||
static int dcblock_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor * Descriptor,
|
||||
uint32_t rate, int index, const char *config, void **hndl)
|
||||
{
|
||||
struct plugin *pl = SPA_CONTAINER_OF(plugin, struct plugin, plugin);
|
||||
struct dcblock_impl *impl;
|
||||
|
||||
impl = calloc(1, sizeof(*impl));
|
||||
if (impl == NULL)
|
||||
return NULL;
|
||||
return -errno;
|
||||
|
||||
impl->plugin = pl;
|
||||
impl->dsp = pl->dsp;
|
||||
impl->log = pl->log;
|
||||
impl->rate = SampleRate;
|
||||
return impl;
|
||||
impl->rate = rate;
|
||||
*hndl = impl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void dcblock_run_n(struct dcblock dc[], float *dst[], const float *src[],
|
||||
|
|
@ -3264,8 +3267,8 @@ struct busy_impl {
|
|||
float cpu_scale;
|
||||
};
|
||||
|
||||
static void *busy_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor * Descriptor,
|
||||
unsigned long SampleRate, int index, const char *config)
|
||||
static int busy_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor * Descriptor,
|
||||
uint32_t rate, int index, const char *config, void **hndl)
|
||||
{
|
||||
struct plugin *pl = SPA_CONTAINER_OF(plugin, struct plugin, plugin);
|
||||
struct busy_impl *impl;
|
||||
|
|
@ -3278,19 +3281,18 @@ static void *busy_instantiate(const struct spa_fga_plugin *plugin, const struct
|
|||
if (config != NULL) {
|
||||
if (spa_json_begin_object(&it[0], config, strlen(config)) <= 0) {
|
||||
spa_log_error(pl->log, "busy:config must be an object");
|
||||
return NULL;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
while ((len = spa_json_object_next(&it[0], key, sizeof(key), &val)) > 0) {
|
||||
if (spa_streq(key, "wait-percent")) {
|
||||
if (spa_json_parse_float(val, len, &wait_percent) <= 0) {
|
||||
spa_log_error(pl->log, "busy:wait-percent requires a number");
|
||||
return NULL;
|
||||
return -EINVAL;
|
||||
}
|
||||
} else if (spa_streq(key, "cpu-percent")) {
|
||||
if (spa_json_parse_float(val, len, &cpu_percent) <= 0) {
|
||||
spa_log_error(pl->log, "busy:cpu-percent requires a number");
|
||||
return NULL;
|
||||
return -EINVAL;
|
||||
}
|
||||
} else {
|
||||
spa_log_warn(pl->log, "busy: ignoring config key: '%s'", key);
|
||||
|
|
@ -3304,17 +3306,18 @@ static void *busy_instantiate(const struct spa_fga_plugin *plugin, const struct
|
|||
|
||||
impl = calloc(1, sizeof(*impl));
|
||||
if (impl == NULL)
|
||||
return NULL;
|
||||
return -errno;
|
||||
|
||||
impl->plugin = pl;
|
||||
impl->dsp = pl->dsp;
|
||||
impl->log = pl->log;
|
||||
impl->rate = SampleRate;
|
||||
impl->wait_scale = wait_percent * SPA_NSEC_PER_SEC / (100.0f * SampleRate);
|
||||
impl->cpu_scale = cpu_percent * SPA_NSEC_PER_SEC / (100.0f * SampleRate);
|
||||
impl->rate = rate;
|
||||
impl->wait_scale = wait_percent * SPA_NSEC_PER_SEC / (100.0f * rate);
|
||||
impl->cpu_scale = cpu_percent * SPA_NSEC_PER_SEC / (100.0f * rate);
|
||||
spa_log_info(impl->log, "wait-percent:%f cpu-percent:%f", wait_percent, cpu_percent);
|
||||
*hndl = impl;
|
||||
|
||||
return impl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void busy_run(void * Instance, unsigned long SampleCount)
|
||||
|
|
|
|||
|
|
@ -68,8 +68,8 @@ struct ebur128_impl {
|
|||
ebur128_state *st[7];
|
||||
};
|
||||
|
||||
static void * ebur128_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor * Descriptor,
|
||||
unsigned long SampleRate, int index, const char *config)
|
||||
static int ebur128_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor * Descriptor,
|
||||
uint32_t rate, int index, const char *config, void **hndl)
|
||||
{
|
||||
struct plugin *pl = SPA_CONTAINER_OF(plugin, struct plugin, plugin);
|
||||
struct ebur128_impl *impl;
|
||||
|
|
@ -80,31 +80,27 @@ static void * ebur128_instantiate(const struct spa_fga_plugin *plugin, const str
|
|||
float f;
|
||||
|
||||
impl = calloc(1, sizeof(*impl));
|
||||
if (impl == NULL) {
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
if (impl == NULL)
|
||||
return -errno;
|
||||
|
||||
impl->plugin = pl;
|
||||
impl->dsp = pl->dsp;
|
||||
impl->log = pl->log;
|
||||
impl->max_history = 10000;
|
||||
impl->max_window = 0;
|
||||
impl->rate = SampleRate;
|
||||
impl->rate = rate;
|
||||
|
||||
if (config == NULL)
|
||||
return impl;
|
||||
goto done;
|
||||
|
||||
if (spa_json_begin_object(&it[0], config, strlen(config)) <= 0) {
|
||||
spa_log_error(pl->log, "ebur128: expected object in config");
|
||||
errno = EINVAL;
|
||||
goto error;
|
||||
}
|
||||
while ((len = spa_json_object_next(&it[0], key, sizeof(key), &val)) > 0) {
|
||||
if (spa_streq(key, "max-history")) {
|
||||
if (spa_json_parse_float(val, len, &f) <= 0) {
|
||||
spa_log_error(impl->log, "ebur128:max-history requires a number");
|
||||
errno = EINVAL;
|
||||
goto error;
|
||||
}
|
||||
impl->max_history = (unsigned int) (f * 1000.0f);
|
||||
|
|
@ -112,7 +108,6 @@ static void * ebur128_instantiate(const struct spa_fga_plugin *plugin, const str
|
|||
else if (spa_streq(key, "max-window")) {
|
||||
if (spa_json_parse_float(val, len, &f) <= 0) {
|
||||
spa_log_error(impl->log, "ebur128:max-window requires a number");
|
||||
errno = EINVAL;
|
||||
goto error;
|
||||
}
|
||||
impl->max_window = (unsigned int) (f * 1000.0f);
|
||||
|
|
@ -120,17 +115,18 @@ static void * ebur128_instantiate(const struct spa_fga_plugin *plugin, const str
|
|||
else if (spa_streq(key, "use-histogram")) {
|
||||
if (spa_json_parse_bool(val, len, &impl->use_histogram) <= 0) {
|
||||
spa_log_error(impl->log, "ebur128:use-histogram requires a boolean");
|
||||
errno = EINVAL;
|
||||
goto error;
|
||||
}
|
||||
} else {
|
||||
spa_log_warn(impl->log, "ebur128: unknown key %s", key);
|
||||
}
|
||||
}
|
||||
return impl;
|
||||
done:
|
||||
*hndl = impl;
|
||||
return 0;
|
||||
error:
|
||||
free(impl);
|
||||
return NULL;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static void ebur128_run(void * Instance, unsigned long SampleCount)
|
||||
|
|
@ -422,24 +418,22 @@ struct lufs2gain_impl {
|
|||
float *port[3];
|
||||
};
|
||||
|
||||
static void * lufs2gain_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor * Descriptor,
|
||||
unsigned long SampleRate, int index, const char *config)
|
||||
static int lufs2gain_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor * Descriptor,
|
||||
uint32_t rate, int index, const char *config, void **hndl)
|
||||
{
|
||||
struct plugin *pl = SPA_CONTAINER_OF(plugin, struct plugin, plugin);
|
||||
struct lufs2gain_impl *impl;
|
||||
|
||||
impl = calloc(1, sizeof(*impl));
|
||||
if (impl == NULL) {
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
if (impl == NULL)
|
||||
return -errno;
|
||||
|
||||
impl->plugin = pl;
|
||||
impl->dsp = pl->dsp;
|
||||
impl->log = pl->log;
|
||||
impl->rate = SampleRate;
|
||||
|
||||
return impl;
|
||||
impl->rate = rate;
|
||||
*hndl = impl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void lufs2gain_connect_port(void * Instance, unsigned long Port,
|
||||
|
|
|
|||
|
|
@ -84,8 +84,8 @@ static void ffmpeg_cleanup(void *instance)
|
|||
free(i);
|
||||
}
|
||||
|
||||
static void *ffmpeg_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor *desc,
|
||||
unsigned long SampleRate, int index, const char *config)
|
||||
static int ffmpeg_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor *desc,
|
||||
uint32_t rate, int index, const char *config, void **hndl)
|
||||
{
|
||||
struct descriptor *d = (struct descriptor *)desc;
|
||||
struct plugin *p = d->p;
|
||||
|
|
@ -99,21 +99,21 @@ static void *ffmpeg_instantiate(const struct spa_fga_plugin *plugin, const struc
|
|||
|
||||
i = calloc(1, sizeof(*i));
|
||||
if (i == NULL)
|
||||
return NULL;
|
||||
return -errno;
|
||||
|
||||
i->desc = d;
|
||||
i->rate = SampleRate;
|
||||
i->rate = rate;
|
||||
|
||||
i->filter_graph = avfilter_graph_alloc();
|
||||
if (i->filter_graph == NULL) {
|
||||
errno = ENOMEM;
|
||||
res = -ENOMEM;
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
res = avfilter_graph_parse2(i->filter_graph, d->desc.name, &in, &out);
|
||||
if (res < 0) {
|
||||
spa_log_error(p->log, "can parse filter graph %s", d->desc.name);
|
||||
errno = EINVAL;
|
||||
res = -EINVAL;
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
|
|
@ -121,13 +121,14 @@ static void *ffmpeg_instantiate(const struct spa_fga_plugin *plugin, const struc
|
|||
ctx = avfilter_graph_alloc_filter(i->filter_graph, d->buffersrc, "src");
|
||||
if (ctx == NULL) {
|
||||
spa_log_error(p->log, "can't alloc buffersrc");
|
||||
res = -ENOMEM;
|
||||
goto error_free;
|
||||
}
|
||||
av_channel_layout_describe(&d->layout[n_fp], channel, sizeof(channel));
|
||||
|
||||
snprintf(options_str, sizeof(options_str),
|
||||
"sample_fmt=%s:sample_rate=%ld:channel_layout=%s",
|
||||
av_get_sample_fmt_name(AV_SAMPLE_FMT_FLTP), SampleRate, channel);
|
||||
"sample_fmt=%s:sample_rate=%u:channel_layout=%s",
|
||||
av_get_sample_fmt_name(AV_SAMPLE_FMT_FLTP), rate, channel);
|
||||
|
||||
spa_log_info(p->log, "%d buffersrc %s", n_fp, options_str);
|
||||
avfilter_init_str(ctx, options_str);
|
||||
|
|
@ -140,14 +141,15 @@ static void *ffmpeg_instantiate(const struct spa_fga_plugin *plugin, const struc
|
|||
cnv = avfilter_graph_alloc_filter(i->filter_graph, d->format, "format");
|
||||
if (cnv == NULL) {
|
||||
spa_log_error(p->log, "can't alloc format");
|
||||
res = -ENOMEM;
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
av_channel_layout_describe(&d->layout[n_fp], channel, sizeof(channel));
|
||||
|
||||
snprintf(options_str, sizeof(options_str),
|
||||
"sample_fmts=%s:sample_rates=%ld:channel_layouts=%s",
|
||||
av_get_sample_fmt_name(AV_SAMPLE_FMT_FLTP), SampleRate, channel);
|
||||
"sample_fmts=%s:sample_rates=%u:channel_layouts=%s",
|
||||
av_get_sample_fmt_name(AV_SAMPLE_FMT_FLTP), rate, channel);
|
||||
|
||||
spa_log_info(p->log, "%d format %s", n_fp, options_str);
|
||||
avfilter_init_str(cnv, options_str);
|
||||
|
|
@ -156,6 +158,7 @@ static void *ffmpeg_instantiate(const struct spa_fga_plugin *plugin, const struc
|
|||
ctx = avfilter_graph_alloc_filter(i->filter_graph, d->buffersink, "sink");
|
||||
if (ctx == NULL) {
|
||||
spa_log_error(p->log, "can't alloc buffersink");
|
||||
res = -ENOMEM;
|
||||
goto error_free;
|
||||
}
|
||||
avfilter_init_str(ctx, NULL);
|
||||
|
|
@ -175,11 +178,12 @@ static void *ffmpeg_instantiate(const struct spa_fga_plugin *plugin, const struc
|
|||
spa_log_debug(p->log, "%s", dump);
|
||||
free(dump);
|
||||
#endif
|
||||
return i;
|
||||
*hndl = i;
|
||||
return 0;
|
||||
|
||||
error_free:
|
||||
ffmpeg_cleanup(i);
|
||||
return NULL;
|
||||
return res;
|
||||
}
|
||||
|
||||
static void ffmpeg_free(const struct spa_fga_descriptor *desc)
|
||||
|
|
|
|||
|
|
@ -34,11 +34,14 @@ struct descriptor {
|
|||
const LADSPA_Descriptor *d;
|
||||
};
|
||||
|
||||
static void *ladspa_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor *desc,
|
||||
unsigned long SampleRate, int index, const char *config)
|
||||
static int ladspa_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor *desc,
|
||||
uint32_t rate, int index, const char *config, void **hndl)
|
||||
{
|
||||
struct descriptor *d = (struct descriptor *)desc;
|
||||
return d->d->instantiate(d->d, SampleRate);
|
||||
*hndl = d->d->instantiate(d->d, rate);
|
||||
if (*hndl == NULL)
|
||||
return -ENOMEM;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const LADSPA_Descriptor *find_desc(LADSPA_Descriptor_Function desc_func, const char *name)
|
||||
|
|
|
|||
|
|
@ -374,8 +374,8 @@ static int log_printf(LV2_Log_Handle handle, LV2_URID type, const char* fmt, ...
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void *lv2_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor *desc,
|
||||
unsigned long SampleRate, int index, const char *config)
|
||||
static int lv2_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor *desc,
|
||||
uint32_t rate, int index, const char *config, void **hndl)
|
||||
{
|
||||
struct descriptor *d = (struct descriptor*)desc;
|
||||
struct plugin *p = d->p;
|
||||
|
|
@ -385,11 +385,11 @@ static void *lv2_instantiate(const struct spa_fga_plugin *plugin, const struct s
|
|||
static const int32_t min_block_length = 1;
|
||||
static const int32_t max_block_length = 8192;
|
||||
static const int32_t seq_size = 32768;
|
||||
float fsample_rate = SampleRate;
|
||||
float fsample_rate = rate;
|
||||
|
||||
i = calloc(1, sizeof(*i));
|
||||
if (i == NULL)
|
||||
return NULL;
|
||||
return -errno;
|
||||
|
||||
i->block_length = 1024;
|
||||
i->desc = d;
|
||||
|
|
@ -436,10 +436,10 @@ static void *lv2_instantiate(const struct spa_fga_plugin *plugin, const struct s
|
|||
i->features[n_features++] = NULL;
|
||||
spa_assert(n_features < SPA_N_ELEMENTS(i->features));
|
||||
|
||||
i->instance = lilv_plugin_instantiate(p->p, SampleRate, i->features);
|
||||
i->instance = lilv_plugin_instantiate(p->p, rate, i->features);
|
||||
if (i->instance == NULL) {
|
||||
free(i);
|
||||
return NULL;
|
||||
return -ENOMEM;
|
||||
}
|
||||
if (lilv_plugin_has_extension_data(p->p, c->worker_iface)) {
|
||||
i->work_iface = (const LV2_Worker_Interface*)
|
||||
|
|
@ -461,7 +461,8 @@ static void *lv2_instantiate(const struct spa_fga_plugin *plugin, const struct s
|
|||
&sd, 0, i->features);
|
||||
free(sd.tmp);
|
||||
}
|
||||
return i;
|
||||
*hndl = i;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void lv2_cleanup(void *instance)
|
||||
|
|
|
|||
|
|
@ -272,8 +272,8 @@ static int set_value(void *data, enum ONNXTensorElementDataType type, double val
|
|||
* }
|
||||
*/
|
||||
|
||||
static void *onnx_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor *desc,
|
||||
unsigned long SampleRate, int index, const char *config)
|
||||
static int onnx_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor *desc,
|
||||
uint32_t rate, int index, const char *config, void **hndl)
|
||||
{
|
||||
struct descriptor *d = (struct descriptor *)desc;
|
||||
struct plugin *p = d->p;
|
||||
|
|
@ -282,14 +282,12 @@ static void *onnx_instantiate(const struct spa_fga_plugin *plugin, const struct
|
|||
size_t n, j;
|
||||
int res;
|
||||
|
||||
errno = EINVAL;
|
||||
|
||||
i = calloc(1, sizeof(*i));
|
||||
if (i == NULL)
|
||||
return NULL;
|
||||
return -errno;
|
||||
|
||||
i->desc = d;
|
||||
i->rate = SampleRate;
|
||||
i->rate = rate;
|
||||
|
||||
for (n = 0; n < d->n_tensors; n++) {
|
||||
struct tensor_info *ti = &d->tensors[n];
|
||||
|
|
@ -309,22 +307,21 @@ static void *onnx_instantiate(const struct spa_fga_plugin *plugin, const struct
|
|||
CHECK(ort->GetTensorMutableData(i->tensor[n], (void**)&data));
|
||||
|
||||
if (ti->data_type == DATA_PARAM_RATE) {
|
||||
if ((res = set_value(data, ti->type, (double)i->rate)) < 0) {
|
||||
errno = -res;
|
||||
if ((res = set_value(data, ti->type, (double)i->rate)) < 0)
|
||||
goto error;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return i;
|
||||
*hndl = i;
|
||||
return 0;
|
||||
|
||||
error_onnx:
|
||||
const char* msg = ort->GetErrorMessage(status);
|
||||
spa_log_error(p->log, "%s", msg);
|
||||
ort->ReleaseStatus(status);
|
||||
res = -EINVAL;
|
||||
error:
|
||||
free(i);
|
||||
return NULL;
|
||||
return res;
|
||||
}
|
||||
|
||||
static void onnx_cleanup(void *instance)
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ struct spatializer_impl {
|
|||
struct convolver *conv[3];
|
||||
};
|
||||
|
||||
static void * spatializer_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor * Descriptor,
|
||||
unsigned long SampleRate, int index, const char *config)
|
||||
static int spatializer_instantiate(const struct spa_fga_plugin *plugin, const struct spa_fga_descriptor * Descriptor,
|
||||
uint32_t rate, int index, const char *config, void **hndl)
|
||||
{
|
||||
struct plugin *pl = SPA_CONTAINER_OF(plugin, struct plugin, plugin);
|
||||
struct spatializer_impl *impl;
|
||||
|
|
@ -52,24 +52,21 @@ static void * spatializer_instantiate(const struct spa_fga_plugin *plugin, const
|
|||
char filename[PATH_MAX] = "";
|
||||
bool normalize = false;
|
||||
float normalized;
|
||||
int len;
|
||||
int res, len;
|
||||
|
||||
errno = EINVAL;
|
||||
if (config == NULL) {
|
||||
spa_log_error(pl->log, "spatializer: no config was given");
|
||||
return NULL;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (spa_json_begin_object(&it[0], config, strlen(config)) <= 0) {
|
||||
spa_log_error(pl->log, "spatializer: expected object in config");
|
||||
return NULL;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
impl = calloc(1, sizeof(*impl));
|
||||
if (impl == NULL) {
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
if (impl == NULL)
|
||||
return -errno;
|
||||
|
||||
impl->plugin = pl;
|
||||
impl->dsp = pl->dsp;
|
||||
|
|
@ -81,43 +78,37 @@ static void * spatializer_instantiate(const struct spa_fga_plugin *plugin, const
|
|||
if (spa_streq(key, "blocksize")) {
|
||||
if (spa_json_parse_int(val, len, &impl->blocksize) <= 0) {
|
||||
spa_log_error(impl->log, "spatializer:blocksize requires a number");
|
||||
errno = EINVAL;
|
||||
goto error;
|
||||
goto error_inval;
|
||||
}
|
||||
}
|
||||
else if (spa_streq(key, "tailsize")) {
|
||||
if (spa_json_parse_int(val, len, &impl->tailsize) <= 0) {
|
||||
spa_log_error(impl->log, "spatializer:tailsize requires a number");
|
||||
errno = EINVAL;
|
||||
goto error;
|
||||
goto error_inval;
|
||||
}
|
||||
}
|
||||
else if (spa_streq(key, "filename")) {
|
||||
if (spa_json_parse_stringn(val, len, filename, sizeof(filename)) <= 0) {
|
||||
spa_log_error(impl->log, "spatializer:filename requires a string");
|
||||
errno = EINVAL;
|
||||
goto error;
|
||||
goto error_inval;
|
||||
}
|
||||
}
|
||||
else if (spa_streq(key, "gain")) {
|
||||
if (spa_json_parse_float(val, len, &impl->gain) <= 0) {
|
||||
spa_log_error(impl->log, "spatializer:gain requires a number");
|
||||
errno = EINVAL;
|
||||
goto error;
|
||||
goto error_inval;
|
||||
}
|
||||
}
|
||||
else if (spa_streq(key, "normalize")) {
|
||||
if (spa_json_parse_bool(val, len, &normalize) <= 0) {
|
||||
spa_log_error(impl->log, "spatializer:normalize requires a bool");
|
||||
errno = EINVAL;
|
||||
goto error;
|
||||
goto error_inval;
|
||||
}
|
||||
}
|
||||
else if (spa_streq(key, "latency")) {
|
||||
if (spa_json_parse_float(val, len, &impl->latency) <= 0) {
|
||||
spa_log_error(impl->log, "spatializer:latency requires a number");
|
||||
errno = EINVAL;
|
||||
goto error;
|
||||
goto error_inval;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
@ -126,87 +117,86 @@ static void * spatializer_instantiate(const struct spa_fga_plugin *plugin, const
|
|||
}
|
||||
if (!filename[0]) {
|
||||
spa_log_error(impl->log, "spatializer:filename was not given");
|
||||
errno = EINVAL;
|
||||
goto error;
|
||||
goto error_inval;
|
||||
}
|
||||
|
||||
int ret = MYSOFA_OK;
|
||||
|
||||
impl->sofa = mysofa_open_cached(filename, SampleRate, &impl->n_samples, &ret);
|
||||
impl->sofa = mysofa_open_cached(filename, rate, &impl->n_samples, &ret);
|
||||
|
||||
if (ret != MYSOFA_OK) {
|
||||
const char *reason;
|
||||
switch (ret) {
|
||||
case MYSOFA_INVALID_FORMAT:
|
||||
reason = "Invalid format";
|
||||
errno = EINVAL;
|
||||
res = -EINVAL;
|
||||
break;
|
||||
case MYSOFA_UNSUPPORTED_FORMAT:
|
||||
reason = "Unsupported format";
|
||||
errno = ENOTSUP;
|
||||
res = -ENOTSUP;
|
||||
break;
|
||||
case MYSOFA_NO_MEMORY:
|
||||
reason = "No memory";
|
||||
errno = ENOMEM;
|
||||
res = -ENOMEM;
|
||||
break;
|
||||
case MYSOFA_READ_ERROR:
|
||||
reason = "Read error";
|
||||
errno = ENOENT;
|
||||
res = -ENOENT;
|
||||
break;
|
||||
case MYSOFA_INVALID_ATTRIBUTES:
|
||||
reason = "Invalid attributes";
|
||||
errno = EINVAL;
|
||||
res = -EINVAL;
|
||||
break;
|
||||
case MYSOFA_INVALID_DIMENSIONS:
|
||||
reason = "Invalid dimensions";
|
||||
errno = EINVAL;
|
||||
res = -EINVAL;
|
||||
break;
|
||||
case MYSOFA_INVALID_DIMENSION_LIST:
|
||||
reason = "Invalid dimension list";
|
||||
errno = EINVAL;
|
||||
res = -EINVAL;
|
||||
break;
|
||||
case MYSOFA_INVALID_COORDINATE_TYPE:
|
||||
reason = "Invalid coordinate type";
|
||||
errno = EINVAL;
|
||||
res = -EINVAL;
|
||||
break;
|
||||
case MYSOFA_ONLY_EMITTER_WITH_ECI_SUPPORTED:
|
||||
reason = "Only emitter with ECI supported";
|
||||
errno = ENOTSUP;
|
||||
res = -ENOTSUP;
|
||||
break;
|
||||
case MYSOFA_ONLY_DELAYS_WITH_IR_OR_MR_SUPPORTED:
|
||||
reason = "Only delays with IR or MR supported";
|
||||
errno = ENOTSUP;
|
||||
res = -ENOTSUP;
|
||||
break;
|
||||
case MYSOFA_ONLY_THE_SAME_SAMPLING_RATE_SUPPORTED:
|
||||
reason = "Only the same sampling rate supported";
|
||||
errno = ENOTSUP;
|
||||
res = -ENOTSUP;
|
||||
break;
|
||||
case MYSOFA_RECEIVERS_WITH_RCI_SUPPORTED:
|
||||
reason = "Receivers with RCI supported";
|
||||
errno = ENOTSUP;
|
||||
res = -ENOTSUP;
|
||||
break;
|
||||
case MYSOFA_RECEIVERS_WITH_CARTESIAN_SUPPORTED:
|
||||
reason = "Receivers with cartesian supported";
|
||||
errno = ENOTSUP;
|
||||
res = -ENOTSUP;
|
||||
break;
|
||||
case MYSOFA_INVALID_RECEIVER_POSITIONS:
|
||||
reason = "Invalid receiver positions";
|
||||
errno = EINVAL;
|
||||
res = -EINVAL;
|
||||
break;
|
||||
case MYSOFA_ONLY_SOURCES_WITH_MC_SUPPORTED:
|
||||
reason = "Only sources with MC supported";
|
||||
errno = ENOTSUP;
|
||||
res = -ENOTSUP;
|
||||
break;
|
||||
case MYSOFA_INTERNAL_ERROR:
|
||||
errno = EIO;
|
||||
res = -EIO;
|
||||
reason = "Internal error";
|
||||
break;
|
||||
default:
|
||||
errno = ret;
|
||||
reason = strerror(errno);
|
||||
res = -ret;
|
||||
reason = strerror(-ret);
|
||||
break;
|
||||
}
|
||||
spa_log_error(impl->log, "Unable to load HRTF from %s: %s (%d)", filename, reason, ret);
|
||||
spa_log_error(impl->log, "Unable to load HRTF from %s: %s (%d)", filename, reason, res);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
|
@ -227,16 +217,21 @@ static void * spatializer_instantiate(const struct spa_fga_plugin *plugin, const
|
|||
impl->tmp[1] = calloc(impl->plugin->quantum_limit, sizeof(float));
|
||||
if (impl->tmp[0] == NULL || impl->tmp[1] == NULL)
|
||||
goto error;
|
||||
impl->rate = SampleRate;
|
||||
impl->rate = rate;
|
||||
|
||||
return impl;
|
||||
*hndl = impl;
|
||||
return 0;
|
||||
|
||||
error_inval:
|
||||
res = -EINVAL;
|
||||
goto error;
|
||||
error:
|
||||
free(impl->tmp[0]);
|
||||
free(impl->tmp[1]);
|
||||
if (impl->sofa)
|
||||
mysofa_close_cached(impl->sofa);
|
||||
free(impl);
|
||||
return NULL;
|
||||
return res;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue