spa: add some macros to events and object types

This commit is contained in:
Wim Taymans 2018-10-08 11:43:18 +02:00
parent a95cd608e7
commit 595daf86c6
2 changed files with 10 additions and 0 deletions

View file

@ -38,6 +38,10 @@ enum spa_node_event {
#define SPA_NODE_EVENT_ID(ev) SPA_EVENT_ID(ev, SPA_TYPE_EVENT_Node) #define SPA_NODE_EVENT_ID(ev) SPA_EVENT_ID(ev, SPA_TYPE_EVENT_Node)
#define SPA_NODE_EVENT_INIT(id) (struct spa_event) \
{ { sizeof(struct spa_event_body), SPA_TYPE_Object }, \
{ { SPA_TYPE_EVENT_Node, id } } } \
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */
#endif #endif

View file

@ -157,6 +157,12 @@ struct spa_pod_struct {
/* one or more spa_pod follow */ /* one or more spa_pod follow */
}; };
#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_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 */