mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
convolver: parse array from filename
This commit is contained in:
parent
051d223d73
commit
9d66de446b
1 changed files with 14 additions and 13 deletions
|
|
@ -667,10 +667,9 @@ static void * convolver_instantiate(const struct fc_descriptor * Descriptor,
|
||||||
{
|
{
|
||||||
struct convolver_impl *impl;
|
struct convolver_impl *impl;
|
||||||
float *samples;
|
float *samples;
|
||||||
int offset = 0, length = 0, channel = index, n_samples;
|
int offset = 0, length = 0, channel = index, n_samples, len;
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
struct spa_json it[2];
|
struct spa_json it[2];
|
||||||
struct spa_json filenames_json;
|
|
||||||
const char *val;
|
const char *val;
|
||||||
char key[256], v[256];
|
char key[256], v[256];
|
||||||
char filename[PATH_MAX] = "";
|
char filename[PATH_MAX] = "";
|
||||||
|
|
@ -715,19 +714,21 @@ static void * convolver_instantiate(const struct fc_descriptor * Descriptor,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (spa_streq(key, "filename")) {
|
else if (spa_streq(key, "filename")) {
|
||||||
if (spa_json_get_string(&it[1], filename, sizeof(filename)) <= 0) {
|
if ((len = spa_json_next(&it[1], &val)) <= 0) {
|
||||||
pw_log_error("convolver:filename requires a string");
|
pw_log_error("convolver:filename requires a string or an array");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
if (spa_json_is_array(val, len)) {
|
||||||
else if (spa_streq(key, "filenames")) {
|
spa_json_enter(&it[1], &it[2]);
|
||||||
if (spa_json_enter_array(&it[1], &filenames_json) <= 0) {
|
while (spa_json_get_string(&it[2], v, sizeof(v)) > 0 &&
|
||||||
pw_log_error("convolver:filenames requires an array");
|
i < SPA_N_ELEMENTS(filenames)) {
|
||||||
return NULL;
|
filenames[i] = strdup(v);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
while (spa_json_get_string(&filenames_json, v, sizeof(v)) > 0 && i < SPA_N_ELEMENTS(filenames)) {
|
else if (spa_json_parse_stringn(val, len, filename, sizeof(filename)) <= 0) {
|
||||||
filenames[i] = strdup(v);
|
pw_log_error("convolver:filename requires a string or an array");
|
||||||
i++;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (spa_streq(key, "offset")) {
|
else if (spa_streq(key, "offset")) {
|
||||||
|
|
@ -758,7 +759,7 @@ static void * convolver_instantiate(const struct fc_descriptor * Descriptor,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!filename[0] && !filenames[0]) {
|
if (!filename[0] && !filenames[0]) {
|
||||||
pw_log_error("convolver:filename nor filenames was given");
|
pw_log_error("convolver:filename was not given");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue