mirror of
https://gitlab.freedesktop.org/pipewire/pipewire
synced 2024-09-16 06:29:56 +00:00
filter-chain: report more parsing errors
This commit is contained in:
parent
66b8cd3e32
commit
6d4f255ae9
|
@ -23,6 +23,7 @@
|
|||
#include <spa/param/tag-utils.h>
|
||||
#include <spa/pod/dynamic.h>
|
||||
#include <spa/debug/types.h>
|
||||
#include <spa/debug/log.h>
|
||||
|
||||
#include <pipewire/utils.h>
|
||||
#include <pipewire/impl.h>
|
||||
|
@ -1872,24 +1873,35 @@ exit:
|
|||
*/
|
||||
static int parse_config(struct node *node, struct spa_json *config)
|
||||
{
|
||||
const char *val;
|
||||
int len;
|
||||
|
||||
if ((len = spa_json_next(config, &val)) <= 0)
|
||||
return len;
|
||||
const char *val, *s = config->cur;
|
||||
int res = 0, len;
|
||||
struct spa_error_location loc;
|
||||
|
||||
if ((len = spa_json_next(config, &val)) <= 0) {
|
||||
res = -EINVAL;
|
||||
goto done;
|
||||
}
|
||||
if (spa_json_is_null(val, len))
|
||||
return 0;
|
||||
goto done;
|
||||
|
||||
if (spa_json_is_container(val, len))
|
||||
if (spa_json_is_container(val, len)) {
|
||||
len = spa_json_container_len(config, val, len);
|
||||
|
||||
if ((node->config = malloc(len+1)) == NULL)
|
||||
return -errno;
|
||||
if (len == 0) {
|
||||
res = -EINVAL;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
if ((node->config = malloc(len+1)) == NULL) {
|
||||
res = -errno;
|
||||
goto done;
|
||||
}
|
||||
|
||||
spa_json_parse_stringn(val, len, node->config, len+1);
|
||||
|
||||
return 0;
|
||||
done:
|
||||
if (spa_json_get_error(config, s, &loc))
|
||||
spa_debug_log_error_location(pw_log_get(), SPA_LOG_LEVEL_WARN,
|
||||
&loc, "error: %s", loc.reason);
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -42,12 +42,16 @@ static void * spatializer_instantiate(const struct fc_descriptor * Descriptor,
|
|||
char filename[PATH_MAX] = "";
|
||||
|
||||
errno = EINVAL;
|
||||
if (config == NULL)
|
||||
if (config == NULL) {
|
||||
pw_log_error("spatializer: no config was given");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
spa_json_init(&it[0], config, strlen(config));
|
||||
if (spa_json_enter_object(&it[0], &it[1]) <= 0)
|
||||
if (spa_json_enter_object(&it[0], &it[1]) <= 0) {
|
||||
pw_log_error("spatializer: expected object in config");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
impl = calloc(1, sizeof(*impl));
|
||||
if (impl == NULL) {
|
||||
|
|
Loading…
Reference in a new issue