mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-05-03 06:47:04 -04:00
Merge branch 'object-type-checks' into 'master'
*: more type checks for POD See merge request pipewire/pipewire!2488
This commit is contained in:
commit
fc765d5cb5
20 changed files with 67 additions and 28 deletions
|
|
@ -834,6 +834,11 @@ static void parse_props(struct global *g, const struct spa_pod *param, bool devi
|
|||
struct spa_pod_object *obj = (struct spa_pod_object *) param;
|
||||
snd_ctl_pipewire_t *ctl = g->ctl;
|
||||
|
||||
if (!spa_pod_is_object_type(param, SPA_TYPE_OBJECT_Props)) {
|
||||
pw_log_warn("cannot parse %d props", g->id);
|
||||
return;
|
||||
}
|
||||
|
||||
SPA_POD_OBJECT_FOREACH(obj, prop) {
|
||||
switch (prop->key) {
|
||||
case SPA_PROP_volume:
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ spa_format_audio_dsd_parse(const struct spa_pod *format, struct spa_audio_info_d
|
|||
SPA_FORMAT_AUDIO_channels, SPA_POD_OPT_Int(&info->channels),
|
||||
SPA_FORMAT_AUDIO_position, SPA_POD_OPT_Pod(&position));
|
||||
if (position == NULL ||
|
||||
!spa_pod_is_array(position) ||
|
||||
!spa_pod_copy_array(position, SPA_TYPE_Id, info->position, SPA_AUDIO_MAX_CHANNELS))
|
||||
SPA_FLAG_SET(info->flags, SPA_AUDIO_FLAG_UNPOSITIONED);
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ spa_format_audio_raw_parse(const struct spa_pod *format, struct spa_audio_info_r
|
|||
SPA_FORMAT_AUDIO_channels, SPA_POD_OPT_Int(&info->channels),
|
||||
SPA_FORMAT_AUDIO_position, SPA_POD_OPT_Pod(&position));
|
||||
if (position == NULL ||
|
||||
!spa_pod_is_array(position) ||
|
||||
!spa_pod_copy_array(position, SPA_TYPE_Id, info->position, SPA_AUDIO_MAX_CHANNELS))
|
||||
SPA_FLAG_SET(info->flags, SPA_AUDIO_FLAG_UNPOSITIONED);
|
||||
|
||||
|
|
|
|||
|
|
@ -31,8 +31,10 @@ SPA_API_VIDEO_DSP_UTILS int
|
|||
spa_format_video_dsp_parse(const struct spa_pod *format,
|
||||
struct spa_video_info_dsp *info)
|
||||
{
|
||||
info->flags = SPA_VIDEO_FLAG_NONE;
|
||||
const struct spa_pod_prop *mod_prop;
|
||||
info->flags = SPA_VIDEO_FLAG_NONE;
|
||||
if (!spa_pod_is_object_type(format, SPA_TYPE_OBJECT_Format))
|
||||
return -EINVAL;
|
||||
if ((mod_prop = spa_pod_find_prop (format, NULL, SPA_FORMAT_VIDEO_modifier)) != NULL) {
|
||||
info->flags |= SPA_VIDEO_FLAG_MODIFIER;
|
||||
if ((mod_prop->flags & SPA_POD_PROP_FLAG_DONT_FIXATE) == SPA_POD_PROP_FLAG_DONT_FIXATE)
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ spa_format_video_raw_parse(const struct spa_pod *format,
|
|||
{
|
||||
info->flags = SPA_VIDEO_FLAG_NONE;
|
||||
const struct spa_pod_prop *mod_prop;
|
||||
if (!spa_pod_is_object_type(format, SPA_TYPE_OBJECT_Format))
|
||||
return -EINVAL;
|
||||
if ((mod_prop = spa_pod_find_prop (format, NULL, SPA_FORMAT_VIDEO_modifier)) != NULL) {
|
||||
info->flags |= SPA_VIDEO_FLAG_MODIFIER;
|
||||
if ((mod_prop->flags & SPA_POD_PROP_FLAG_DONT_FIXATE) == SPA_POD_PROP_FLAG_DONT_FIXATE)
|
||||
|
|
|
|||
|
|
@ -257,7 +257,8 @@ static int impl_node_set_param(void *object, uint32_t id, uint32_t flags,
|
|||
SPA_PROP_iec958Codecs, SPA_POD_OPT_Pod(&iec958_codecs),
|
||||
SPA_PROP_params, SPA_POD_OPT_Pod(¶ms));
|
||||
|
||||
if ((this->is_iec958 || this->is_hdmi) && iec958_codecs != NULL) {
|
||||
if ((this->is_iec958 || this->is_hdmi) && iec958_codecs != NULL &&
|
||||
spa_pod_is_array(iec958_codecs)) {
|
||||
uint32_t i, codecs[16], n_codecs;
|
||||
n_codecs = spa_pod_copy_array(iec958_codecs, SPA_TYPE_Id,
|
||||
codecs, SPA_N_ELEMENTS(codecs));
|
||||
|
|
|
|||
|
|
@ -1657,6 +1657,9 @@ static int apply_props(struct impl *this, const struct spa_pod *param)
|
|||
|
||||
spa_zero(vrp);
|
||||
|
||||
if (!spa_pod_is_object_type(param, SPA_TYPE_OBJECT_Props))
|
||||
return -EINVAL;
|
||||
|
||||
SPA_POD_OBJECT_FOREACH(obj, prop) {
|
||||
switch (prop->key) {
|
||||
case SPA_PROP_volume:
|
||||
|
|
@ -1827,7 +1830,9 @@ static int apply_midi(struct impl *this, const struct spa_pod *value)
|
|||
uint8_t data[8];
|
||||
int size;
|
||||
|
||||
size = spa_ump_to_midi(SPA_POD_BODY(value), SPA_POD_BODY_SIZE(value),
|
||||
if (!spa_pod_is_bytes(value))
|
||||
return -EINVAL;
|
||||
size = spa_ump_to_midi(SPA_POD_BODY(value), value->size,
|
||||
data, sizeof(data));
|
||||
if (size < 3)
|
||||
return -EINVAL;
|
||||
|
|
@ -1973,7 +1978,8 @@ static int node_set_param_props(struct impl *this, uint32_t flags,
|
|||
|
||||
if (param == NULL)
|
||||
return 0;
|
||||
|
||||
if (!spa_pod_is_object_type(param, SPA_TYPE_OBJECT_Props))
|
||||
return -EINVAL;
|
||||
this->filter_props_count = 0;
|
||||
|
||||
spa_list_for_each_safe(g, t, &this->active_graphs, link) {
|
||||
|
|
|
|||
|
|
@ -251,13 +251,19 @@ static int apply_props(struct impl *this, const struct spa_pod *param)
|
|||
struct props *p = &this->props;
|
||||
int changed = 0;
|
||||
|
||||
if (!spa_pod_is_object_type(param, SPA_TYPE_OBJECT_Props))
|
||||
return -EINVAL;
|
||||
SPA_POD_OBJECT_FOREACH(obj, prop) {
|
||||
switch (prop->key) {
|
||||
case SPA_PROP_volume:
|
||||
if (!spa_pod_is_float(&prop->value))
|
||||
return -EINVAL;
|
||||
if (spa_pod_get_float(&prop->value, &p->volume) == 0)
|
||||
changed++;
|
||||
break;
|
||||
case SPA_PROP_mute:
|
||||
if (!spa_pod_is_bool(&prop->value))
|
||||
return -EINVAL;
|
||||
if (spa_pod_get_bool(&prop->value, &p->mute) == 0)
|
||||
changed++;
|
||||
break;
|
||||
|
|
@ -272,6 +278,7 @@ static int impl_node_set_param(void *object, uint32_t id, uint32_t flags,
|
|||
const struct spa_pod *param)
|
||||
{
|
||||
struct impl *this = object;
|
||||
int res;
|
||||
|
||||
spa_return_val_if_fail(this != NULL, -EINVAL);
|
||||
|
||||
|
|
@ -281,7 +288,9 @@ static int impl_node_set_param(void *object, uint32_t id, uint32_t flags,
|
|||
props_reset(&this->props);
|
||||
return 0;
|
||||
}
|
||||
if (apply_props(this, param) > 0) {
|
||||
if ((res = apply_props(this, param)) < 0)
|
||||
return res;
|
||||
if (res > 0) {
|
||||
this->info.change_mask = SPA_NODE_CHANGE_MASK_PARAMS;
|
||||
this->params[1].flags ^= SPA_PARAM_INFO_SERIAL;
|
||||
emit_info(this, false);
|
||||
|
|
|
|||
|
|
@ -567,6 +567,8 @@ static int impl_node_set_param(void *object, uint32_t id, uint32_t flags,
|
|||
case SPA_PARAM_Props:
|
||||
{
|
||||
int res, codec_res = 0;
|
||||
if (!spa_pod_is_object_type(param, SPA_TYPE_OBJECT_Props))
|
||||
return -EINVAL;
|
||||
res = apply_props(this, param);
|
||||
if (this->codec_props && this->codec->set_props) {
|
||||
codec_res = this->codec->set_props(this->codec_props, param);
|
||||
|
|
|
|||
|
|
@ -383,6 +383,8 @@ static int impl_node_set_param(void *object, uint32_t id, uint32_t flags,
|
|||
case SPA_PARAM_Props:
|
||||
{
|
||||
int res, codec_res = 0;
|
||||
if (!spa_pod_is_object_type(param, SPA_TYPE_OBJECT_Props))
|
||||
return -EINVAL;
|
||||
res = apply_props(this, param);
|
||||
if (this->codec_props && this->codec->set_props) {
|
||||
codec_res = this->codec->set_props(this->codec_props, param);
|
||||
|
|
|
|||
|
|
@ -714,6 +714,9 @@ static int impl_set_props(void *object, enum spa_direction direction, const stru
|
|||
struct volume *vol = &graph->volume[direction];
|
||||
bool do_volume = false;
|
||||
|
||||
if (!spa_pod_is_object_type(props, SPA_TYPE_OBJECT_Props))
|
||||
return -EINVAL;
|
||||
|
||||
spa_pod_dynamic_builder_init(&b, buf, sizeof(buf), 1024);
|
||||
spa_pod_builder_push_object(&b.b, &f[0], SPA_TYPE_OBJECT_Props, SPA_PARAM_Props);
|
||||
|
||||
|
|
|
|||
|
|
@ -392,6 +392,8 @@ static int impl_node_set_param(void *object,
|
|||
struct spa_pod_object *obj = (struct spa_pod_object *) param;
|
||||
struct spa_pod_prop *prop;
|
||||
|
||||
if (!spa_pod_is_object_type(param, SPA_TYPE_OBJECT_Props))
|
||||
return -EINVAL;
|
||||
if (param == NULL) {
|
||||
reset_props(p);
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -870,6 +870,8 @@ static int impl_node_set_param(void *object, uint32_t id, uint32_t flags,
|
|||
|
||||
case SPA_PARAM_Props:
|
||||
{
|
||||
if (!spa_pod_is_object_type(param, SPA_TYPE_OBJECT_Props))
|
||||
return -EINVAL;
|
||||
int in_set_param = ++this->in_set_param;
|
||||
res = spa_node_set_param(this->follower, id, flags, param);
|
||||
if (this->target != this->follower && this->in_set_param == in_set_param)
|
||||
|
|
@ -880,6 +882,8 @@ static int impl_node_set_param(void *object, uint32_t id, uint32_t flags,
|
|||
break;
|
||||
}
|
||||
case SPA_PARAM_ProcessLatency:
|
||||
if (!spa_pod_is_object_type(param, SPA_TYPE_OBJECT_ParamProcessLatency))
|
||||
return -EINVAL;
|
||||
res = spa_node_set_param(this->follower, id, flags, param);
|
||||
break;
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -711,6 +711,8 @@ static int apply_props(struct impl *this, const struct spa_pod *param)
|
|||
struct spa_pod_object *obj = (struct spa_pod_object *) param;
|
||||
int changed = 0;
|
||||
|
||||
if (!spa_pod_is_object_type(param, SPA_TYPE_OBJECT_Props))
|
||||
return -EINVAL;
|
||||
SPA_POD_OBJECT_FOREACH(obj, prop) {
|
||||
switch (prop->key) {
|
||||
case SPA_PROP_params:
|
||||
|
|
@ -807,9 +809,6 @@ static int node_set_param_port_config(struct impl *this, uint32_t flags,
|
|||
bool monitor = false, control = false;
|
||||
int res;
|
||||
|
||||
if (param == NULL)
|
||||
return 0;
|
||||
|
||||
if (spa_pod_parse_object(param,
|
||||
SPA_TYPE_OBJECT_ParamPortConfig, NULL,
|
||||
SPA_PARAM_PORT_CONFIG_direction, SPA_POD_Id(&direction),
|
||||
|
|
@ -831,15 +830,6 @@ static int node_set_param_port_config(struct impl *this, uint32_t flags,
|
|||
return reconfigure_mode(this, mode, direction, monitor, control, infop);
|
||||
}
|
||||
|
||||
static int node_set_param_props(struct impl *this, uint32_t flags,
|
||||
const struct spa_pod *param)
|
||||
{
|
||||
if (param == NULL)
|
||||
return 0;
|
||||
|
||||
apply_props(this, param);
|
||||
return 0;
|
||||
}
|
||||
static int impl_node_set_param(void *object, uint32_t id, uint32_t flags,
|
||||
const struct spa_pod *param)
|
||||
{
|
||||
|
|
@ -850,10 +840,10 @@ static int impl_node_set_param(void *object, uint32_t id, uint32_t flags,
|
|||
|
||||
switch (id) {
|
||||
case SPA_PARAM_PortConfig:
|
||||
res = node_set_param_port_config(this, flags, param);
|
||||
res = param ? node_set_param_port_config(this, flags, param) : 0;
|
||||
break;
|
||||
case SPA_PARAM_Props:
|
||||
res = node_set_param_props(this, flags, param);
|
||||
res = param ? apply_props(this, param) : 0;
|
||||
break;
|
||||
default:
|
||||
return -ENOENT;
|
||||
|
|
|
|||
|
|
@ -232,15 +232,17 @@ static int impl_node_set_param(void *object, uint32_t id, uint32_t flags,
|
|||
{
|
||||
struct props *p = &this->props;
|
||||
struct port *port = &this->port;
|
||||
int res;
|
||||
|
||||
if (param == NULL) {
|
||||
reset_props(p);
|
||||
return 0;
|
||||
}
|
||||
spa_pod_parse_object(param,
|
||||
if ((res = spa_pod_parse_object(param,
|
||||
SPA_TYPE_OBJECT_Props, NULL,
|
||||
SPA_PROP_live, SPA_POD_OPT_Bool(&p->live),
|
||||
SPA_PROP_patternType, SPA_POD_OPT_Int(&p->pattern));
|
||||
SPA_PROP_patternType, SPA_POD_OPT_Int(&p->pattern))) < 0)
|
||||
return res;
|
||||
|
||||
if (p->live)
|
||||
port->info.flags |= SPA_PORT_FLAG_LIVE;
|
||||
|
|
|
|||
|
|
@ -187,15 +187,17 @@ static int impl_node_set_param(void *object, uint32_t id, uint32_t flags,
|
|||
case SPA_PARAM_Props:
|
||||
{
|
||||
struct props *p = &this->props;
|
||||
int res;
|
||||
|
||||
if (param == NULL) {
|
||||
reset_props(p);
|
||||
return 0;
|
||||
}
|
||||
spa_pod_parse_object(param,
|
||||
if ((res = spa_pod_parse_object(param,
|
||||
SPA_TYPE_OBJECT_Props, NULL,
|
||||
SPA_PROP_volume, SPA_POD_OPT_Float(&p->volume),
|
||||
SPA_PROP_mute, SPA_POD_OPT_Bool(&p->mute));
|
||||
SPA_PROP_mute, SPA_POD_OPT_Bool(&p->mute))) < 0)
|
||||
return res;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -218,14 +218,16 @@ static int impl_node_set_param(void *object, uint32_t id, uint32_t flags,
|
|||
{
|
||||
struct props *p = &this->props;
|
||||
struct port *port = &this->port;
|
||||
int res;
|
||||
|
||||
if (param == NULL) {
|
||||
reset_props(p);
|
||||
return 0;
|
||||
}
|
||||
spa_pod_parse_object(param,
|
||||
if ((res = spa_pod_parse_object(param,
|
||||
SPA_TYPE_OBJECT_Props, NULL,
|
||||
SPA_PROP_live, SPA_POD_OPT_Bool(&p->live));
|
||||
SPA_PROP_live, SPA_POD_OPT_Bool(&p->live))) < 0)
|
||||
return res;
|
||||
|
||||
if (p->live)
|
||||
port->info.flags |= SPA_PORT_FLAG_LIVE;
|
||||
|
|
|
|||
|
|
@ -1476,7 +1476,7 @@ static void param_changed(struct impl *impl, uint32_t id, const struct spa_pod *
|
|||
break;
|
||||
}
|
||||
case SPA_PARAM_Props:
|
||||
if (param != NULL)
|
||||
if (param != NULL && spa_pod_is_object_type(param, SPA_TYPE_OBJECT_Props))
|
||||
spa_filter_graph_set_props(impl->graph, direction, param);
|
||||
break;
|
||||
case SPA_PARAM_Latency:
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ uint32_t collect_profile_info(struct pw_manager_object *card, struct card_info *
|
|||
SPA_PARAM_PROFILE_description, SPA_POD_OPT_String(&pi->description),
|
||||
SPA_PARAM_PROFILE_priority, SPA_POD_OPT_Int(&pi->priority),
|
||||
SPA_PARAM_PROFILE_available, SPA_POD_OPT_Id(&pi->available),
|
||||
SPA_PARAM_PROFILE_classes, SPA_POD_OPT_Pod(&classes)) < 0) {
|
||||
SPA_PARAM_PROFILE_classes, SPA_POD_OPT_PodStruct(&classes)) < 0) {
|
||||
continue;
|
||||
}
|
||||
if (pi->description == NULL)
|
||||
|
|
@ -246,7 +246,7 @@ static void collect_device_info(struct pw_manager_object *device, struct pw_mana
|
|||
SPA_TYPE_OBJECT_ParamRoute, NULL,
|
||||
SPA_PARAM_ROUTE_index, SPA_POD_Int(&index),
|
||||
SPA_PARAM_ROUTE_device, SPA_POD_Int(&dev),
|
||||
SPA_PARAM_ROUTE_props, SPA_POD_OPT_Pod(&props)) < 0)
|
||||
SPA_PARAM_ROUTE_props, SPA_POD_OPT_PodObject(&props)) < 0)
|
||||
continue;
|
||||
if (dev != dev_info->device)
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,9 @@ int volume_parse_param(const struct spa_pod *param, struct volume_info *info, bo
|
|||
struct spa_pod_object *obj = (struct spa_pod_object *) param;
|
||||
struct spa_pod_prop *prop;
|
||||
|
||||
if (!spa_pod_is_object_type(param, SPA_TYPE_OBJECT_Props))
|
||||
return -EINVAL;
|
||||
|
||||
SPA_POD_OBJECT_FOREACH(obj, prop) {
|
||||
switch (prop->key) {
|
||||
case SPA_PROP_volume:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue