mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-10 13:30:05 -05:00
types: work on types
Move static pod types to type system work on type info for types Move the event and command ids to an enum to make it easier to extend later.
This commit is contained in:
parent
fca3e1d85d
commit
805e3bb6c1
82 changed files with 812 additions and 924 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_POD_TYPE_ARRAY || pod->type == SPA_POD_TYPE_PROP);
|
||||
(pod->type == SPA_ID_Array || pod->type == SPA_ID_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_POD_TYPE_ARRAY || top->pod.type == SPA_POD_TYPE_PROP));
|
||||
(top->pod.type == SPA_ID_Array || top->pod.type == SPA_ID_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_POD_TYPE_NONE }
|
||||
#define SPA_POD_NONE_INIT() (struct spa_pod) { 0, SPA_ID_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_POD_TYPE_BOOL }, val ? 1 : 0, 0 }
|
||||
#define SPA_POD_BOOL_INIT(val) (struct spa_pod_bool){ { sizeof(uint32_t), SPA_ID_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_ID_INIT(val) (struct spa_pod_id){ { sizeof(uint32_t), SPA_POD_TYPE_ID }, val, 0 }
|
||||
#define SPA_POD_ID_INIT(val) (struct spa_pod_id){ { sizeof(uint32_t), SPA_ID_Enum }, val, 0 }
|
||||
|
||||
static inline uint32_t spa_pod_builder_id(struct spa_pod_builder *builder, uint32_t val)
|
||||
{
|
||||
|
|
@ -203,7 +203,7 @@ static inline uint32_t spa_pod_builder_id(struct spa_pod_builder *builder, uint3
|
|||
return spa_pod_builder_primitive(builder, &p.pod);
|
||||
}
|
||||
|
||||
#define SPA_POD_INT_INIT(val) (struct spa_pod_int){ { sizeof(uint32_t), SPA_POD_TYPE_INT }, val, 0 }
|
||||
#define SPA_POD_INT_INIT(val) (struct spa_pod_int){ { sizeof(uint32_t), SPA_ID_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_POD_TYPE_LONG }, val }
|
||||
#define SPA_POD_LONG_INIT(val) (struct spa_pod_long){ { sizeof(uint64_t), SPA_ID_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_POD_TYPE_FLOAT }, val }
|
||||
#define SPA_POD_FLOAT_INIT(val) (struct spa_pod_float){ { sizeof(float), SPA_ID_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_POD_TYPE_DOUBLE }, val }
|
||||
#define SPA_POD_DOUBLE_INIT(val) (struct spa_pod_double){ { sizeof(double), SPA_ID_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_POD_TYPE_STRING } }
|
||||
#define SPA_POD_STRING_INIT(len) (struct spa_pod_string){ { len, SPA_ID_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_POD_TYPE_BYTES } }
|
||||
#define SPA_POD_BYTES_INIT(len) (struct spa_pod_bytes){ { len, SPA_ID_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_POD_TYPE_POINTER }, { type, value } }
|
||||
#define SPA_POD_POINTER_INIT(type,value) (struct spa_pod_pointer){ { sizeof(struct spa_pod_pointer_body), SPA_ID_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_POD_TYPE_FD }, fd }
|
||||
#define SPA_POD_FD_INIT(fd) (struct spa_pod_fd){ { sizeof(int), SPA_ID_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_POD_TYPE_RECTANGLE }, { width, height } }
|
||||
#define SPA_POD_RECTANGLE_INIT(width,height) (struct spa_pod_rectangle){ { sizeof(struct spa_rectangle), SPA_ID_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_POD_TYPE_FRACTION }, { num, denom } }
|
||||
#define SPA_POD_FRACTION_INIT(num,denom) (struct spa_pod_fraction){ { sizeof(struct spa_fraction), SPA_ID_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_POD_TYPE_ARRAY},
|
||||
{ {sizeof(struct spa_pod_array_body) - sizeof(struct spa_pod), SPA_ID_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_POD_TYPE_ARRAY},
|
||||
{(uint32_t)(sizeof(struct spa_pod_array_body) + n_elems * child_size), SPA_ID_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_POD_TYPE_STRUCT } }
|
||||
#define SPA_POD_STRUCT_INIT(size) (struct spa_pod_struct){ { size, SPA_ID_Struct } }
|
||||
|
||||
static inline uint32_t
|
||||
spa_pod_builder_push_struct(struct spa_pod_builder *builder)
|
||||
|
|
@ -347,7 +347,7 @@ 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_POD_TYPE_OBJECT }, { id, type }, ##__VA_ARGS__ }
|
||||
#define SPA_POD_OBJECT_INIT(size,id,type,...) (struct spa_pod_object){ { size, SPA_ID_Object }, { id, type }, ##__VA_ARGS__ }
|
||||
|
||||
static inline uint32_t
|
||||
spa_pod_builder_push_object(struct spa_pod_builder *builder, uint32_t id, uint32_t type)
|
||||
|
|
@ -359,7 +359,7 @@ spa_pod_builder_push_object(struct spa_pod_builder *builder, uint32_t id, uint32
|
|||
}
|
||||
|
||||
#define SPA_POD_PROP_INIT(size,key,flags,val_size,val_type) \
|
||||
(struct spa_pod_prop){ { size, SPA_POD_TYPE_PROP}, {key, flags, { val_size, val_type } } }
|
||||
(struct spa_pod_prop){ { size, SPA_ID_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)
|
||||
|
|
@ -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_POD_TYPE_PROP)
|
||||
builder->frame[builder->state.depth-1].pod.type == SPA_ID_Prop)
|
||||
spa_pod_builder_pop(builder);
|
||||
break;
|
||||
case ' ': case '\n': case '\t': case '\r':
|
||||
|
|
|
|||
|
|
@ -36,15 +36,17 @@ struct spa_command {
|
|||
struct spa_command_body body;
|
||||
};
|
||||
|
||||
#define SPA_COMMAND_TYPE(cmd) ((cmd)->body.body.type)
|
||||
#define SPA_COMMAND_TYPE(cmd) ((cmd)->body.body.type)
|
||||
#define SPA_COMMAND_ID(cmd,type) (SPA_COMMAND_TYPE(cmd) == type ? \
|
||||
(cmd)->body.body.id : SPA_ID_INVALID)
|
||||
|
||||
#define SPA_COMMAND_INIT(type) (struct spa_command) \
|
||||
{ { sizeof(struct spa_command_body), SPA_POD_TYPE_OBJECT }, \
|
||||
{ { 0, type } } } \
|
||||
#define SPA_COMMAND_INIT(type,id) (struct spa_command) \
|
||||
{ { sizeof(struct spa_command_body), SPA_ID_Object }, \
|
||||
{ { id, type } } } \
|
||||
|
||||
#define SPA_COMMAND_INIT_FULL(t,size,type,...) (t) \
|
||||
{ { size, SPA_POD_TYPE_OBJECT }, \
|
||||
{ { 0, type }, ##__VA_ARGS__ } } \
|
||||
#define SPA_COMMAND_INIT_FULL(t,size,type,id,...) (t) \
|
||||
{ { size, SPA_ID_OBJECT }, \
|
||||
{ { id, type }, ##__VA_ARGS__ } } \
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
|
|
|||
|
|
@ -27,25 +27,25 @@
|
|||
#include <spa/pod/iter.h>
|
||||
#include <spa/pod/builder.h>
|
||||
|
||||
static inline int spa_pod_compare_value(enum spa_pod_type type, const void *r1, const void *r2)
|
||||
static inline int spa_pod_compare_value(uint32_t type, const void *r1, const void *r2)
|
||||
{
|
||||
switch (type) {
|
||||
case SPA_POD_TYPE_INVALID:
|
||||
case SPA_ID_INVALID:
|
||||
return 0;
|
||||
case SPA_POD_TYPE_BOOL:
|
||||
case SPA_POD_TYPE_ID:
|
||||
case SPA_ID_Bool:
|
||||
case SPA_ID_Enum:
|
||||
return *(int32_t *) r1 == *(uint32_t *) r2 ? 0 : 1;
|
||||
case SPA_POD_TYPE_INT:
|
||||
case SPA_ID_Int:
|
||||
return *(int32_t *) r1 - *(int32_t *) r2;
|
||||
case SPA_POD_TYPE_LONG:
|
||||
case SPA_ID_Long:
|
||||
return *(int64_t *) r1 - *(int64_t *) r2;
|
||||
case SPA_POD_TYPE_FLOAT:
|
||||
case SPA_ID_Float:
|
||||
return *(float *) r1 - *(float *) r2;
|
||||
case SPA_POD_TYPE_DOUBLE:
|
||||
case SPA_ID_Double:
|
||||
return *(double *) r1 - *(double *) r2;
|
||||
case SPA_POD_TYPE_STRING:
|
||||
case SPA_ID_String:
|
||||
return strcmp(r1, r2);
|
||||
case SPA_POD_TYPE_RECTANGLE:
|
||||
case SPA_ID_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(enum spa_pod_type type, const void *r1,
|
|||
else
|
||||
return 1;
|
||||
}
|
||||
case SPA_POD_TYPE_FRACTION:
|
||||
case SPA_ID_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_POD_TYPE_STRUCT:
|
||||
case SPA_POD_TYPE_OBJECT:
|
||||
case SPA_ID_Struct:
|
||||
case SPA_ID_Object:
|
||||
if (SPA_POD_TYPE(p2) != SPA_POD_TYPE(p1))
|
||||
return -EINVAL;
|
||||
|
||||
if (SPA_POD_TYPE(p1) == SPA_POD_TYPE_STRUCT)
|
||||
if (SPA_POD_TYPE(p1) == SPA_ID_Struct)
|
||||
recurse_offset = sizeof(struct spa_pod_struct);
|
||||
else
|
||||
recurse_offset = sizeof(struct spa_pod_object);
|
||||
|
||||
do_advance = true;
|
||||
break;
|
||||
case SPA_POD_TYPE_PROP:
|
||||
case SPA_ID_Prop:
|
||||
{
|
||||
struct spa_pod_prop *pr1, *pr2;
|
||||
void *a1, *a2;
|
||||
|
|
|
|||
|
|
@ -1,36 +0,0 @@
|
|||
/* Simple Plugin API
|
||||
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __SPA_EVENT_TYPES_H__
|
||||
#define __SPA_EVENT_TYPES_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <spa/pod/pod-types.h>
|
||||
|
||||
#define SPA_TYPE__Event SPA_TYPE_POD_OBJECT_BASE "Event"
|
||||
#define SPA_TYPE_EVENT_BASE SPA_TYPE__Event ":"
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* __SPA_EVENT_TYPES_H__ */
|
||||
|
|
@ -35,15 +35,17 @@ struct spa_event {
|
|||
struct spa_event_body body;
|
||||
};
|
||||
|
||||
#define SPA_EVENT_TYPE(ev) ((ev)->body.body.type)
|
||||
#define SPA_EVENT_TYPE(ev) ((ev)->body.body.type)
|
||||
#define SPA_EVENT_ID(ev,type) (SPA_EVENT_TYPE(ev) == type ? \
|
||||
(ev)->body.body.id : SPA_ID_INVALID)
|
||||
|
||||
#define SPA_EVENT_INIT(type) (struct spa_event) \
|
||||
{ { sizeof(struct spa_event_body), SPA_POD_TYPE_OBJECT }, \
|
||||
{ { 0, type } } } \
|
||||
#define SPA_EVENT_INIT(type,id) (struct spa_event) \
|
||||
{ { sizeof(struct spa_event_body), SPA_ID_Object }, \
|
||||
{ { id, type } } } \
|
||||
|
||||
#define SPA_EVENT_INIT_FULL(t,size,type,...) (t) \
|
||||
{ { size, SPA_POD_TYPE_OBJECT }, \
|
||||
{ { 0, type }, ##__VA_ARGS__ } } \
|
||||
#define SPA_EVENT_INIT_FULL(t,size,type,id,...) (t) \
|
||||
{ { size, SPA_ID_OBJECT }, \
|
||||
{ { id, type }, ##__VA_ARGS__ } } \
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
|
|
|||
|
|
@ -249,13 +249,13 @@ static inline int spa_pod_filter_part(struct spa_pod_builder *b,
|
|||
uint32_t filter_offset = 0;
|
||||
|
||||
switch (SPA_POD_TYPE(pp)) {
|
||||
case SPA_POD_TYPE_STRUCT:
|
||||
case SPA_POD_TYPE_OBJECT:
|
||||
case SPA_ID_Struct:
|
||||
case SPA_ID_Object:
|
||||
if (pf != NULL) {
|
||||
if (SPA_POD_TYPE(pf) != SPA_POD_TYPE(pp))
|
||||
return -EINVAL;
|
||||
|
||||
if (SPA_POD_TYPE(pp) == SPA_POD_TYPE_STRUCT) {
|
||||
if (SPA_POD_TYPE(pp) == SPA_ID_Struct) {
|
||||
filter_offset = sizeof(struct spa_pod_struct);
|
||||
spa_pod_builder_push_struct(b);
|
||||
} else {
|
||||
|
|
@ -269,7 +269,7 @@ static inline int spa_pod_filter_part(struct spa_pod_builder *b,
|
|||
do_copy = true;
|
||||
break;
|
||||
|
||||
case SPA_POD_TYPE_PROP:
|
||||
case SPA_ID_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_POD_TYPE_PROP
|
||||
if (res->type == SPA_ID_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_POD_TYPE_OBJECT)
|
||||
if (pod->type == SPA_ID_Object)
|
||||
offset = sizeof(struct spa_pod_object);
|
||||
else if (pod->type == SPA_POD_TYPE_STRUCT)
|
||||
else if (pod->type == SPA_ID_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_POD_TYPE_OBJECT)
|
||||
if (pod->type == SPA_ID_Object)
|
||||
offset = sizeof(struct spa_pod_object);
|
||||
else if (pod->type == SPA_POD_TYPE_STRUCT)
|
||||
else if (pod->type == SPA_ID_Struct)
|
||||
offset = sizeof(struct spa_pod_struct);
|
||||
else
|
||||
return -EINVAL;
|
||||
|
||||
SPA_POD_CONTENTS_FOREACH(pod, offset, res) {
|
||||
if (res->type == SPA_POD_TYPE_PROP)
|
||||
if (res->type == SPA_ID_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_POD_TYPE_NONE:
|
||||
case SPA_ID_None:
|
||||
return type == 'T' || type == 'O' || type == 'V' || type == 's';
|
||||
case SPA_POD_TYPE_BOOL:
|
||||
case SPA_ID_Bool:
|
||||
return type == 'b';
|
||||
case SPA_POD_TYPE_ID:
|
||||
case SPA_ID_Enum:
|
||||
return type == 'I';
|
||||
case SPA_POD_TYPE_INT:
|
||||
case SPA_ID_Int:
|
||||
return type == 'i';
|
||||
case SPA_POD_TYPE_LONG:
|
||||
case SPA_ID_Long:
|
||||
return type == 'l';
|
||||
case SPA_POD_TYPE_FLOAT:
|
||||
case SPA_ID_Float:
|
||||
return type == 'f';
|
||||
case SPA_POD_TYPE_DOUBLE:
|
||||
case SPA_ID_Double:
|
||||
return type == 'd';
|
||||
case SPA_POD_TYPE_STRING:
|
||||
case SPA_ID_String:
|
||||
return type == 's' || type == 'S';
|
||||
case SPA_POD_TYPE_BYTES:
|
||||
case SPA_ID_Bytes:
|
||||
return type == 'z';
|
||||
case SPA_POD_TYPE_RECTANGLE:
|
||||
case SPA_ID_Rectangle:
|
||||
return type == 'R';
|
||||
case SPA_POD_TYPE_FRACTION:
|
||||
case SPA_ID_Fraction:
|
||||
return type == 'F';
|
||||
case SPA_POD_TYPE_BITMAP:
|
||||
case SPA_ID_Bitmap:
|
||||
return type == 'B';
|
||||
case SPA_POD_TYPE_ARRAY:
|
||||
case SPA_ID_Array:
|
||||
return type == 'a';
|
||||
case SPA_POD_TYPE_STRUCT:
|
||||
case SPA_ID_Struct:
|
||||
return type == 'T';
|
||||
case SPA_POD_TYPE_OBJECT:
|
||||
case SPA_ID_Object:
|
||||
return type == 'O';
|
||||
case SPA_POD_TYPE_POINTER:
|
||||
case SPA_ID_Pointer:
|
||||
return type == 'p';
|
||||
case SPA_POD_TYPE_FD:
|
||||
case SPA_ID_Fd:
|
||||
return type == 'h';
|
||||
case SPA_POD_TYPE_PROP:
|
||||
case SPA_ID_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_POD_TYPE_NONE) \
|
||||
(pod == NULL || (SPA_POD_TYPE(pod) == SPA_ID_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_POD_TYPE_NONE) \
|
||||
(pod == NULL || (SPA_POD_TYPE(pod) == SPA_ID_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_POD_TYPE_OBJECT)
|
||||
if (pod == NULL || SPA_POD_TYPE(pod) != SPA_ID_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_POD_TYPE_STRUCT)
|
||||
if (pod == NULL || SPA_POD_TYPE(pod) != SPA_ID_Struct)
|
||||
return -EINVAL;
|
||||
if (++parser->depth >= SPA_POD_MAX_DEPTH)
|
||||
return -EINVAL;
|
||||
|
|
|
|||
|
|
@ -1,43 +0,0 @@
|
|||
/* Simple Plugin API
|
||||
* Copyright (C) 2017 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __SPA_POD_TYPES_H__
|
||||
#define __SPA_POD_TYPES_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <spa/utils/type-info.h>
|
||||
#include <spa/pod/pod.h>
|
||||
|
||||
#define SPA_TYPE__POD SPA_TYPE_BASE "POD"
|
||||
#define SPA_TYPE_POD_BASE SPA_TYPE__POD ":"
|
||||
|
||||
#define SPA_TYPE_POD__Object SPA_TYPE_POD_BASE "Object"
|
||||
#define SPA_TYPE_POD_OBJECT_BASE SPA_TYPE_POD__Object ":"
|
||||
|
||||
#define SPA_TYPE_POD__Struct SPA_TYPE_POD_BASE "Struct"
|
||||
#define SPA_TYPE_POD_STRUCT_BASE SPA_TYPE_POD__Struct ":"
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* __SPA_POD_TYPES_H__ */
|
||||
|
|
@ -27,47 +27,12 @@ extern "C" {
|
|||
#include <stdarg.h>
|
||||
|
||||
#include <spa/utils/defs.h>
|
||||
#include <spa/utils/type.h>
|
||||
|
||||
#ifndef SPA_POD_MAX_DEPTH
|
||||
#define SPA_POD_MAX_DEPTH 16
|
||||
#endif
|
||||
|
||||
/**
|
||||
* spa_pod_type:
|
||||
*/
|
||||
enum spa_pod_type {
|
||||
SPA_POD_TYPE_INVALID = 0,
|
||||
SPA_POD_TYPE_NONE = 1,
|
||||
|
||||
SPA_POD_TYPE_BOOL,
|
||||
|
||||
SPA_POD_TYPE_ID,
|
||||
SPA_POD_TYPE_INT,
|
||||
SPA_POD_TYPE_LONG,
|
||||
SPA_POD_TYPE_FLOAT,
|
||||
SPA_POD_TYPE_DOUBLE,
|
||||
|
||||
SPA_POD_TYPE_STRING,
|
||||
SPA_POD_TYPE_BYTES,
|
||||
|
||||
SPA_POD_TYPE_RECTANGLE,
|
||||
SPA_POD_TYPE_FRACTION,
|
||||
SPA_POD_TYPE_BITMAP,
|
||||
|
||||
SPA_POD_TYPE_ARRAY,
|
||||
SPA_POD_TYPE_STRUCT,
|
||||
SPA_POD_TYPE_OBJECT,
|
||||
SPA_POD_TYPE_SEQUENCE,
|
||||
|
||||
SPA_POD_TYPE_POINTER,
|
||||
SPA_POD_TYPE_FD,
|
||||
|
||||
SPA_POD_TYPE_PROP,
|
||||
SPA_POD_TYPE_POD,
|
||||
|
||||
SPA_POD_TYPE_CUSTOM_START = 64,
|
||||
};
|
||||
|
||||
#define SPA_POD_BODY_SIZE(pod) (((struct spa_pod*)(pod))->size)
|
||||
#define SPA_POD_TYPE(pod) (((struct spa_pod*)(pod))->type)
|
||||
#define SPA_POD_SIZE(pod) (sizeof(struct spa_pod) + SPA_POD_BODY_SIZE(pod))
|
||||
|
|
@ -172,13 +137,13 @@ 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_POD_TYPE_OBJECT
|
||||
return (pod && pod->type == SPA_ID_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_POD_TYPE_OBJECT
|
||||
return (pod && pod->type == SPA_ID_Object
|
||||
&& ((struct spa_pod_object *) pod)->body.id == id);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue