pod: remove SPA_POD_IS_OBJECT_TYPE

We have a safer version of that in iter.h
Use macros to get id and type of an object
Use safer checks in plugins.
This commit is contained in:
Wim Taymans 2019-10-29 10:08:46 +01:00
parent 241a6165d2
commit f7d32e78f2
5 changed files with 5 additions and 10 deletions

View file

@ -379,14 +379,12 @@ static inline int spa_pod_is_object(const struct spa_pod *pod)
static inline bool spa_pod_is_object_type(const struct spa_pod *pod, uint32_t type) static inline bool spa_pod_is_object_type(const struct spa_pod *pod, uint32_t type)
{ {
return (pod && spa_pod_is_object(pod) && return (pod && spa_pod_is_object(pod) && SPA_POD_OBJECT_TYPE(pod) == type);
((const struct spa_pod_object *) pod)->body.type == type);
} }
static inline bool spa_pod_is_object_id(const struct spa_pod *pod, uint32_t id) static inline bool spa_pod_is_object_id(const struct spa_pod *pod, uint32_t id)
{ {
return (pod && spa_pod_is_object(pod) && return (pod && spa_pod_is_object(pod) && SPA_POD_OBJECT_ID(pod) == id);
((const struct spa_pod_object *) pod)->body.id == id);
} }
static inline int spa_pod_is_sequence(const struct spa_pod *pod) static inline int spa_pod_is_sequence(const struct spa_pod *pod)

View file

@ -160,9 +160,6 @@ struct spa_pod_struct {
#define SPA_POD_OBJECT_TYPE(obj) (((struct spa_pod_object*)(obj))->body.type) #define SPA_POD_OBJECT_TYPE(obj) (((struct spa_pod_object*)(obj))->body.type)
#define SPA_POD_OBJECT_ID(obj) (((struct spa_pod_object*)(obj))->body.id) #define SPA_POD_OBJECT_ID(obj) (((struct spa_pod_object*)(obj))->body.id)
#define SPA_POD_IS_OBJECT_TYPE(obj,tp) (SPA_POD_TYPE(obj) == SPA_TYPE_Object && \
SPA_POD_OBJECT_TYPE(obj) == (tp))
struct spa_pod_object_body { struct spa_pod_object_body {
uint32_t type; /**< one of enum spa_type */ uint32_t type; /**< one of enum spa_type */
uint32_t id; /**< id of the object, depends on the object type */ uint32_t id; /**< id of the object, depends on the object type */

View file

@ -710,7 +710,7 @@ static int impl_node_set_param(void *object, uint32_t id, uint32_t flags,
return -EINVAL; return -EINVAL;
if (format) { if (format) {
if (!SPA_POD_IS_OBJECT_TYPE(format, SPA_TYPE_OBJECT_Format)) if (!spa_pod_is_object_type(format, SPA_TYPE_OBJECT_Format))
return -EINVAL; return -EINVAL;
if ((res = spa_format_parse(format, &info.media_type, &info.media_subtype)) < 0) if ((res = spa_format_parse(format, &info.media_type, &info.media_subtype)) < 0)

View file

@ -268,7 +268,7 @@ static int impl_node_set_param(void *object, uint32_t id, uint32_t flags,
SPA_PARAM_PORT_CONFIG_format, SPA_POD_Pod(&format)) < 0) SPA_PARAM_PORT_CONFIG_format, SPA_POD_Pod(&format)) < 0)
return -EINVAL; return -EINVAL;
if (!SPA_POD_IS_OBJECT_TYPE(format, SPA_TYPE_OBJECT_Format)) if (!spa_pod_is_object_type(format, SPA_TYPE_OBJECT_Format))
return -EINVAL; return -EINVAL;
if (mode != SPA_PARAM_PORT_CONFIG_MODE_dsp) if (mode != SPA_PARAM_PORT_CONFIG_MODE_dsp)

View file

@ -258,7 +258,7 @@ static int impl_node_set_param(void *object, uint32_t id, uint32_t flags,
SPA_PARAM_PORT_CONFIG_format, SPA_POD_Pod(&format)) < 0) SPA_PARAM_PORT_CONFIG_format, SPA_POD_Pod(&format)) < 0)
return -EINVAL; return -EINVAL;
if (!SPA_POD_IS_OBJECT_TYPE(format, SPA_TYPE_OBJECT_Format)) if (!spa_pod_is_object_type(format, SPA_TYPE_OBJECT_Format))
return -EINVAL; return -EINVAL;
if (mode != SPA_PARAM_PORT_CONFIG_MODE_dsp) if (mode != SPA_PARAM_PORT_CONFIG_MODE_dsp)