fix more compile errors

Avoid void * arithmetic
Do explicit casts to target type to make c++ happy
This commit is contained in:
Wim Taymans 2019-01-08 11:53:36 +01:00
parent 3fa2ad33e4
commit b0f4be5fbc
26 changed files with 175 additions and 159 deletions

View file

@ -40,7 +40,7 @@ pkgconfig = import('pkgconfig')
cc = meson.get_compiler('c')
if cc.get_id() == 'gcc'
add_global_arguments('-Wsign-compare', '-Wimplicit-fallthrough', language : 'c')
add_global_arguments('-Wsign-compare', '-Wimplicit-fallthrough', '-Wpointer-arith', language : 'c')
endif
cdata = configuration_data()

View file

@ -48,9 +48,9 @@ struct spa_buffer_alloc_info {
};
static inline int spa_buffer_alloc_fill_info(struct spa_buffer_alloc_info *info,
uint32_t n_metas, struct spa_meta metas[n_metas],
uint32_t n_datas, struct spa_data datas[n_datas],
uint32_t data_aligns[n_datas])
uint32_t n_metas, struct spa_meta metas[],
uint32_t n_datas, struct spa_data datas[],
uint32_t data_aligns[])
{
size_t size;
uint32_t i;
@ -91,7 +91,7 @@ static inline struct spa_buffer *
spa_buffer_alloc_layout(struct spa_buffer_alloc_info *info,
void *skel_mem, void *data_mem)
{
struct spa_buffer *b = skel_mem;
struct spa_buffer *b = (struct spa_buffer*)skel_mem;
size_t size;
uint32_t i;
void **dp, *skel, *data;
@ -114,17 +114,17 @@ spa_buffer_alloc_layout(struct spa_buffer_alloc_info *info,
struct spa_meta *m = &b->metas[i];
*m = info->metas[i];
m->data = *dp;
*dp += m->size;
*dp = SPA_MEMBER(*dp, m->size, void);
}
size = info->n_datas * sizeof(struct spa_chunk);
if (SPA_FLAG_CHECK(info->flags, SPA_BUFFER_ALLOC_FLAG_INLINE_CHUNK)) {
cp = skel;
skel += size;
cp = (struct spa_chunk*)skel;
skel = SPA_MEMBER(skel, size, void);
}
else {
cp = data;
data += size;
cp = (struct spa_chunk*)data;
data = SPA_MEMBER(data, size, void);
}
if (SPA_FLAG_CHECK(info->flags, SPA_BUFFER_ALLOC_FLAG_INLINE_DATA))
@ -139,7 +139,7 @@ spa_buffer_alloc_layout(struct spa_buffer_alloc_info *info,
d->chunk = &cp[i];
if (!SPA_FLAG_CHECK(info->flags, SPA_BUFFER_ALLOC_FLAG_NO_DATA)) {
d->data = *dp;
*dp += d->maxsize;
*dp = SPA_MEMBER(*dp, d->maxsize, void);
}
}
return b;
@ -147,7 +147,7 @@ spa_buffer_alloc_layout(struct spa_buffer_alloc_info *info,
static inline int
spa_buffer_alloc_layout_array(struct spa_buffer_alloc_info *info,
uint32_t n_buffers, struct spa_buffer *buffers[n_buffers],
uint32_t n_buffers, struct spa_buffer *buffers[],
void *skel_mem, void *data_mem)
{
uint32_t i;
@ -162,9 +162,9 @@ spa_buffer_alloc_layout_array(struct spa_buffer_alloc_info *info,
static inline struct spa_buffer **
spa_buffer_alloc_array(uint32_t n_buffers, uint32_t flags,
uint32_t n_metas, struct spa_meta metas[n_metas],
uint32_t n_datas, struct spa_data datas[n_datas],
uint32_t data_aligns[n_datas])
uint32_t n_metas, struct spa_meta metas[],
uint32_t n_datas, struct spa_data datas[],
uint32_t data_aligns[])
{
struct spa_buffer **buffers;
@ -175,7 +175,7 @@ spa_buffer_alloc_array(uint32_t n_buffers, uint32_t flags,
info.skel_size = SPA_ROUND_UP_N(info.skel_size, 16);
buffers = calloc(n_buffers, sizeof(struct spa_buffer *) + info.skel_size);
buffers = (struct spa_buffer **)calloc(n_buffers, sizeof(struct spa_buffer *) + info.skel_size);
skel = SPA_MEMBER(buffers, sizeof(struct spa_buffer *) * n_buffers, void);

View file

@ -60,8 +60,8 @@ struct spa_meta {
};
#define spa_meta_first(m) ((m)->data)
#define spa_meta_end(m) ((m)->data + (m)->size)
#define spa_meta_check(p,m) ((void*)(p) + sizeof(*p) <= spa_meta_end(m))
#define spa_meta_end(m) SPA_MEMBER((m)->data,(m)->size,void)
#define spa_meta_check(p,m) (SPA_MEMBER(p,sizeof(*p),void) <= spa_meta_end(m))
/**
* Describes essential buffer header metadata such as flags and
@ -89,7 +89,7 @@ struct spa_meta_region {
#define spa_meta_region_is_valid(m) ((m)->region.size.width != 0 && (m)->region.size.height != 0)
#define spa_meta_region_for_each(pos,meta) \
for (pos = spa_meta_first(meta); \
for (pos = (__typeof(pos))spa_meta_first(meta); \
spa_meta_check(pos, meta); \
(pos)++)

View file

@ -31,7 +31,7 @@ extern "C" {
#include <spa/buffer/buffer.h>
#include <spa/buffer/meta.h>
#include <spa/utils/type-info.h>
#include <spa/utils/type.h>
#define SPA_TYPE__Buffer SPA_TYPE_POINTER_BASE "Buffer"
#define SPA_TYPE_BUFFER_BASE SPA_TYPE__Buffer ":"

View file

@ -41,6 +41,7 @@ enum spa_control_type {
SPA_CONTROL_Invalid,
SPA_CONTROL_Properties,
SPA_CONTROL_Midi,
SPA_CONTROL_LAST, /**< not part of ABI */
};
#ifdef __cplusplus

View file

@ -29,7 +29,8 @@
extern "C" {
#endif
#include <spa/debug/debug-mem.h>
#include <spa/debug/mem.h>
#include <spa/debug/types.h>
#include <spa/buffer/type-info.h>
#ifndef spa_debug
@ -38,10 +39,9 @@ extern "C" {
static inline int spa_debug_buffer(int indent, const struct spa_buffer *buffer)
{
int i;
uint32_t i;
spa_debug("%*s" "struct spa_buffer %p:", indent, "", buffer);
spa_debug("%*s" " id: %08X", indent, "", buffer->id);
spa_debug("%*s" " n_metas: %u (at %p)", indent, "", buffer->n_metas, buffer->metas);
for (i = 0; i < buffer->n_metas; i++) {
struct spa_meta *m = &buffer->metas[i];
@ -54,7 +54,7 @@ static inline int spa_debug_buffer(int indent, const struct spa_buffer *buffer)
switch (m->type) {
case SPA_META_Header:
{
struct spa_meta_header *h = m->data;
struct spa_meta_header *h = (struct spa_meta_header*)m->data;
spa_debug("%*s" " struct spa_meta_header:", indent, "");
spa_debug("%*s" " flags: %08x", indent, "", h->flags);
spa_debug("%*s" " seq: %u", indent, "", h->seq);
@ -64,15 +64,30 @@ static inline int spa_debug_buffer(int indent, const struct spa_buffer *buffer)
}
case SPA_META_VideoCrop:
{
struct spa_meta_video_crop *h = m->data;
spa_debug("%*s" " struct spa_meta_video_crop:", indent, "");
spa_debug("%*s" " x: %d", indent, "", h->x);
spa_debug("%*s" " y: %d", indent, "", h->y);
spa_debug("%*s" " width: %d", indent, "", h->width);
spa_debug("%*s" " height: %d", indent, "", h->height);
struct spa_meta_region *h = (struct spa_meta_region*)m->data;
spa_debug("%*s" " struct spa_meta_region:", indent, "");
spa_debug("%*s" " x: %d", indent, "", h->region.position.x);
spa_debug("%*s" " y: %d", indent, "", h->region.position.y);
spa_debug("%*s" " width: %d", indent, "", h->region.size.width);
spa_debug("%*s" " height: %d", indent, "", h->region.size.height);
break;
}
case SPA_META_VideoDamage:
{
struct spa_meta_region *h;
spa_meta_region_for_each(h, m) {
spa_debug("%*s" " struct spa_meta_region:", indent, "");
spa_debug("%*s" " x: %d", indent, "", h->region.position.x);
spa_debug("%*s" " y: %d", indent, "", h->region.position.y);
spa_debug("%*s" " width: %d", indent, "", h->region.size.width);
spa_debug("%*s" " height: %d", indent, "", h->region.size.height);
}
break;
}
case SPA_META_Bitmap:
break;
case SPA_META_Cursor:
break;
default:
spa_debug("%*s" " Unknown:", indent, "");
spa_debug_mem(5, m->data, m->size);

View file

@ -74,13 +74,13 @@ spa_debug_format_value(const struct spa_type_info *info,
break;
case SPA_TYPE_Rectangle:
{
struct spa_rectangle *r = body;
struct spa_rectangle *r = (struct spa_rectangle *)body;
fprintf(stderr, "%" PRIu32 "x%" PRIu32, r->width, r->height);
break;
}
case SPA_TYPE_Fraction:
{
struct spa_fraction *f = body;
struct spa_fraction *f = (struct spa_fraction *)body;
fprintf(stderr, "%" PRIu32 "/%" PRIu32, f->num, f->denom);
break;
}
@ -93,7 +93,7 @@ spa_debug_format_value(const struct spa_type_info *info,
case SPA_TYPE_Array:
{
void *p;
struct spa_pod_array_body *b = body;
struct spa_pod_array_body *b = (struct spa_pod_array_body *)body;
int i = 0;
fprintf(stderr, "< ");
SPA_POD_ARRAY_BODY_FOREACH(b, size, p) {
@ -118,27 +118,6 @@ static inline int spa_debug_format(int indent,
const char *media_subtype;
struct spa_pod_prop *prop;
uint32_t mtype, mstype;
const char *pod_type_names[] = {
[SPA_TYPE_None] = "none",
[SPA_TYPE_Bool] = "bool",
[SPA_TYPE_Id] = "id",
[SPA_TYPE_Int] = "int",
[SPA_TYPE_Long] = "long",
[SPA_TYPE_Float] = "float",
[SPA_TYPE_Double] = "double",
[SPA_TYPE_String] = "string",
[SPA_TYPE_Bytes] = "bytes",
[SPA_TYPE_Rectangle] = "rectangle",
[SPA_TYPE_Fraction] = "fraction",
[SPA_TYPE_Bitmap] = "bitmap",
[SPA_TYPE_Array] = "array",
[SPA_TYPE_Struct] = "struct",
[SPA_TYPE_Object] = "object",
[SPA_TYPE_Pointer] = "pointer",
[SPA_TYPE_Fd] = "fd",
[SPA_TYPE_Choice] = "choice",
[SPA_TYPE_Pod] = "pod"
};
if (info == NULL)
info = spa_type_format;
@ -173,12 +152,15 @@ static inline int spa_debug_format(int indent,
size = val->size;
vals = SPA_POD_BODY(val);
if (type < SPA_TYPE_None || type >= SPA_TYPE_LAST)
continue;
ti = spa_debug_type_find(info, prop->key);
key = ti ? ti->name : NULL;
fprintf(stderr, "%*s %16s : (%s) ", indent, "",
key ? rindex(key, ':') + 1 : "unknown",
pod_type_names[type]);
rindex(spa_types[type].name, ':') + 1);
if (choice == SPA_CHOICE_None) {
spa_debug_format_value(ti->values, type, vals, size);

View file

@ -37,7 +37,7 @@ extern "C" {
static inline int spa_debug_mem(int indent, const void *data, size_t size)
{
const uint8_t *t = data;
const uint8_t *t = (const uint8_t*)data;
char buffer[512];
size_t i;
int pos = 0;

View file

@ -137,20 +137,20 @@ spa_debug_pod_value(int indent, const struct spa_type_info *info,
break;
case SPA_TYPE_Pointer:
{
struct spa_pod_pointer_body *b = body;
struct spa_pod_pointer_body *b = (struct spa_pod_pointer_body *)body;
spa_debug("%*s" "Pointer %s %p", indent, "",
spa_debug_type_find_name(SPA_TYPE_ROOT, b->type), b->value);
break;
}
case SPA_TYPE_Rectangle:
{
struct spa_rectangle *r = body;
struct spa_rectangle *r = (struct spa_rectangle *)body;
spa_debug("%*s" "Rectangle %dx%d", indent, "", r->width, r->height);
break;
}
case SPA_TYPE_Fraction:
{
struct spa_fraction *f = body;
struct spa_fraction *f = (struct spa_fraction *)body;
spa_debug("%*s" "Fraction %d/%d", indent, "", f->num, f->denom);
break;
}
@ -159,7 +159,7 @@ spa_debug_pod_value(int indent, const struct spa_type_info *info,
break;
case SPA_TYPE_Array:
{
struct spa_pod_array_body *b = body;
struct spa_pod_array_body *b = (struct spa_pod_array_body *)body;
void *p;
const struct spa_type_info *ti = spa_debug_type_find(SPA_TYPE_ROOT, b->child.type);
@ -172,7 +172,7 @@ spa_debug_pod_value(int indent, const struct spa_type_info *info,
}
case SPA_TYPE_Choice:
{
struct spa_pod_choice_body *b = body;
struct spa_pod_choice_body *b = (struct spa_pod_choice_body *)body;
void *p;
const struct spa_type_info *ti = spa_debug_type_find(spa_type_choice, b->type);
@ -185,7 +185,7 @@ spa_debug_pod_value(int indent, const struct spa_type_info *info,
}
case SPA_TYPE_Struct:
{
struct spa_pod *b = body, *p;
struct spa_pod *b = (struct spa_pod *)body, *p;
spa_debug("%*s" "Struct: size %d", indent, "", size);
SPA_POD_FOREACH(b, size, p)
spa_debug_pod_value(indent + 2, info, p->type, SPA_POD_BODY(p), p->size);
@ -193,7 +193,7 @@ spa_debug_pod_value(int indent, const struct spa_type_info *info,
}
case SPA_TYPE_Object:
{
struct spa_pod_object_body *b = body;
struct spa_pod_object_body *b = (struct spa_pod_object_body *)body;
struct spa_pod_prop *p;
const struct spa_type_info *ti, *ii;
@ -221,7 +221,7 @@ spa_debug_pod_value(int indent, const struct spa_type_info *info,
}
case SPA_TYPE_Sequence:
{
struct spa_pod_sequence_body *b = body;
struct spa_pod_sequence_body *b = (struct spa_pod_sequence_body *)body;
const struct spa_type_info *ti, *ii;
struct spa_pod_control *c;

View file

@ -132,14 +132,14 @@ struct spa_graph_port {
static inline int spa_graph_link_signal_node(void *data)
{
struct spa_graph_node *node = data;
struct spa_graph_node *node = (struct spa_graph_node *)data;
spa_debug("node %p call process", node);
return spa_graph_node_process(node);
}
static inline int spa_graph_link_signal_graph(void *data)
{
struct spa_graph_node *node = data;
struct spa_graph_node *node = (struct spa_graph_node *)data;
if (node->graph)
spa_graph_finish(node->graph);
return 0;
@ -299,7 +299,7 @@ spa_graph_port_unlink(struct spa_graph_port *port)
static inline int spa_graph_node_impl_process(void *data, struct spa_graph_node *node)
{
struct spa_node *n = data;
struct spa_node *n = (struct spa_node *)data;
struct spa_graph_state *state = node->state;
spa_debug("node %p: process state %p: %d, node %p", node, state, state->status, n);
@ -312,7 +312,7 @@ static inline int spa_graph_node_impl_process(void *data, struct spa_graph_node
static inline int spa_graph_node_impl_reuse_buffer(void *data, struct spa_graph_node *node,
uint32_t port_id, uint32_t buffer_id)
{
struct spa_node *n = data;
struct spa_node *n = (struct spa_node *)data;
return spa_node_port_reuse_buffer(n, port_id, buffer_id);
}

View file

@ -48,7 +48,7 @@ spa_format_audio_raw_parse(const struct spa_pod *format, struct spa_audio_info_r
":", SPA_FORMAT_AUDIO_position, "?P", &position, NULL);
if (position && position->type == SPA_TYPE_Array &&
SPA_POD_ARRAY_TYPE(position) == SPA_TYPE_Id) {
uint32_t *values = SPA_POD_ARRAY_VALUES(position);
uint32_t *values = (uint32_t*)SPA_POD_ARRAY_VALUES(position);
uint32_t n_values = SPA_MIN(SPA_POD_ARRAY_N_VALUES(position), SPA_AUDIO_MAX_CHANNELS);
memcpy(info->position, values, n_values * sizeof(uint32_t));
}
@ -61,13 +61,19 @@ spa_format_audio_raw_parse(const struct spa_pod *format, struct spa_audio_info_r
static inline struct spa_pod *
spa_format_audio_raw_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info_raw *info)
{
const struct spa_pod_id media_type = SPA_POD_Id(SPA_MEDIA_TYPE_audio);
const struct spa_pod_id media_subtype = SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw);
const struct spa_pod_id format = SPA_POD_Id(info->format);
const struct spa_pod_int rate = SPA_POD_Int(info->rate);
const struct spa_pod_int channels = SPA_POD_Int(info->channels);
spa_pod_builder_push_object(builder, SPA_TYPE_OBJECT_Format, id);
spa_pod_builder_props(builder,
SPA_FORMAT_mediaType, &SPA_POD_Id(SPA_MEDIA_TYPE_audio),
SPA_FORMAT_mediaSubtype, &SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
SPA_FORMAT_AUDIO_format, &SPA_POD_Id(info->format),
SPA_FORMAT_AUDIO_rate, &SPA_POD_Int(info->rate),
SPA_FORMAT_AUDIO_channels, &SPA_POD_Int(info->channels),
SPA_FORMAT_mediaType, &media_type,
SPA_FORMAT_mediaSubtype, &media_subtype,
SPA_FORMAT_AUDIO_format, &format,
SPA_FORMAT_AUDIO_rate, &rate,
SPA_FORMAT_AUDIO_channels, &channels,
0);
if (!SPA_FLAG_CHECK(info->flags, SPA_AUDIO_FLAG_UNPOSITIONED)) {
@ -75,7 +81,8 @@ spa_format_audio_raw_build(struct spa_pod_builder *builder, uint32_t id, struct
spa_pod_builder_array(builder, sizeof(uint32_t), SPA_TYPE_Id,
info->channels, info->position);
}
return spa_pod_builder_pop(builder);
return (struct spa_pod*)spa_pod_builder_pop(builder);
}

View file

@ -29,11 +29,7 @@
extern "C" {
#endif
struct spa_video_info_h264;
struct spa_video_info_mjpg;
#include <spa/param/format.h>
#include <spa/param/video/format.h>
enum spa_h264_stream_format {
SPA_H264_STREAM_FORMAT_UNKNOWN = 0,

View file

@ -232,7 +232,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(val) (struct spa_pod_id){ { sizeof(uint32_t), SPA_TYPE_Id }, val, 0 }
#define SPA_POD_Id(val) (struct spa_pod_id){ { sizeof(uint32_t), SPA_TYPE_Id }, (uint32_t)val, 0 }
static inline uint32_t spa_pod_builder_id(struct spa_pod_builder *builder, uint32_t val)
{
@ -240,7 +240,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(val) (struct spa_pod_int){ { sizeof(uint32_t), SPA_TYPE_Int }, val, 0 }
#define SPA_POD_Int(val) (struct spa_pod_int){ { sizeof(int32_t), SPA_TYPE_Int }, (int32_t)val, 0 }
static inline uint32_t spa_pod_builder_int(struct spa_pod_builder *builder, int32_t val)
{
@ -248,7 +248,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(val) (struct spa_pod_long){ { sizeof(uint64_t), SPA_TYPE_Long }, val }
#define SPA_POD_Long(val) (struct spa_pod_long){ { sizeof(int64_t), SPA_TYPE_Long }, (int64_t)val }
static inline uint32_t spa_pod_builder_long(struct spa_pod_builder *builder, int64_t val)
{

View file

@ -22,6 +22,14 @@
* DEALINGS IN THE SOFTWARE.
*/
#ifndef __SPA_POD_COMPARE_H__
#define __SPA_POD_COMPARE_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdarg.h>
#include <errno.h>
#include <stdint.h>
#include <stddef.h>
@ -49,7 +57,7 @@ static inline int spa_pod_compare_value(uint32_t type, const void *r1, const voi
case SPA_TYPE_Double:
return *(double *) r1 - *(double *) r2;
case SPA_TYPE_String:
return strcmp(r1, r2);
return strcmp((char *)r1, (char *)r2);
case SPA_TYPE_Rectangle:
{
const struct spa_rectangle *rec1 = (struct spa_rectangle *) r1,
@ -106,9 +114,9 @@ static inline int spa_pod_compare(const struct spa_pod *pod1,
const struct spa_pod *p1, *p2;
size_t p1s, p2s;
p1 = SPA_POD_BODY_CONST(pod1);
p1 = (const struct spa_pod*)SPA_POD_BODY_CONST(pod1);
p1s = SPA_POD_BODY_SIZE(pod1);
p2 = SPA_POD_BODY_CONST(pod2);
p2 = (const struct spa_pod*)SPA_POD_BODY_CONST(pod2);
p2s = SPA_POD_BODY_SIZE(pod2);
while (true) {
@ -119,8 +127,8 @@ static inline int spa_pod_compare(const struct spa_pod *pod1,
if ((res = spa_pod_compare(p1, p2)) != 0)
return res;
p1 = spa_pod_next(p1);
p2 = spa_pod_next(p2);
p1 = (const struct spa_pod*)spa_pod_next(p1);
p2 = (const struct spa_pod*)spa_pod_next(p2);
}
break;
}
@ -153,3 +161,9 @@ static inline int spa_pod_compare(const struct spa_pod *pod1,
}
return res;
}
#ifdef __cplusplus
}
#endif
#endif

View file

@ -125,7 +125,7 @@ spa_pod_filter_prop(struct spa_pod_builder *b,
/* start with copying the property */
spa_pod_builder_prop(b, p1->key, 0);
nc = spa_pod_builder_deref(b, spa_pod_builder_push_choice(b, 0, 0));
nc = (struct spa_pod_choice*)spa_pod_builder_deref(b, spa_pod_builder_push_choice(b, 0, 0));
/* default value */
spa_pod_builder_primitive(b, v1);
@ -136,8 +136,8 @@ spa_pod_filter_prop(struct spa_pod_builder *b,
(p1c == SPA_CHOICE_Enum && p2c == SPA_CHOICE_Enum)) {
int n_copied = 0;
/* copy all equal values but don't copy the default value again */
for (j = 0, a1 = alt1; j < nalt1; j++, a1 += size) {
for (k = 0, a2 = alt2; k < nalt2; k++, a2 += size) {
for (j = 0, a1 = alt1; j < nalt1; j++, a1 = SPA_MEMBER(a1, size, void)) {
for (k = 0, a2 = alt2; k < nalt2; k++, a2 = SPA_MEMBER(a2,size,void)) {
if (spa_pod_compare_value(type, a1, a2) == 0) {
if (p1c == SPA_CHOICE_Enum || j > 0)
spa_pod_builder_raw(b, a1, size);
@ -154,10 +154,10 @@ spa_pod_filter_prop(struct spa_pod_builder *b,
(p1c == SPA_CHOICE_Enum && p2c == SPA_CHOICE_Range)) {
int n_copied = 0;
/* copy all values inside the range */
for (j = 0, a1 = alt1, a2 = alt2; j < nalt1; j++, a1 += size) {
for (j = 0, a1 = alt1, a2 = alt2; j < nalt1; j++, a1 = SPA_MEMBER(a1,size,void)) {
if (spa_pod_compare_value(type, a1, a2) < 0)
continue;
if (spa_pod_compare_value(type, a1, a2 + size) > 0)
if (spa_pod_compare_value(type, a1, SPA_MEMBER(a2,size,void)) > 0)
continue;
spa_pod_builder_raw(b, a1, size);
n_copied++;
@ -176,10 +176,10 @@ spa_pod_filter_prop(struct spa_pod_builder *b,
(p1c == SPA_CHOICE_Range && p2c == SPA_CHOICE_Enum)) {
int n_copied = 0;
/* copy all values inside the range */
for (k = 0, a1 = alt1, a2 = alt2; k < nalt2; k++, a2 += size) {
for (k = 0, a1 = alt1, a2 = alt2; k < nalt2; k++, a2 = SPA_MEMBER(a2,size,void)) {
if (spa_pod_compare_value(type, a2, a1) < 0)
continue;
if (spa_pod_compare_value(type, a2, a1 + size) > 0)
if (spa_pod_compare_value(type, a2, SPA_MEMBER(a1,size,void)) > 0)
continue;
spa_pod_builder_raw(b, a2, size);
n_copied++;
@ -195,8 +195,8 @@ spa_pod_filter_prop(struct spa_pod_builder *b,
else
spa_pod_builder_raw(b, alt1, size);
alt1 += size;
alt2 += size;
alt1 = SPA_MEMBER(alt1,size,void);
alt2 = SPA_MEMBER(alt2,size,void);
if (spa_pod_compare_value(type, alt1, alt2) < 0)
spa_pod_builder_raw(b, alt1, size);
@ -304,9 +304,9 @@ static inline int spa_pod_filter_part(struct spa_pod_builder *b,
filter_offset = sizeof(struct spa_pod_struct);
spa_pod_builder_push_struct(b);
res = spa_pod_filter_part(b,
SPA_MEMBER(pp,filter_offset,void),
SPA_MEMBER(pp,filter_offset,const struct spa_pod),
SPA_POD_SIZE(pp) - filter_offset,
SPA_MEMBER(pf,filter_offset,void),
SPA_MEMBER(pf,filter_offset,const struct spa_pod),
SPA_POD_SIZE(pf) - filter_offset);
spa_pod_builder_pop(b);
do_advance = true;
@ -329,7 +329,7 @@ static inline int spa_pod_filter_part(struct spa_pod_builder *b,
if (do_copy)
spa_pod_builder_raw_padded(b, pp, SPA_POD_SIZE(pp));
if (do_advance) {
pf = spa_pod_next(pf);
pf = (const struct spa_pod*)spa_pod_next(pf);
if (!spa_pod_is_inside(filter, filter_size, pf))
pf = NULL;
}
@ -352,7 +352,7 @@ spa_pod_filter(struct spa_pod_builder *b,
spa_return_val_if_fail(b != NULL, -EINVAL);
if (filter == NULL) {
*result = spa_pod_builder_deref(b,
*result = (struct spa_pod*)spa_pod_builder_deref(b,
spa_pod_builder_raw_padded(b, pod, SPA_POD_SIZE(pod)));
return 0;
}
@ -361,7 +361,7 @@ spa_pod_filter(struct spa_pod_builder *b,
if ((res = spa_pod_filter_part(b, pod, SPA_POD_SIZE(pod), filter, SPA_POD_SIZE(filter))) < 0)
spa_pod_builder_reset(b, &state);
else
*result = spa_pod_builder_deref(b, state.offset);
*result = (struct spa_pod*)spa_pod_builder_deref(b, state.offset);
return res;
}

View file

@ -108,19 +108,19 @@ static inline struct spa_pod_control *spa_pod_control_next(const struct spa_pod_
}
#define SPA_POD_ARRAY_BODY_FOREACH(body, _size, iter) \
for ((iter) = SPA_MEMBER((body), sizeof(struct spa_pod_array_body), __typeof__(*(iter))); \
(iter) < SPA_MEMBER((body), (_size), __typeof__(*(iter))); \
(iter) = SPA_MEMBER((iter), (body)->child.size, __typeof__(*(iter))))
for ((iter) = (__typeof__(iter))SPA_MEMBER((body), sizeof(struct spa_pod_array_body), void); \
(iter) < (__typeof__(iter))SPA_MEMBER((body), (_size), void); \
(iter) = (__typeof__(iter))SPA_MEMBER((iter), (body)->child.size, void))
#define SPA_POD_CHOICE_BODY_FOREACH(body, _size, iter) \
for ((iter) = SPA_MEMBER((body), sizeof(struct spa_pod_choice_body), __typeof__(*(iter))); \
(iter) < SPA_MEMBER((body), (_size), __typeof__(*(iter))); \
(iter) = SPA_MEMBER((iter), (body)->child.size, __typeof__(*(iter))))
for ((iter) = (__typeof__(iter))SPA_MEMBER((body), sizeof(struct spa_pod_choice_body), void); \
(iter) < (__typeof__(iter))SPA_MEMBER((body), (_size), void); \
(iter) = (__typeof__(iter))SPA_MEMBER((iter), (body)->child.size, void))
#define SPA_POD_FOREACH(pod, size, iter) \
for ((iter) = (pod); \
spa_pod_is_inside(pod, size, iter); \
(iter) = spa_pod_next(iter))
(iter) = (__typeof__(iter))spa_pod_next(iter))
#define SPA_POD_STRUCT_FOREACH(obj, iter) \
SPA_POD_FOREACH(SPA_POD_BODY(obj), SPA_POD_BODY_SIZE(obj), iter)

View file

@ -40,42 +40,6 @@ static inline bool spa_type_is_a(const char *type, const char *parent)
return type != NULL && parent != NULL && strncmp(type, parent, strlen(parent)) == 0;
}
struct spa_type_info {
uint32_t type;
const char *name;
uint32_t parent;
const struct spa_type_info *values;
};
#define SPA_TYPE_BASE "Spa:"
#define SPA_TYPE__Flags SPA_TYPE_BASE "Flags"
#define SPA_TYPE_FLAGS_BASE SPA_TYPE__Flags ":"
#define SPA_TYPE__Enum SPA_TYPE_BASE "Enum"
#define SPA_TYPE_ENUM_BASE SPA_TYPE__Enum ":"
#define SPA_TYPE__Pod SPA_TYPE_BASE "Pod"
#define SPA_TYPE_POD_BASE SPA_TYPE__Pod ":"
#define SPA_TYPE__Struct SPA_TYPE_POD_BASE "Struct"
#define SPA_TYPE_STRUCT_BASE SPA_TYPE__Struct ":"
#define SPA_TYPE__Object SPA_TYPE_POD_BASE "Object"
#define SPA_TYPE_OBJECT_BASE SPA_TYPE__Object ":"
#define SPA_TYPE__Pointer SPA_TYPE_BASE "Pointer"
#define SPA_TYPE_POINTER_BASE SPA_TYPE__Pointer ":"
#define SPA_TYPE__Interface SPA_TYPE_POINTER_BASE "Interface"
#define SPA_TYPE_INTERFACE_BASE SPA_TYPE__Interface ":"
#define SPA_TYPE__Event SPA_TYPE_OBJECT_BASE "Event"
#define SPA_TYPE_EVENT_BASE SPA_TYPE__Event ":"
#define SPA_TYPE__Command SPA_TYPE_OBJECT_BASE "Command"
#define SPA_TYPE_COMMAND_BASE SPA_TYPE__Command ":"
#include <spa/utils/type.h>
/* base for parameter object enumerations */

View file

@ -110,6 +110,41 @@ enum {
SPA_TYPE_VENDOR_Other = 0x7f000000,
};
#define SPA_TYPE_BASE "Spa:"
#define SPA_TYPE__Flags SPA_TYPE_BASE "Flags"
#define SPA_TYPE_FLAGS_BASE SPA_TYPE__Flags ":"
#define SPA_TYPE__Enum SPA_TYPE_BASE "Enum"
#define SPA_TYPE_ENUM_BASE SPA_TYPE__Enum ":"
#define SPA_TYPE__Pod SPA_TYPE_BASE "Pod"
#define SPA_TYPE_POD_BASE SPA_TYPE__Pod ":"
#define SPA_TYPE__Struct SPA_TYPE_POD_BASE "Struct"
#define SPA_TYPE_STRUCT_BASE SPA_TYPE__Struct ":"
#define SPA_TYPE__Object SPA_TYPE_POD_BASE "Object"
#define SPA_TYPE_OBJECT_BASE SPA_TYPE__Object ":"
#define SPA_TYPE__Pointer SPA_TYPE_BASE "Pointer"
#define SPA_TYPE_POINTER_BASE SPA_TYPE__Pointer ":"
#define SPA_TYPE__Interface SPA_TYPE_POINTER_BASE "Interface"
#define SPA_TYPE_INTERFACE_BASE SPA_TYPE__Interface ":"
#define SPA_TYPE__Event SPA_TYPE_OBJECT_BASE "Event"
#define SPA_TYPE_EVENT_BASE SPA_TYPE__Event ":"
#define SPA_TYPE__Command SPA_TYPE_OBJECT_BASE "Command"
#define SPA_TYPE_COMMAND_BASE SPA_TYPE__Command ":"
struct spa_type_info {
uint32_t type;
const char *name;
uint32_t parent;
const struct spa_type_info *values;
};
#ifdef __cplusplus
} /* extern "C" */

View file

@ -801,7 +801,7 @@ push_frames(struct state *state,
l0 = SPA_MIN(n_bytes, d[0].maxsize - offs);
l1 = n_bytes - l0;
memcpy(d[0].data + offs, src, l0);
memcpy(SPA_MEMBER(d[0].data, offs, void), src, l0);
if (l1 > 0)
memcpy(d[0].data, src + l0, l1);

View file

@ -760,7 +760,7 @@ add_port_data(struct impl *this, void *out, size_t outsize, struct port *port, i
if (layer == 0) {
this->clear(out, len1);
if (len2 > 0)
this->clear(out + len1, len2);
this->clear(SPA_MEMBER(out, len1, void), len2);
}
}
else if (volume < 0.999 || volume > 1.001) {
@ -768,14 +768,14 @@ add_port_data(struct impl *this, void *out, size_t outsize, struct port *port, i
mix(out, SPA_MEMBER(data, offset, void), volume, len1);
if (len2 > 0)
mix(out + len1, data, volume, len2);
mix(SPA_MEMBER(out, len1, void), data, volume, len2);
}
else {
mix_func_t mix = layer == 0 ? this->copy : this->add;
mix(out, SPA_MEMBER(data, offset, void), len1);
if (len2 > 0)
mix(out + len1, data, len2);
mix(SPA_MEMBER(out, len1, void), data, len2);
}
port->queued_bytes -= outsize;

View file

@ -413,7 +413,7 @@ static int add_data(struct impl *this, const void *data, int size)
if (processed < 0)
return 0;
data += processed;
data = SPA_MEMBER(data, processed, void);
size -= processed;
total += processed;
}

View file

@ -529,7 +529,7 @@ write_pod (struct spa_pod_builder *b, const void *data, uint32_t size)
if (b->data == NULL)
return -1;
}
memcpy (b->data + ref, data, size);
memcpy (SPA_MEMBER(b->data, ref, void), data, size);
return ref;
}

View file

@ -852,7 +852,7 @@ do_port_use_buffers(struct impl *impl,
mb[i].buffer = &b->buffer;
mb[i].mem_id = b->memid;
mb[i].offset = SPA_PTRDIFF(baseptr, mem->ptr + mem->offset);
mb[i].offset = SPA_PTRDIFF(baseptr, SPA_MEMBER(mem->ptr, mem->offset, void));
mb[i].size = data_size;
for (j = 0; j < buffers[i]->n_metas; j++)

View file

@ -361,7 +361,7 @@ static uint32_t write_pod(struct spa_pod_builder *b, const void *data, uint32_t
b->size = SPA_ROUND_UP_N(ref + size, 4096);
b->data = begin_write(&impl->this, b->size);
}
memcpy(b->data + ref, data, size);
memcpy(SPA_MEMBER(b->data, ref, void), data, size);
return ref;
}
@ -493,7 +493,7 @@ int pw_protocol_native_connection_flush(struct pw_protocol_native_connection *co
outfds);
size -= sent;
data += sent;
data = SPA_MEMBER(data, sent, void);
n_fds -= outfds;
fds += outfds;
}

View file

@ -491,7 +491,7 @@ static int alloc_buffers(struct pw_link *this,
m->type = metas[j].type;
m->size = metas[j].size;
m->data = p;
p += m->size;
p = SPA_MEMBER(p, m->size, void);
}
/* pointer to data structure */
b->n_datas = n_datas;
@ -514,7 +514,7 @@ static int alloc_buffers(struct pw_link *this,
d->chunk->offset = 0;
d->chunk->size = 0;
d->chunk->stride = data_strides[j];
ddp += data_sizes[j];
ddp = SPA_MEMBER(ddp, data_sizes[j], void);
} else {
/* needs to be allocated by a node */
d->type = SPA_ID_INVALID;

View file

@ -112,7 +112,7 @@ int pw_memblock_map(struct pw_memblock *mem)
prot |= PROT_WRITE;
if (mem->flags & PW_MEMBLOCK_FLAG_MAP_TWICE) {
void *ptr;
void *ptr, *wrap;
mem->ptr =
mmap(NULL, mem->size << 1, PROT_NONE, MAP_ANONYMOUS | MAP_PRIVATE, -1,
@ -128,10 +128,12 @@ int pw_memblock_map(struct pw_memblock *mem)
return -ENOMEM;
}
wrap = SPA_MEMBER(mem->ptr, mem->size, void);
ptr =
mmap(mem->ptr + mem->size, mem->size, prot, MAP_FIXED | MAP_SHARED,
mmap(wrap, mem->size, prot, MAP_FIXED | MAP_SHARED,
mem->fd, mem->offset);
if (ptr != mem->ptr + mem->size) {
if (ptr != wrap) {
munmap(mem->ptr, mem->size << 1);
return -ENOMEM;
}
@ -280,7 +282,7 @@ struct pw_memblock * pw_memblock_find(const void *ptr)
struct memblock *m;
spa_list_for_each(m, &_memblocks, link) {
if (ptr >= m->mem.ptr && ptr < m->mem.ptr + m->mem.size)
if (ptr >= m->mem.ptr && ptr < SPA_MEMBER(m->mem.ptr, m->mem.size, void))
return &m->mem;
}
return NULL;