mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-10 13:30:05 -05:00
More type cleanups
SPA_ID_* -> SPA_TYPE_*. We use 'type' for all registered types. ID refers to either a registered type or an enum. Improve introspection of object ids. Make 0 an invalid enum and use it to look up the object id type. Move some type-info files together. Swap type and id of the object, we first specify the type and then the id because the meaning of the id depends on the object type.
This commit is contained in:
parent
281b65934e
commit
90c1a95eef
117 changed files with 1198 additions and 1272 deletions
|
|
@ -98,7 +98,7 @@ spa_pod_builder_push(struct spa_pod_builder *builder,
|
|||
frame->pod = *pod;
|
||||
frame->ref = ref;
|
||||
builder->state.in_array = builder->state.first =
|
||||
(pod->type == SPA_ID_Array || pod->type == SPA_ID_Prop);
|
||||
(pod->type == SPA_TYPE_Array || pod->type == SPA_TYPE_Prop);
|
||||
return ref;
|
||||
}
|
||||
|
||||
|
|
@ -153,7 +153,7 @@ static inline void *spa_pod_builder_pop(struct spa_pod_builder *builder)
|
|||
|
||||
top = builder->state.depth > 0 ? &builder->frame[builder->state.depth-1] : NULL;
|
||||
builder->state.in_array = (top &&
|
||||
(top->pod.type == SPA_ID_Array || top->pod.type == SPA_ID_Prop));
|
||||
(top->pod.type == SPA_TYPE_Array || top->pod.type == SPA_TYPE_Prop));
|
||||
spa_pod_builder_pad(builder, builder->state.offset);
|
||||
|
||||
return pod;
|
||||
|
|
@ -179,7 +179,7 @@ spa_pod_builder_primitive(struct spa_pod_builder *builder, const struct spa_pod
|
|||
return ref;
|
||||
}
|
||||
|
||||
#define SPA_POD_NONE_INIT() (struct spa_pod) { 0, SPA_ID_None }
|
||||
#define SPA_POD_NONE_INIT() (struct spa_pod) { 0, SPA_TYPE_None }
|
||||
|
||||
static inline uint32_t spa_pod_builder_none(struct spa_pod_builder *builder)
|
||||
{
|
||||
|
|
@ -187,7 +187,7 @@ static inline uint32_t spa_pod_builder_none(struct spa_pod_builder *builder)
|
|||
return spa_pod_builder_primitive(builder, &p);
|
||||
}
|
||||
|
||||
#define SPA_POD_BOOL_INIT(val) (struct spa_pod_bool){ { sizeof(uint32_t), SPA_ID_Bool }, val ? 1 : 0, 0 }
|
||||
#define SPA_POD_BOOL_INIT(val) (struct spa_pod_bool){ { sizeof(uint32_t), SPA_TYPE_Bool }, val ? 1 : 0, 0 }
|
||||
|
||||
static inline uint32_t spa_pod_builder_bool(struct spa_pod_builder *builder, bool val)
|
||||
{
|
||||
|
|
@ -195,7 +195,7 @@ static inline uint32_t spa_pod_builder_bool(struct spa_pod_builder *builder, boo
|
|||
return spa_pod_builder_primitive(builder, &p.pod);
|
||||
}
|
||||
|
||||
#define SPA_POD_ENUM_INIT(val) (struct spa_pod_enum){ { sizeof(uint32_t), SPA_ID_Enum }, val, 0 }
|
||||
#define SPA_POD_ENUM_INIT(val) (struct spa_pod_enum){ { sizeof(uint32_t), SPA_TYPE_Enum }, val, 0 }
|
||||
|
||||
static inline uint32_t spa_pod_builder_enum(struct spa_pod_builder *builder, uint32_t val)
|
||||
{
|
||||
|
|
@ -203,7 +203,7 @@ static inline uint32_t spa_pod_builder_enum(struct spa_pod_builder *builder, uin
|
|||
return spa_pod_builder_primitive(builder, &p.pod);
|
||||
}
|
||||
|
||||
#define SPA_POD_INT_INIT(val) (struct spa_pod_int){ { sizeof(uint32_t), SPA_ID_Int }, val, 0 }
|
||||
#define SPA_POD_INT_INIT(val) (struct spa_pod_int){ { sizeof(uint32_t), SPA_TYPE_Int }, val, 0 }
|
||||
|
||||
static inline uint32_t spa_pod_builder_int(struct spa_pod_builder *builder, int32_t val)
|
||||
{
|
||||
|
|
@ -211,7 +211,7 @@ static inline uint32_t spa_pod_builder_int(struct spa_pod_builder *builder, int3
|
|||
return spa_pod_builder_primitive(builder, &p.pod);
|
||||
}
|
||||
|
||||
#define SPA_POD_LONG_INIT(val) (struct spa_pod_long){ { sizeof(uint64_t), SPA_ID_Long }, val }
|
||||
#define SPA_POD_LONG_INIT(val) (struct spa_pod_long){ { sizeof(uint64_t), SPA_TYPE_Long }, val }
|
||||
|
||||
static inline uint32_t spa_pod_builder_long(struct spa_pod_builder *builder, int64_t val)
|
||||
{
|
||||
|
|
@ -219,7 +219,7 @@ static inline uint32_t spa_pod_builder_long(struct spa_pod_builder *builder, int
|
|||
return spa_pod_builder_primitive(builder, &p.pod);
|
||||
}
|
||||
|
||||
#define SPA_POD_FLOAT_INIT(val) (struct spa_pod_float){ { sizeof(float), SPA_ID_Float }, val }
|
||||
#define SPA_POD_FLOAT_INIT(val) (struct spa_pod_float){ { sizeof(float), SPA_TYPE_Float }, val }
|
||||
|
||||
static inline uint32_t spa_pod_builder_float(struct spa_pod_builder *builder, float val)
|
||||
{
|
||||
|
|
@ -227,7 +227,7 @@ static inline uint32_t spa_pod_builder_float(struct spa_pod_builder *builder, fl
|
|||
return spa_pod_builder_primitive(builder, &p.pod);
|
||||
}
|
||||
|
||||
#define SPA_POD_DOUBLE_INIT(val) (struct spa_pod_double){ { sizeof(double), SPA_ID_Double }, val }
|
||||
#define SPA_POD_DOUBLE_INIT(val) (struct spa_pod_double){ { sizeof(double), SPA_TYPE_Double }, val }
|
||||
|
||||
static inline uint32_t spa_pod_builder_double(struct spa_pod_builder *builder, double val)
|
||||
{
|
||||
|
|
@ -235,7 +235,7 @@ static inline uint32_t spa_pod_builder_double(struct spa_pod_builder *builder, d
|
|||
return spa_pod_builder_primitive(builder, &p.pod);
|
||||
}
|
||||
|
||||
#define SPA_POD_STRING_INIT(len) (struct spa_pod_string){ { len, SPA_ID_String } }
|
||||
#define SPA_POD_STRING_INIT(len) (struct spa_pod_string){ { len, SPA_TYPE_String } }
|
||||
|
||||
static inline uint32_t
|
||||
spa_pod_builder_write_string(struct spa_pod_builder *builder, const char *str, uint32_t len)
|
||||
|
|
@ -265,7 +265,7 @@ static inline uint32_t spa_pod_builder_string(struct spa_pod_builder *builder, c
|
|||
return spa_pod_builder_string_len(builder, str ? str : "", len);
|
||||
}
|
||||
|
||||
#define SPA_POD_BYTES_INIT(len) (struct spa_pod_bytes){ { len, SPA_ID_Bytes } }
|
||||
#define SPA_POD_BYTES_INIT(len) (struct spa_pod_bytes){ { len, SPA_TYPE_Bytes } }
|
||||
|
||||
static inline uint32_t
|
||||
spa_pod_builder_bytes(struct spa_pod_builder *builder, const void *bytes, uint32_t len)
|
||||
|
|
@ -277,7 +277,7 @@ spa_pod_builder_bytes(struct spa_pod_builder *builder, const void *bytes, uint32
|
|||
return ref;
|
||||
}
|
||||
|
||||
#define SPA_POD_POINTER_INIT(type,value) (struct spa_pod_pointer){ { sizeof(struct spa_pod_pointer_body), SPA_ID_Pointer }, { type, value } }
|
||||
#define SPA_POD_POINTER_INIT(type,value) (struct spa_pod_pointer){ { sizeof(struct spa_pod_pointer_body), SPA_TYPE_Pointer }, { type, value } }
|
||||
|
||||
static inline uint32_t
|
||||
spa_pod_builder_pointer(struct spa_pod_builder *builder, uint32_t type, void *val)
|
||||
|
|
@ -286,7 +286,7 @@ spa_pod_builder_pointer(struct spa_pod_builder *builder, uint32_t type, void *va
|
|||
return spa_pod_builder_primitive(builder, &p.pod);
|
||||
}
|
||||
|
||||
#define SPA_POD_FD_INIT(fd) (struct spa_pod_fd){ { sizeof(int), SPA_ID_Fd }, fd }
|
||||
#define SPA_POD_FD_INIT(fd) (struct spa_pod_fd){ { sizeof(int), SPA_TYPE_Fd }, fd }
|
||||
|
||||
static inline uint32_t spa_pod_builder_fd(struct spa_pod_builder *builder, int fd)
|
||||
{
|
||||
|
|
@ -294,7 +294,7 @@ static inline uint32_t spa_pod_builder_fd(struct spa_pod_builder *builder, int f
|
|||
return spa_pod_builder_primitive(builder, &p.pod);
|
||||
}
|
||||
|
||||
#define SPA_POD_RECTANGLE_INIT(width,height) (struct spa_pod_rectangle){ { sizeof(struct spa_rectangle), SPA_ID_Rectangle }, { width, height } }
|
||||
#define SPA_POD_RECTANGLE_INIT(width,height) (struct spa_pod_rectangle){ { sizeof(struct spa_rectangle), SPA_TYPE_Rectangle }, { width, height } }
|
||||
|
||||
static inline uint32_t
|
||||
spa_pod_builder_rectangle(struct spa_pod_builder *builder, uint32_t width, uint32_t height)
|
||||
|
|
@ -303,7 +303,7 @@ spa_pod_builder_rectangle(struct spa_pod_builder *builder, uint32_t width, uint3
|
|||
return spa_pod_builder_primitive(builder, &p.pod);
|
||||
}
|
||||
|
||||
#define SPA_POD_FRACTION_INIT(num,denom) (struct spa_pod_fraction){ { sizeof(struct spa_fraction), SPA_ID_Fraction }, { num, denom } }
|
||||
#define SPA_POD_FRACTION_INIT(num,denom) (struct spa_pod_fraction){ { sizeof(struct spa_fraction), SPA_TYPE_Fraction }, { num, denom } }
|
||||
|
||||
static inline uint32_t
|
||||
spa_pod_builder_fraction(struct spa_pod_builder *builder, uint32_t num, uint32_t denom)
|
||||
|
|
@ -316,7 +316,7 @@ static inline uint32_t
|
|||
spa_pod_builder_push_array(struct spa_pod_builder *builder)
|
||||
{
|
||||
const struct spa_pod_array p =
|
||||
{ {sizeof(struct spa_pod_array_body) - sizeof(struct spa_pod), SPA_ID_Array},
|
||||
{ {sizeof(struct spa_pod_array_body) - sizeof(struct spa_pod), SPA_TYPE_Array},
|
||||
{{0, 0}} };
|
||||
return spa_pod_builder_push(builder, &p.pod,
|
||||
spa_pod_builder_raw(builder, &p,
|
||||
|
|
@ -328,7 +328,7 @@ spa_pod_builder_array(struct spa_pod_builder *builder,
|
|||
uint32_t child_size, uint32_t child_type, uint32_t n_elems, const void *elems)
|
||||
{
|
||||
const struct spa_pod_array p = {
|
||||
{(uint32_t)(sizeof(struct spa_pod_array_body) + n_elems * child_size), SPA_ID_Array},
|
||||
{(uint32_t)(sizeof(struct spa_pod_array_body) + n_elems * child_size), SPA_TYPE_Array},
|
||||
{{child_size, child_type}}
|
||||
};
|
||||
uint32_t ref = spa_pod_builder_raw(builder, &p, sizeof(p));
|
||||
|
|
@ -337,7 +337,7 @@ spa_pod_builder_array(struct spa_pod_builder *builder,
|
|||
return ref;
|
||||
}
|
||||
|
||||
#define SPA_POD_STRUCT_INIT(size) (struct spa_pod_struct){ { size, SPA_ID_Struct } }
|
||||
#define SPA_POD_STRUCT_INIT(size) (struct spa_pod_struct){ { size, SPA_TYPE_Struct } }
|
||||
|
||||
static inline uint32_t
|
||||
spa_pod_builder_push_struct(struct spa_pod_builder *builder)
|
||||
|
|
@ -347,19 +347,19 @@ spa_pod_builder_push_struct(struct spa_pod_builder *builder)
|
|||
spa_pod_builder_raw(builder, &p, sizeof(p)));
|
||||
}
|
||||
|
||||
#define SPA_POD_OBJECT_INIT(size,id,type,...) (struct spa_pod_object){ { size, SPA_ID_Object }, { id, type }, ##__VA_ARGS__ }
|
||||
#define SPA_POD_OBJECT_INIT(size,type,id,...) (struct spa_pod_object){ { size, SPA_TYPE_Object }, { type, id }, ##__VA_ARGS__ }
|
||||
|
||||
static inline uint32_t
|
||||
spa_pod_builder_push_object(struct spa_pod_builder *builder, uint32_t id, uint32_t type)
|
||||
spa_pod_builder_push_object(struct spa_pod_builder *builder, uint32_t type, uint32_t id)
|
||||
{
|
||||
const struct spa_pod_object p =
|
||||
SPA_POD_OBJECT_INIT(sizeof(struct spa_pod_object_body), id, type);
|
||||
SPA_POD_OBJECT_INIT(sizeof(struct spa_pod_object_body), type, id);
|
||||
return spa_pod_builder_push(builder, &p.pod,
|
||||
spa_pod_builder_raw(builder, &p, sizeof(p)));
|
||||
}
|
||||
|
||||
#define SPA_POD_PROP_INIT(size,key,flags,val_size,val_type) \
|
||||
(struct spa_pod_prop){ { size, SPA_ID_Prop}, {key, flags, { val_size, val_type } } }
|
||||
(struct spa_pod_prop){ { size, SPA_TYPE_Prop}, {key, flags, { val_size, val_type } } }
|
||||
|
||||
static inline uint32_t
|
||||
spa_pod_builder_push_prop(struct spa_pod_builder *builder, uint32_t key, uint32_t flags)
|
||||
|
|
@ -507,9 +507,9 @@ spa_pod_builder_addv(struct spa_pod_builder *builder,
|
|||
switch (t) {
|
||||
case '<':
|
||||
{
|
||||
uint32_t id = va_arg(args, uint32_t);
|
||||
uint32_t type = va_arg(args, uint32_t);
|
||||
spa_pod_builder_push_object(builder, id, type);
|
||||
uint32_t id = va_arg(args, uint32_t);
|
||||
spa_pod_builder_push_object(builder, type, id);
|
||||
break;
|
||||
}
|
||||
case '[':
|
||||
|
|
@ -556,7 +556,7 @@ spa_pod_builder_addv(struct spa_pod_builder *builder,
|
|||
case ']': case ')': case '>':
|
||||
spa_pod_builder_pop(builder);
|
||||
if (builder->state.depth > 0 &&
|
||||
builder->frame[builder->state.depth-1].pod.type == SPA_ID_Prop)
|
||||
builder->frame[builder->state.depth-1].pod.type == SPA_TYPE_Prop)
|
||||
spa_pod_builder_pop(builder);
|
||||
break;
|
||||
case ' ': case '\n': case '\t': case '\r':
|
||||
|
|
@ -586,8 +586,8 @@ static inline void *spa_pod_builder_add(struct spa_pod_builder *builder, const c
|
|||
return res;
|
||||
}
|
||||
|
||||
#define SPA_POD_OBJECT(id,type,...) \
|
||||
"<", id, type, ##__VA_ARGS__, ">"
|
||||
#define SPA_POD_OBJECT(type,id,...) \
|
||||
"<", type, id, ##__VA_ARGS__, ">"
|
||||
|
||||
#define SPA_POD_STRUCT(...) \
|
||||
"[", ##__VA_ARGS__, "]"
|
||||
|
|
@ -599,8 +599,8 @@ static inline void *spa_pod_builder_add(struct spa_pod_builder *builder, const c
|
|||
#define SPA_POD_PROP_STEP(min,max,step) 3,(min),(max),(step)
|
||||
#define SPA_POD_PROP_ENUM(n_vals,...) (n_vals),__VA_ARGS__
|
||||
|
||||
#define spa_pod_builder_object(b,id,type,...) \
|
||||
spa_pod_builder_add(b, SPA_POD_OBJECT(id,type,##__VA_ARGS__), NULL)
|
||||
#define spa_pod_builder_object(b,type,id,...) \
|
||||
spa_pod_builder_add(b, SPA_POD_OBJECT(type,id,##__VA_ARGS__), NULL)
|
||||
|
||||
#define spa_pod_builder_struct(b,...) \
|
||||
spa_pod_builder_add(b, SPA_POD_STRUCT(__VA_ARGS__), NULL)
|
||||
|
|
|
|||
|
|
@ -41,12 +41,12 @@ struct spa_command {
|
|||
(cmd)->body.body.id : SPA_ID_INVALID)
|
||||
|
||||
#define SPA_COMMAND_INIT(type,id) (struct spa_command) \
|
||||
{ { sizeof(struct spa_command_body), SPA_ID_Object }, \
|
||||
{ { id, type } } } \
|
||||
{ { sizeof(struct spa_command_body), SPA_TYPE_Object }, \
|
||||
{ { type, id } } } \
|
||||
|
||||
#define SPA_COMMAND_INIT_FULL(t,size,type,id,...) (t) \
|
||||
{ { size, SPA_ID_OBJECT }, \
|
||||
{ { id, type }, ##__VA_ARGS__ } } \
|
||||
{ { size, SPA_TYPE_OBJECT }, \
|
||||
{ { type, id }, ##__VA_ARGS__ } } \
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
|
|
|||
|
|
@ -30,22 +30,22 @@
|
|||
static inline int spa_pod_compare_value(uint32_t type, const void *r1, const void *r2)
|
||||
{
|
||||
switch (type) {
|
||||
case SPA_ID_INVALID:
|
||||
case SPA_TYPE_None:
|
||||
return 0;
|
||||
case SPA_ID_Bool:
|
||||
case SPA_ID_Enum:
|
||||
case SPA_TYPE_Bool:
|
||||
case SPA_TYPE_Enum:
|
||||
return *(int32_t *) r1 == *(uint32_t *) r2 ? 0 : 1;
|
||||
case SPA_ID_Int:
|
||||
case SPA_TYPE_Int:
|
||||
return *(int32_t *) r1 - *(int32_t *) r2;
|
||||
case SPA_ID_Long:
|
||||
case SPA_TYPE_Long:
|
||||
return *(int64_t *) r1 - *(int64_t *) r2;
|
||||
case SPA_ID_Float:
|
||||
case SPA_TYPE_Float:
|
||||
return *(float *) r1 - *(float *) r2;
|
||||
case SPA_ID_Double:
|
||||
case SPA_TYPE_Double:
|
||||
return *(double *) r1 - *(double *) r2;
|
||||
case SPA_ID_String:
|
||||
case SPA_TYPE_String:
|
||||
return strcmp(r1, r2);
|
||||
case SPA_ID_Rectangle:
|
||||
case SPA_TYPE_Rectangle:
|
||||
{
|
||||
const struct spa_rectangle *rec1 = (struct spa_rectangle *) r1,
|
||||
*rec2 = (struct spa_rectangle *) r2;
|
||||
|
|
@ -56,7 +56,7 @@ static inline int spa_pod_compare_value(uint32_t type, const void *r1, const voi
|
|||
else
|
||||
return 1;
|
||||
}
|
||||
case SPA_ID_Fraction:
|
||||
case SPA_TYPE_Fraction:
|
||||
{
|
||||
const struct spa_fraction *f1 = (struct spa_fraction *) r1,
|
||||
*f2 = (struct spa_fraction *) r2;
|
||||
|
|
@ -92,19 +92,19 @@ static inline int spa_pod_compare_part(const struct spa_pod *pod1, uint32_t pod1
|
|||
return -EINVAL;
|
||||
|
||||
switch (SPA_POD_TYPE(p1)) {
|
||||
case SPA_ID_Struct:
|
||||
case SPA_ID_Object:
|
||||
case SPA_TYPE_Struct:
|
||||
case SPA_TYPE_Object:
|
||||
if (SPA_POD_TYPE(p2) != SPA_POD_TYPE(p1))
|
||||
return -EINVAL;
|
||||
|
||||
if (SPA_POD_TYPE(p1) == SPA_ID_Struct)
|
||||
if (SPA_POD_TYPE(p1) == SPA_TYPE_Struct)
|
||||
recurse_offset = sizeof(struct spa_pod_struct);
|
||||
else
|
||||
recurse_offset = sizeof(struct spa_pod_object);
|
||||
|
||||
do_advance = true;
|
||||
break;
|
||||
case SPA_ID_Prop:
|
||||
case SPA_TYPE_Prop:
|
||||
{
|
||||
struct spa_pod_prop *pr1, *pr2;
|
||||
void *a1, *a2;
|
||||
|
|
|
|||
|
|
@ -40,12 +40,12 @@ struct spa_event {
|
|||
(ev)->body.body.id : SPA_ID_INVALID)
|
||||
|
||||
#define SPA_EVENT_INIT(type,id) (struct spa_event) \
|
||||
{ { sizeof(struct spa_event_body), SPA_ID_Object }, \
|
||||
{ { id, type } } } \
|
||||
{ { sizeof(struct spa_event_body), SPA_TYPE_Object }, \
|
||||
{ { type, id } } } \
|
||||
|
||||
#define SPA_EVENT_INIT_FULL(t,size,type,id,...) (t) \
|
||||
{ { size, SPA_ID_OBJECT }, \
|
||||
{ { id, type }, ##__VA_ARGS__ } } \
|
||||
{ { size, SPA_TYPE_OBJECT }, \
|
||||
{ { type, id }, ##__VA_ARGS__ } } \
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
|
|
|||
|
|
@ -249,19 +249,19 @@ static inline int spa_pod_filter_part(struct spa_pod_builder *b,
|
|||
uint32_t filter_offset = 0;
|
||||
|
||||
switch (SPA_POD_TYPE(pp)) {
|
||||
case SPA_ID_Struct:
|
||||
case SPA_ID_Object:
|
||||
case SPA_TYPE_Struct:
|
||||
case SPA_TYPE_Object:
|
||||
if (pf != NULL) {
|
||||
if (SPA_POD_TYPE(pf) != SPA_POD_TYPE(pp))
|
||||
return -EINVAL;
|
||||
|
||||
if (SPA_POD_TYPE(pp) == SPA_ID_Struct) {
|
||||
if (SPA_POD_TYPE(pp) == SPA_TYPE_Struct) {
|
||||
filter_offset = sizeof(struct spa_pod_struct);
|
||||
spa_pod_builder_push_struct(b);
|
||||
} else {
|
||||
struct spa_pod_object *p1 = (struct spa_pod_object *) pp;
|
||||
filter_offset = sizeof(struct spa_pod_object);
|
||||
spa_pod_builder_push_object(b, p1->body.id, p1->body.type);
|
||||
spa_pod_builder_push_object(b, p1->body.type, p1->body.id);
|
||||
}
|
||||
do_advance = true;
|
||||
}
|
||||
|
|
@ -269,7 +269,7 @@ static inline int spa_pod_filter_part(struct spa_pod_builder *b,
|
|||
do_copy = true;
|
||||
break;
|
||||
|
||||
case SPA_ID_Prop:
|
||||
case SPA_TYPE_Prop:
|
||||
{
|
||||
struct spa_pod_prop *p1, *p2;
|
||||
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ static inline struct spa_pod_prop *spa_pod_contents_find_prop(const struct spa_p
|
|||
{
|
||||
const struct spa_pod *res;
|
||||
SPA_POD_FOREACH(pod, size, res) {
|
||||
if (res->type == SPA_ID_Prop
|
||||
if (res->type == SPA_TYPE_Prop
|
||||
&& ((struct spa_pod_prop *) res)->body.key == key)
|
||||
return (struct spa_pod_prop *) res;
|
||||
}
|
||||
|
|
@ -112,9 +112,9 @@ static inline struct spa_pod_prop *spa_pod_find_prop(const struct spa_pod *pod,
|
|||
{
|
||||
uint32_t offset;
|
||||
|
||||
if (pod->type == SPA_ID_Object)
|
||||
if (pod->type == SPA_TYPE_Object)
|
||||
offset = sizeof(struct spa_pod_object);
|
||||
else if (pod->type == SPA_ID_Struct)
|
||||
else if (pod->type == SPA_TYPE_Struct)
|
||||
offset = sizeof(struct spa_pod_struct);
|
||||
else
|
||||
return NULL;
|
||||
|
|
@ -128,15 +128,15 @@ static inline int spa_pod_fixate(struct spa_pod *pod)
|
|||
struct spa_pod *res;
|
||||
uint32_t offset;
|
||||
|
||||
if (pod->type == SPA_ID_Object)
|
||||
if (pod->type == SPA_TYPE_Object)
|
||||
offset = sizeof(struct spa_pod_object);
|
||||
else if (pod->type == SPA_ID_Struct)
|
||||
else if (pod->type == SPA_TYPE_Struct)
|
||||
offset = sizeof(struct spa_pod_struct);
|
||||
else
|
||||
return -EINVAL;
|
||||
|
||||
SPA_POD_CONTENTS_FOREACH(pod, offset, res) {
|
||||
if (res->type == SPA_ID_Prop)
|
||||
if (res->type == SPA_TYPE_Prop)
|
||||
SPA_FLAG_UNSET (((struct spa_pod_prop *) res)->body.flags,
|
||||
SPA_POD_PROP_FLAG_UNSET);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,41 +53,41 @@ static inline bool spa_pod_parser_can_collect(struct spa_pod *pod, char type)
|
|||
return true;
|
||||
|
||||
switch (SPA_POD_TYPE(pod)) {
|
||||
case SPA_ID_None:
|
||||
case SPA_TYPE_None:
|
||||
return type == 'T' || type == 'O' || type == 'V' || type == 's';
|
||||
case SPA_ID_Bool:
|
||||
case SPA_TYPE_Bool:
|
||||
return type == 'b';
|
||||
case SPA_ID_Enum:
|
||||
case SPA_TYPE_Enum:
|
||||
return type == 'I';
|
||||
case SPA_ID_Int:
|
||||
case SPA_TYPE_Int:
|
||||
return type == 'i';
|
||||
case SPA_ID_Long:
|
||||
case SPA_TYPE_Long:
|
||||
return type == 'l';
|
||||
case SPA_ID_Float:
|
||||
case SPA_TYPE_Float:
|
||||
return type == 'f';
|
||||
case SPA_ID_Double:
|
||||
case SPA_TYPE_Double:
|
||||
return type == 'd';
|
||||
case SPA_ID_String:
|
||||
case SPA_TYPE_String:
|
||||
return type == 's' || type == 'S';
|
||||
case SPA_ID_Bytes:
|
||||
case SPA_TYPE_Bytes:
|
||||
return type == 'z';
|
||||
case SPA_ID_Rectangle:
|
||||
case SPA_TYPE_Rectangle:
|
||||
return type == 'R';
|
||||
case SPA_ID_Fraction:
|
||||
case SPA_TYPE_Fraction:
|
||||
return type == 'F';
|
||||
case SPA_ID_Bitmap:
|
||||
case SPA_TYPE_Bitmap:
|
||||
return type == 'B';
|
||||
case SPA_ID_Array:
|
||||
case SPA_TYPE_Array:
|
||||
return type == 'a';
|
||||
case SPA_ID_Struct:
|
||||
case SPA_TYPE_Struct:
|
||||
return type == 'T';
|
||||
case SPA_ID_Object:
|
||||
case SPA_TYPE_Object:
|
||||
return type == 'O';
|
||||
case SPA_ID_Pointer:
|
||||
case SPA_TYPE_Pointer:
|
||||
return type == 'p';
|
||||
case SPA_ID_Fd:
|
||||
case SPA_TYPE_Fd:
|
||||
return type == 'h';
|
||||
case SPA_ID_Prop:
|
||||
case SPA_TYPE_Prop:
|
||||
return type == 'V';
|
||||
default:
|
||||
return false;
|
||||
|
|
@ -115,7 +115,7 @@ do { \
|
|||
break; \
|
||||
case 's': \
|
||||
*va_arg(args, char**) = \
|
||||
(pod == NULL || (SPA_POD_TYPE(pod) == SPA_ID_None) \
|
||||
(pod == NULL || (SPA_POD_TYPE(pod) == SPA_TYPE_None) \
|
||||
? NULL \
|
||||
: (char *)SPA_POD_CONTENTS(struct spa_pod_string, pod)); \
|
||||
break; \
|
||||
|
|
@ -157,7 +157,7 @@ do { \
|
|||
case 'O': \
|
||||
case 'T': \
|
||||
*va_arg(args, struct spa_pod**) = \
|
||||
(pod == NULL || (SPA_POD_TYPE(pod) == SPA_ID_None) \
|
||||
(pod == NULL || (SPA_POD_TYPE(pod) == SPA_TYPE_None) \
|
||||
? NULL : pod); \
|
||||
break; \
|
||||
default: \
|
||||
|
|
@ -209,7 +209,7 @@ static inline int spa_pod_parser_getv(struct spa_pod_parser *parser,
|
|||
while (format) {
|
||||
switch (*format) {
|
||||
case '<':
|
||||
if (pod == NULL || SPA_POD_TYPE(pod) != SPA_ID_Object)
|
||||
if (pod == NULL || SPA_POD_TYPE(pod) != SPA_TYPE_Object)
|
||||
return -EINVAL;
|
||||
if (++parser->depth >= SPA_POD_MAX_DEPTH)
|
||||
return -EINVAL;
|
||||
|
|
@ -218,7 +218,7 @@ static inline int spa_pod_parser_getv(struct spa_pod_parser *parser,
|
|||
spa_pod_iter_init(it, pod, SPA_POD_SIZE(pod), sizeof(struct spa_pod_object));
|
||||
goto read_pod;
|
||||
case '[':
|
||||
if (pod == NULL || SPA_POD_TYPE(pod) != SPA_ID_Struct)
|
||||
if (pod == NULL || SPA_POD_TYPE(pod) != SPA_TYPE_Struct)
|
||||
return -EINVAL;
|
||||
if (++parser->depth >= SPA_POD_MAX_DEPTH)
|
||||
return -EINVAL;
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ extern "C" {
|
|||
|
||||
struct spa_pod {
|
||||
uint32_t size;
|
||||
uint32_t type; /* one of spa_pod_type */
|
||||
uint32_t type; /* a basic id of enum spa_type */
|
||||
};
|
||||
|
||||
#define SPA_POD_VALUE(type,pod) (((type*)pod)->value)
|
||||
|
|
@ -125,8 +125,8 @@ struct spa_pod_struct {
|
|||
};
|
||||
|
||||
struct spa_pod_object_body {
|
||||
uint32_t id;
|
||||
uint32_t type;
|
||||
uint32_t type; /**< one of enum spa_type */
|
||||
uint32_t id; /**< id of the object, depends on the object type */
|
||||
/* contents follow, series of spa_pod */
|
||||
};
|
||||
|
||||
|
|
@ -137,18 +137,18 @@ struct spa_pod_object {
|
|||
|
||||
static inline bool spa_pod_is_object_type(const struct spa_pod *pod, uint32_t type)
|
||||
{
|
||||
return (pod && pod->type == SPA_ID_Object
|
||||
return (pod && pod->type == SPA_TYPE_Object
|
||||
&& ((struct spa_pod_object *) pod)->body.type == type);
|
||||
}
|
||||
|
||||
static inline bool spa_pod_is_object_id(const struct spa_pod *pod, uint32_t id)
|
||||
{
|
||||
return (pod && pod->type == SPA_ID_Object
|
||||
return (pod && pod->type == SPA_TYPE_Object
|
||||
&& ((struct spa_pod_object *) pod)->body.id == id);
|
||||
}
|
||||
|
||||
struct spa_pod_pointer_body {
|
||||
uint32_t type;
|
||||
uint32_t type; /**< pointer id, one of enum spa_type */
|
||||
void *value;
|
||||
};
|
||||
|
||||
|
|
@ -165,7 +165,8 @@ struct spa_pod_fd {
|
|||
#define SPA_POD_PROP_N_VALUES(prop) (((prop)->pod.size - sizeof(struct spa_pod_prop_body)) / (prop)->body.value.size)
|
||||
|
||||
struct spa_pod_prop_body {
|
||||
uint32_t key;
|
||||
uint32_t key; /**< key of property, list of valid keys depends on the
|
||||
* object type */
|
||||
#define SPA_POD_PROP_RANGE_NONE 0 /**< no range */
|
||||
#define SPA_POD_PROP_RANGE_MIN_MAX 1 /**< property has range */
|
||||
#define SPA_POD_PROP_RANGE_STEP 2 /**< property has range with step */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue