add some padding and fix types

This commit is contained in:
Wim Taymans 2019-01-16 17:37:58 +01:00
parent cb346c0745
commit 92e9d99d0a
4 changed files with 13 additions and 9 deletions

View file

@ -36,6 +36,7 @@ extern "C" {
struct spa_pod_frame { struct spa_pod_frame {
struct spa_pod pod; struct spa_pod pod;
uint32_t ref; uint32_t ref;
uint32_t _padding;
}; };
struct spa_pod_builder_state { struct spa_pod_builder_state {
@ -46,12 +47,14 @@ struct spa_pod_builder_state {
#define SPA_POD_BUILDER_FLAG_SEQUENCE (1<<3) #define SPA_POD_BUILDER_FLAG_SEQUENCE (1<<3)
#define SPA_POD_BUILDER_FLAG_HEADER (1<<4) #define SPA_POD_BUILDER_FLAG_HEADER (1<<4)
uint32_t flags; uint32_t flags;
int depth; uint32_t depth;
uint32_t _padding;
}; };
struct spa_pod_builder { struct spa_pod_builder {
void *data; void *data;
uint32_t size; uint32_t size;
uint32_t _padding;
uint32_t (*write) (struct spa_pod_builder *builder, const void *data, uint32_t size); uint32_t (*write) (struct spa_pod_builder *builder, const void *data, uint32_t size);
void * (*deref) (struct spa_pod_builder *builder, uint32_t ref, bool safe); void * (*deref) (struct spa_pod_builder *builder, uint32_t ref, bool safe);
@ -144,8 +147,7 @@ spa_pod_builder_push(struct spa_pod_builder *builder,
static inline uint32_t static inline uint32_t
spa_pod_builder_raw(struct spa_pod_builder *builder, const void *data, uint32_t size) spa_pod_builder_raw(struct spa_pod_builder *builder, const void *data, uint32_t size)
{ {
uint32_t ref; uint32_t i, ref;
int i;
if (builder->write) { if (builder->write) {
ref = builder->write(builder, data, size); ref = builder->write(builder, data, size);
@ -322,7 +324,7 @@ spa_pod_builder_bytes(struct spa_pod_builder *builder, const void *bytes, uint32
return ref; return ref;
} }
#define SPA_POD_INIT_Pointer(type,value) (struct spa_pod_pointer){ { sizeof(struct spa_pod_pointer_body), SPA_TYPE_Pointer }, { type, value } } #define SPA_POD_INIT_Pointer(type,value) (struct spa_pod_pointer){ { sizeof(struct spa_pod_pointer_body), SPA_TYPE_Pointer }, { type, 0, value } }
static inline uint32_t static inline uint32_t
spa_pod_builder_pointer(struct spa_pod_builder *builder, uint32_t type, void *val) spa_pod_builder_pointer(struct spa_pod_builder *builder, uint32_t type, void *val)

View file

@ -35,7 +35,7 @@ extern "C" {
#include <spa/pod/iter.h> #include <spa/pod/iter.h>
struct spa_pod_parser { struct spa_pod_parser {
int depth; uint32_t depth;
#define SPA_POD_PARSER_FLAG_OBJECT (1<<0) #define SPA_POD_PARSER_FLAG_OBJECT (1<<0)
#define SPA_POD_PARSER_FLAG_STRUCT (1<<1) #define SPA_POD_PARSER_FLAG_STRUCT (1<<1)
uint32_t flags; uint32_t flags;

View file

@ -49,7 +49,7 @@ extern "C" {
#define SPA_POD_BODY_CONST(pod) SPA_MEMBER((pod),sizeof(struct spa_pod),const void) #define SPA_POD_BODY_CONST(pod) SPA_MEMBER((pod),sizeof(struct spa_pod),const void)
struct spa_pod { struct spa_pod {
uint32_t size; uint32_t size; /* size of the body */
uint32_t type; /* a basic id of enum spa_type */ uint32_t type; /* a basic id of enum spa_type */
}; };
@ -193,6 +193,7 @@ static inline bool spa_pod_is_object_id(const struct spa_pod *pod, uint32_t id)
struct spa_pod_pointer_body { struct spa_pod_pointer_body {
uint32_t type; /**< pointer id, one of enum spa_type */ uint32_t type; /**< pointer id, one of enum spa_type */
uint32_t _padding;
const void *value; const void *value;
}; };
@ -203,7 +204,7 @@ struct spa_pod_pointer {
struct spa_pod_fd { struct spa_pod_fd {
struct spa_pod pod; struct spa_pod pod;
int value; int64_t value;
}; };
static inline struct spa_pod *spa_pod_get_values(const struct spa_pod *pod, uint32_t *n_vals, uint32_t *choice) static inline struct spa_pod *spa_pod_get_values(const struct spa_pod *pod, uint32_t *n_vals, uint32_t *choice)
@ -221,6 +222,7 @@ static inline struct spa_pod *spa_pod_get_values(const struct spa_pod *pod, uint
#define SPA_POD_PROP_SIZE(prop) (sizeof(struct spa_pod_prop) + (prop)->value.size) #define SPA_POD_PROP_SIZE(prop) (sizeof(struct spa_pod_prop) + (prop)->value.size)
/* props can be inside an object */
struct spa_pod_prop { struct spa_pod_prop {
uint32_t key; /**< key of property, list of valid keys depends on the uint32_t key; /**< key of property, list of valid keys depends on the
* object type */ * object type */

View file

@ -375,7 +375,7 @@ pw_protocol_native_connection_begin_resource(struct pw_protocol_native_connectio
impl->dest_id = resource->id; impl->dest_id = resource->id;
impl->opcode = opcode; impl->opcode = opcode;
impl->builder = (struct spa_pod_builder) { NULL, 0, write_pod }; impl->builder = (struct spa_pod_builder) { NULL, 0, 0, write_pod };
return &impl->builder; return &impl->builder;
} }
@ -389,7 +389,7 @@ pw_protocol_native_connection_begin_proxy(struct pw_protocol_native_connection *
impl->dest_id = proxy->id; impl->dest_id = proxy->id;
impl->opcode = opcode; impl->opcode = opcode;
impl->builder = (struct spa_pod_builder) { NULL, 0, write_pod, }; impl->builder = (struct spa_pod_builder) { NULL, 0, 0, write_pod, };
return &impl->builder; return &impl->builder;
} }