spa/buffer: rename SPA_MEMBER to SPA_PTROFF

SPA_MEMBER is misleading, all we're doing here is pointer+offset and a
type-casting the result. Rename to SPA_PTROFF which is more expressive (and
has the same number of characters so we don't need to re-indent).
This commit is contained in:
Peter Hutterer 2021-05-06 13:41:44 +10:00 committed by Wim Taymans
parent e598d0a422
commit 2405f0942b
92 changed files with 248 additions and 227 deletions

View file

@ -259,7 +259,7 @@ snd_pcm_pipewire_process(snd_pcm_pipewire_t *pw, struct pw_buffer *b,
d[0].chunk->size = want * pw->stride;
d[0].chunk->offset = 0;
}
ptr = SPA_MEMBER(d[0].data, d[0].chunk->offset, void);
ptr = SPA_PTROFF(d[0].data, d[0].chunk->offset, void);
for (channel = 0; channel < io->channels; channel++) {
pwareas[channel].addr = ptr;
pwareas[channel].first = channel * pw->sample_bits;
@ -271,7 +271,7 @@ snd_pcm_pipewire_process(snd_pcm_pipewire_t *pw, struct pw_buffer *b,
d[channel].chunk->size = want * pw->stride;
d[channel].chunk->offset = 0;
}
ptr = SPA_MEMBER(d[channel].data, d[channel].chunk->offset, void);
ptr = SPA_PTROFF(d[channel].data, d[channel].chunk->offset, void);
pwareas[channel].addr = ptr;
pwareas[channel].first = 0;
pwareas[channel].step = pw->sample_bits;

View file

@ -129,8 +129,8 @@ static void remove_property(jack_description_t *desc, jack_property_t *prop)
{
clear_property(prop);
desc->property_cnt--;
memmove(desc->properties, SPA_MEMBER(prop, sizeof(*prop), void),
SPA_PTRDIFF(SPA_MEMBER(desc->properties, sizeof(*prop) * desc->property_cnt, void),
memmove(desc->properties, SPA_PTROFF(prop, sizeof(*prop), void),
SPA_PTRDIFF(SPA_PTROFF(desc->properties, sizeof(*prop) * desc->property_cnt, void),
prop));
if (desc->property_cnt == 0)

View file

@ -1799,7 +1799,7 @@ static int client_node_port_use_buffers(void *object,
memcpy(d, &buf->datas[j], sizeof(struct spa_data));
d->chunk =
SPA_MEMBER(mm->ptr, offset + sizeof(struct spa_chunk) * j,
SPA_PTROFF(mm->ptr, offset + sizeof(struct spa_chunk) * j,
struct spa_chunk);
if (d->type == SPA_DATA_MemId) {
@ -1833,7 +1833,7 @@ static int client_node_port_use_buffers(void *object,
c, j, bm->id, bm->fd, d->maxsize);
} else if (d->type == SPA_DATA_MemPtr) {
int offs = SPA_PTR_TO_INT(d->data);
d->data = SPA_MEMBER(mm->ptr, offs, void);
d->data = SPA_PTROFF(mm->ptr, offs, void);
d->fd = -1;
pw_log_debug(NAME" %p: data %d %u -> mem %p %d",
c, j, b->id, d->data, d->maxsize);
@ -5128,7 +5128,7 @@ static inline uint8_t * midi_event_data (void* port_buffer,
if (SPA_LIKELY(event->size <= MIDI_INLINE_MAX))
return (uint8_t *)event->inline_data;
else
return SPA_MEMBER(port_buffer, event->byte_offset, uint8_t);
return SPA_PTROFF(port_buffer, event->byte_offset, uint8_t);
}
SPA_EXPORT
@ -5146,7 +5146,7 @@ int jack_midi_event_get(jack_midi_event_t *event,
uint32_t event_index)
{
struct midi_buffer *mb = port_buffer;
struct midi_event *ev = SPA_MEMBER(mb, sizeof(*mb), struct midi_event);
struct midi_event *ev = SPA_PTROFF(mb, sizeof(*mb), struct midi_event);
spa_return_val_if_fail(mb != NULL, -EINVAL);
spa_return_val_if_fail(ev != NULL, -EINVAL);
if (event_index >= mb->event_count)
@ -5206,7 +5206,7 @@ jack_midi_data_t* jack_midi_event_reserve(void *port_buffer,
size_t data_size)
{
struct midi_buffer *mb = port_buffer;
struct midi_event *events = SPA_MEMBER(mb, sizeof(*mb), struct midi_event);
struct midi_event *events = SPA_PTROFF(mb, sizeof(*mb), struct midi_event);
size_t buffer_size;
spa_return_val_if_fail(mb != NULL, NULL);
@ -5241,7 +5241,7 @@ jack_midi_data_t* jack_midi_event_reserve(void *port_buffer,
} else {
mb->write_pos += data_size;
ev->byte_offset = buffer_size - 1 - mb->write_pos;
res = SPA_MEMBER(mb, ev->byte_offset, uint8_t);
res = SPA_PTROFF(mb, ev->byte_offset, uint8_t);
}
mb->event_count += 1;
return res;

View file

@ -209,7 +209,7 @@ static int on_source_ready(void *_data, int status)
MAP_PRIVATE, datas[0].fd, 0);
if (map == MAP_FAILED)
return -errno;
sdata = SPA_MEMBER(map, datas[0].mapoffset, uint8_t);
sdata = SPA_PTROFF(map, datas[0].mapoffset, uint8_t);
} else if (datas[0].type == SPA_DATA_MemPtr) {
map = NULL;
sdata = datas[0].data;

View file

@ -202,7 +202,7 @@ static int on_source_ready(void *_data, int status)
MAP_PRIVATE, datas[0].fd, 0);
if (map == MAP_FAILED)
return -errno;
sdata = SPA_MEMBER(map, datas[0].mapoffset, uint8_t);
sdata = SPA_PTROFF(map, datas[0].mapoffset, uint8_t);
} else if (datas[0].type == SPA_DATA_MemPtr) {
map = NULL;
sdata = datas[0].data;

View file

@ -202,11 +202,11 @@ spa_buffer_alloc_layout(struct spa_buffer_alloc_info *info,
struct spa_chunk *cp;
b->n_metas = info->n_metas;
b->metas = SPA_MEMBER(b, sizeof(struct spa_buffer), struct spa_meta);
b->metas = SPA_PTROFF(b, sizeof(struct spa_buffer), struct spa_meta);
b->n_datas = info->n_datas;
b->datas = SPA_MEMBER(b->metas, info->n_metas * sizeof(struct spa_meta), struct spa_data);
b->datas = SPA_PTROFF(b->metas, info->n_metas * sizeof(struct spa_meta), struct spa_data);
skel = SPA_MEMBER(b->datas, info->n_datas * sizeof(struct spa_data), void);
skel = SPA_PTROFF(b->datas, info->n_datas * sizeof(struct spa_data), void);
data = data_mem;
if (SPA_FLAG_IS_SET(info->flags, SPA_BUFFER_ALLOC_FLAG_INLINE_META))
@ -218,17 +218,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 = SPA_MEMBER(*dp, SPA_ROUND_UP_N(m->size, 8), void);
*dp = SPA_PTROFF(*dp, SPA_ROUND_UP_N(m->size, 8), void);
}
size = info->n_datas * sizeof(struct spa_chunk);
if (SPA_FLAG_IS_SET(info->flags, SPA_BUFFER_ALLOC_FLAG_INLINE_CHUNK)) {
cp = (struct spa_chunk*)skel;
skel = SPA_MEMBER(skel, size, void);
skel = SPA_PTROFF(skel, size, void);
}
else {
cp = (struct spa_chunk*)data;
data = SPA_MEMBER(data, size, void);
data = SPA_PTROFF(data, size, void);
}
if (SPA_FLAG_IS_SET(info->flags, SPA_BUFFER_ALLOC_FLAG_INLINE_DATA))
@ -244,7 +244,7 @@ spa_buffer_alloc_layout(struct spa_buffer_alloc_info *info,
if (!SPA_FLAG_IS_SET(info->flags, SPA_BUFFER_ALLOC_FLAG_NO_DATA)) {
*dp = SPA_PTR_ALIGN(*dp, info->data_aligns[i], void);
d->data = *dp;
*dp = SPA_MEMBER(*dp, d->maxsize, void);
*dp = SPA_PTROFF(*dp, d->maxsize, void);
}
}
return b;
@ -277,8 +277,8 @@ spa_buffer_alloc_layout_array(struct spa_buffer_alloc_info *info,
uint32_t i;
for (i = 0; i < n_buffers; i++) {
buffers[i] = spa_buffer_alloc_layout(info, skel_mem, data_mem);
skel_mem = SPA_MEMBER(skel_mem, info->skel_size, void);
data_mem = SPA_MEMBER(data_mem, info->mem_size, void);
skel_mem = SPA_PTROFF(skel_mem, info->skel_size, void);
data_mem = SPA_PTROFF(data_mem, info->mem_size, void);
}
return 0;
}
@ -322,7 +322,7 @@ spa_buffer_alloc_array(uint32_t n_buffers, uint32_t flags,
if (buffers == NULL)
return NULL;
skel = SPA_MEMBER(buffers, sizeof(struct spa_buffer *) * n_buffers, void);
skel = SPA_PTROFF(buffers, sizeof(struct spa_buffer *) * n_buffers, void);
skel = SPA_PTR_ALIGN(skel, info.max_align, void);
spa_buffer_alloc_layout_array(&info, n_buffers, buffers, skel, NULL);

View file

@ -64,8 +64,8 @@ struct spa_meta {
};
#define spa_meta_first(m) ((m)->data)
#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))
#define spa_meta_end(m) SPA_PTROFF((m)->data,(m)->size,void)
#define spa_meta_check(p,m) (SPA_PTROFF(p,sizeof(*p),void) <= spa_meta_end(m))
/**
* Describes essential buffer header metadata such as flags and

View file

@ -183,7 +183,7 @@ static inline int spa_debug_format(int indent,
fprintf(stderr, "%s", ssep);
for (i = 1; i < n_vals; i++) {
vals = SPA_MEMBER(vals, size, void);
vals = SPA_PTROFF(vals, size, void);
if (i > 1)
fprintf(stderr, "%s", sep);
spa_debug_format_value(ti ? ti->values : NULL, type, vals, size);

View file

@ -47,7 +47,7 @@ static inline void spa_result_func_device_params(void *data, int seq, int res,
uint32_t offset = d->builder->state.offset;
spa_pod_builder_raw_padded(d->builder, r->param, SPA_POD_SIZE(r->param));
d->data.next = r->next;
d->data.param = SPA_MEMBER(d->builder->data, offset, struct spa_pod);
d->data.param = SPA_PTROFF(d->builder->data, offset, struct spa_pod);
}
static inline int spa_device_enum_params_sync(struct spa_device *device,

View file

@ -48,7 +48,7 @@ static inline void spa_result_func_node_params(void *data,
uint32_t offset = d->builder->state.offset;
spa_pod_builder_raw_padded(d->builder, r->param, SPA_POD_SIZE(r->param));
d->data.next = r->next;
d->data.param = SPA_MEMBER(d->builder->data, offset, struct spa_pod);
d->data.param = SPA_PTROFF(d->builder->data, offset, struct spa_pod);
}
static inline int spa_node_enum_params_sync(struct spa_node *node,

View file

@ -95,7 +95,7 @@ spa_pod_builder_deref(struct spa_pod_builder *builder, uint32_t offset)
{
uint32_t size = builder->size;
if (offset + 8 <= size) {
struct spa_pod *pod = SPA_MEMBER(builder->data, offset, struct spa_pod);
struct spa_pod *pod = SPA_PTROFF(builder->data, offset, struct spa_pod);
if (offset + SPA_POD_SIZE(pod) <= size)
return pod;
}
@ -106,7 +106,7 @@ static inline struct spa_pod *
spa_pod_builder_frame(struct spa_pod_builder *builder, struct spa_pod_frame *frame)
{
if (frame->offset + SPA_POD_SIZE(&frame->pod) <= builder->size)
return SPA_MEMBER(builder->data, frame->offset, struct spa_pod);
return SPA_PTROFF(builder->data, frame->offset, struct spa_pod);
return NULL;
}
@ -138,7 +138,7 @@ static inline int spa_pod_builder_raw(struct spa_pod_builder *builder, const voi
overflow, 0, offset + size);
}
if (res == 0 && data)
memcpy(SPA_MEMBER(builder->data, offset, void), data, size);
memcpy(SPA_PTROFF(builder->data, offset, void), data, size);
builder->state.offset += size;

View file

@ -50,12 +50,12 @@ static inline int spa_pod_choice_fix_default(struct spa_pod_choice *choice)
case SPA_CHOICE_Range:
case SPA_CHOICE_Step:
if (nvals > 1) {
alt = SPA_MEMBER(alt, size, void);
alt = SPA_PTROFF(alt, size, void);
if (spa_pod_compare_value(type, val, alt, size) < 0)
memcpy(val, alt, size);
}
if (nvals > 2) {
alt = SPA_MEMBER(alt, size, void);
alt = SPA_PTROFF(alt, size, void);
if (spa_pod_compare_value(type, val, alt, size) > 0)
memcpy(val, alt, size);
}
@ -66,7 +66,7 @@ static inline int spa_pod_choice_fix_default(struct spa_pod_choice *choice)
void *best = NULL;
for (i = 1; i < nvals; i++) {
alt = SPA_MEMBER(alt, size, void);
alt = SPA_PTROFF(alt, size, void);
if (spa_pod_compare_value(type, val, alt, size) == 0) {
best = alt;
break;
@ -139,14 +139,14 @@ spa_pod_filter_prop(struct spa_pod_builder *b,
if (p1c == SPA_CHOICE_None || p1c == SPA_CHOICE_Flags) {
nalt1 = 1;
} else {
alt1 = SPA_MEMBER(alt1, size, void);
alt1 = SPA_PTROFF(alt1, size, void);
nalt1--;
}
if (p2c == SPA_CHOICE_None || p2c == SPA_CHOICE_Flags) {
nalt2 = 1;
} else {
alt2 = SPA_MEMBER(alt2, size, void);
alt2 = SPA_PTROFF(alt2, size, void);
nalt2--;
}
@ -164,8 +164,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 = SPA_MEMBER(a1, size, void)) {
for (k = 0, a2 = alt2; k < nalt2; k++, a2 = SPA_MEMBER(a2,size,void)) {
for (j = 0, a1 = alt1; j < nalt1; j++, a1 = SPA_PTROFF(a1, size, void)) {
for (k = 0, a2 = alt2; k < nalt2; k++, a2 = SPA_PTROFF(a2,size,void)) {
if (spa_pod_compare_value(type, a1, a2, size) == 0) {
if (p1c == SPA_CHOICE_Enum || j > 0)
spa_pod_builder_raw(b, a1, size);
@ -182,10 +182,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 = SPA_MEMBER(a1,size,void)) {
for (j = 0, a1 = alt1, a2 = alt2; j < nalt1; j++, a1 = SPA_PTROFF(a1,size,void)) {
if (spa_pod_compare_value(type, a1, a2, size) < 0)
continue;
if (spa_pod_compare_value(type, a1, SPA_MEMBER(a2,size,void), size) > 0)
if (spa_pod_compare_value(type, a1, SPA_PTROFF(a2,size,void), size) > 0)
continue;
spa_pod_builder_raw(b, a1, size);
n_copied++;
@ -204,10 +204,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 = SPA_MEMBER(a2,size,void)) {
for (k = 0, a1 = alt1, a2 = alt2; k < nalt2; k++, a2 = SPA_PTROFF(a2,size,void)) {
if (spa_pod_compare_value(type, a2, a1, size) < 0)
continue;
if (spa_pod_compare_value(type, a2, SPA_MEMBER(a1,size,void), size) > 0)
if (spa_pod_compare_value(type, a2, SPA_PTROFF(a1,size,void), size) > 0)
continue;
spa_pod_builder_raw(b, a2, size);
n_copied++;
@ -226,8 +226,8 @@ spa_pod_filter_prop(struct spa_pod_builder *b,
else
spa_pod_builder_raw(b, alt1, size);
alt1 = SPA_MEMBER(alt1,size,void);
alt2 = SPA_MEMBER(alt2,size,void);
alt1 = SPA_PTROFF(alt1,size,void);
alt2 = SPA_PTROFF(alt2,size,void);
if (spa_pod_compare_value(type, alt1, alt2, size) < 0)
spa_pod_builder_raw(b, alt1, size);
@ -331,9 +331,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, &f);
res = spa_pod_filter_part(b,
SPA_MEMBER(pp,filter_offset,const struct spa_pod),
SPA_PTROFF(pp,filter_offset,const struct spa_pod),
SPA_POD_SIZE(pp) - filter_offset,
SPA_MEMBER(pf,filter_offset,const struct spa_pod),
SPA_PTROFF(pf,filter_offset,const struct spa_pod),
SPA_POD_SIZE(pf) - filter_offset);
spa_pod_builder_pop(b, &f);
do_advance = true;

View file

@ -43,61 +43,61 @@ struct spa_pod_frame {
static inline bool spa_pod_is_inside(const void *pod, uint32_t size, const void *iter)
{
return SPA_POD_BODY(iter) <= SPA_MEMBER(pod, size, void) &&
SPA_MEMBER(iter, SPA_POD_SIZE(iter), void) <= SPA_MEMBER(pod, size, void);
return SPA_POD_BODY(iter) <= SPA_PTROFF(pod, size, void) &&
SPA_PTROFF(iter, SPA_POD_SIZE(iter), void) <= SPA_PTROFF(pod, size, void);
}
static inline void *spa_pod_next(const void *iter)
{
return SPA_MEMBER(iter, SPA_ROUND_UP_N(SPA_POD_SIZE(iter), 8), void);
return SPA_PTROFF(iter, SPA_ROUND_UP_N(SPA_POD_SIZE(iter), 8), void);
}
static inline struct spa_pod_prop *spa_pod_prop_first(const struct spa_pod_object_body *body)
{
return SPA_MEMBER(body, sizeof(struct spa_pod_object_body), struct spa_pod_prop);
return SPA_PTROFF(body, sizeof(struct spa_pod_object_body), struct spa_pod_prop);
}
static inline bool spa_pod_prop_is_inside(const struct spa_pod_object_body *body,
uint32_t size, const struct spa_pod_prop *iter)
{
return SPA_POD_CONTENTS(struct spa_pod_prop, iter) <= SPA_MEMBER(body, size, void) &&
SPA_MEMBER(iter, SPA_POD_PROP_SIZE(iter), void) <= SPA_MEMBER(body, size, void);
return SPA_POD_CONTENTS(struct spa_pod_prop, iter) <= SPA_PTROFF(body, size, void) &&
SPA_PTROFF(iter, SPA_POD_PROP_SIZE(iter), void) <= SPA_PTROFF(body, size, void);
}
static inline struct spa_pod_prop *spa_pod_prop_next(const struct spa_pod_prop *iter)
{
return SPA_MEMBER(iter, SPA_ROUND_UP_N(SPA_POD_PROP_SIZE(iter), 8), struct spa_pod_prop);
return SPA_PTROFF(iter, SPA_ROUND_UP_N(SPA_POD_PROP_SIZE(iter), 8), struct spa_pod_prop);
}
static inline struct spa_pod_control *spa_pod_control_first(const struct spa_pod_sequence_body *body)
{
return SPA_MEMBER(body, sizeof(struct spa_pod_sequence_body), struct spa_pod_control);
return SPA_PTROFF(body, sizeof(struct spa_pod_sequence_body), struct spa_pod_control);
}
static inline bool spa_pod_control_is_inside(const struct spa_pod_sequence_body *body,
uint32_t size, const struct spa_pod_control *iter)
{
return SPA_POD_CONTENTS(struct spa_pod_control, iter) <= SPA_MEMBER(body, size, void) &&
SPA_MEMBER(iter, SPA_POD_CONTROL_SIZE(iter), void) <= SPA_MEMBER(body, size, void);
return SPA_POD_CONTENTS(struct spa_pod_control, iter) <= SPA_PTROFF(body, size, void) &&
SPA_PTROFF(iter, SPA_POD_CONTROL_SIZE(iter), void) <= SPA_PTROFF(body, size, void);
}
static inline struct spa_pod_control *spa_pod_control_next(const struct spa_pod_control *iter)
{
return SPA_MEMBER(iter, SPA_ROUND_UP_N(SPA_POD_CONTROL_SIZE(iter), 8), struct spa_pod_control);
return SPA_PTROFF(iter, SPA_ROUND_UP_N(SPA_POD_CONTROL_SIZE(iter), 8), struct spa_pod_control);
}
#define SPA_POD_ARRAY_BODY_FOREACH(body, _size, 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))
for ((iter) = (__typeof__(iter))SPA_PTROFF((body), sizeof(struct spa_pod_array_body), void); \
(iter) < (__typeof__(iter))SPA_PTROFF((body), (_size), void); \
(iter) = (__typeof__(iter))SPA_PTROFF((iter), (body)->child.size, void))
#define SPA_POD_ARRAY_FOREACH(obj, iter) \
SPA_POD_ARRAY_BODY_FOREACH(&(obj)->body, SPA_POD_BODY_SIZE(obj), iter)
#define SPA_POD_CHOICE_BODY_FOREACH(body, _size, 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))
for ((iter) = (__typeof__(iter))SPA_PTROFF((body), sizeof(struct spa_pod_choice_body), void); \
(iter) < (__typeof__(iter))SPA_PTROFF((body), (_size), void); \
(iter) = (__typeof__(iter))SPA_PTROFF((iter), (body)->child.size, void))
#define SPA_POD_CHOICE_FOREACH(obj, iter) \
SPA_POD_CHOICE_BODY_FOREACH(&(obj)->body, SPA_POD_BODY_SIZE(obj), iter)
@ -132,7 +132,7 @@ static inline void *spa_pod_from_data(void *data, size_t maxsize, off_t offset,
void *pod;
if (size < sizeof(struct spa_pod) || offset + size > maxsize)
return NULL;
pod = SPA_MEMBER(data, offset, void);
pod = SPA_PTROFF(data, offset, void);
if (SPA_POD_SIZE(pod) > size)
return NULL;
return pod;

View file

@ -78,7 +78,7 @@ static inline struct spa_pod *
spa_pod_parser_deref(struct spa_pod_parser *parser, uint32_t offset, uint32_t size)
{
if (offset + 8 <= size) {
struct spa_pod *pod = SPA_MEMBER(parser->data, offset, struct spa_pod);
struct spa_pod *pod = SPA_PTROFF(parser->data, offset, struct spa_pod);
if (offset + SPA_POD_SIZE(pod) <= size)
return pod;
}
@ -87,7 +87,7 @@ spa_pod_parser_deref(struct spa_pod_parser *parser, uint32_t offset, uint32_t si
static inline struct spa_pod *spa_pod_parser_frame(struct spa_pod_parser *parser, struct spa_pod_frame *frame)
{
return SPA_MEMBER(parser->data, frame->offset, struct spa_pod);
return SPA_PTROFF(parser->data, frame->offset, struct spa_pod);
}
static inline void spa_pod_parser_push(struct spa_pod_parser *parser,

View file

@ -37,10 +37,10 @@ extern "C" {
#define SPA_POD_SIZE(pod) (sizeof(struct spa_pod) + SPA_POD_BODY_SIZE(pod))
#define SPA_POD_CONTENTS_SIZE(type,pod) (SPA_POD_SIZE(pod)-sizeof(type))
#define SPA_POD_CONTENTS(type,pod) SPA_MEMBER((pod),sizeof(type),void)
#define SPA_POD_CONTENTS_CONST(type,pod) SPA_MEMBER((pod),sizeof(type),const void)
#define SPA_POD_BODY(pod) SPA_MEMBER((pod),sizeof(struct spa_pod),void)
#define SPA_POD_BODY_CONST(pod) SPA_MEMBER((pod),sizeof(struct spa_pod),const void)
#define SPA_POD_CONTENTS(type,pod) SPA_PTROFF((pod),sizeof(type),void)
#define SPA_POD_CONTENTS_CONST(type,pod) SPA_PTROFF((pod),sizeof(type),const void)
#define SPA_POD_BODY(pod) SPA_PTROFF((pod),sizeof(struct spa_pod),void)
#define SPA_POD_BODY_CONST(pod) SPA_PTROFF((pod),sizeof(struct spa_pod),const void)
struct spa_pod {
uint32_t size; /* size of the body */

View file

@ -132,8 +132,19 @@ struct spa_fraction {
x; \
})
#define SPA_MEMBER(b,o,t) ((t*)((uint8_t*)(b) + (int)(o)))
#define SPA_MEMBER_ALIGN(b,o,a,t) SPA_PTR_ALIGN(SPA_MEMBER(b,o,t),a,t)
/**
* Return the address (buffer + offset) as pointer of \a type
*/
#define SPA_PTROFF(ptr_,offset_,type_) ((type_*)((uint8_t*)(ptr_) + (int)(offset_)))
#define SPA_PTROFF_ALIGN(ptr_,offset_,alignment_,type_) \
SPA_PTR_ALIGN(SPA_PTROFF(ptr_,offset_,type_),alignment_,type_)
/**
* Deprecated, use SPA_PTROFF and SPA_PTROFF_ALIGN instead
*/
#define SPA_MEMBER(b,o,t) SPA_PTROFF(b,o,t)
#define SPA_MEMBER_ALIGN(b,o,a,t) SPA_PTROFF_ALIGN(b,o,a,t)
#define SPA_CONTAINER_OF(p,t,m) (t*)((uint8_t*)p - offsetof (t,m))

View file

@ -100,9 +100,9 @@ spa_ringbuffer_read_data(struct spa_ringbuffer *rbuf,
uint32_t offset, void *data, uint32_t len)
{
uint32_t l0 = SPA_MIN(len, size - offset), l1 = len - l0;
spa_memcpy(data, SPA_MEMBER(buffer, offset, void), l0);
spa_memcpy(data, SPA_PTROFF(buffer, offset, void), l0);
if (SPA_UNLIKELY(l1 > 0))
spa_memcpy(SPA_MEMBER(data, l0, void), buffer, l1);
spa_memcpy(SPA_PTROFF(data, l0, void), buffer, l1);
}
/**
@ -150,9 +150,9 @@ spa_ringbuffer_write_data(struct spa_ringbuffer *rbuf,
uint32_t offset, const void *data, uint32_t len)
{
uint32_t l0 = SPA_MIN(len, size - offset), l1 = len - l0;
spa_memcpy(SPA_MEMBER(buffer, offset, void), data, l0);
spa_memcpy(SPA_PTROFF(buffer, offset, void), data, l0);
if (SPA_UNLIKELY(l1 > 0))
spa_memcpy(buffer, SPA_MEMBER(data, l0, void), l1);
spa_memcpy(buffer, SPA_PTROFF(data, l0, void), l1);
}
/**

View file

@ -1004,7 +1004,7 @@ again:
if (SPA_LIKELY(state->use_mmap)) {
for (i = 0; i < b->buf->n_datas; i++) {
dst = SPA_MEMBER(my_areas[i].addr, off * state->frame_size, uint8_t);
dst = SPA_PTROFF(my_areas[i].addr, off * state->frame_size, uint8_t);
src = d[i].data;
spa_memcpy(dst, src + offs, l0);
@ -1016,7 +1016,7 @@ again:
void *bufs[b->buf->n_datas];
for (i = 0; i < b->buf->n_datas; i++)
bufs[i] = SPA_MEMBER(d[i].data, offs, void);
bufs[i] = SPA_PTROFF(d[i].data, offs, void);
snd_pcm_writen(hndl, bufs, l0 / state->frame_size);
if (SPA_UNLIKELY(l1 > 0)) {
for (i = 0; i < b->buf->n_datas; i++)
@ -1127,10 +1127,10 @@ push_frames(struct state *state,
l1 = n_bytes - l0;
for (i = 0; i < b->buf->n_datas; i++) {
src = SPA_MEMBER(my_areas[i].addr, offset * state->frame_size, uint8_t);
src = SPA_PTROFF(my_areas[i].addr, offset * state->frame_size, uint8_t);
spa_memcpy(d[i].data, src, l0);
if (l1 > 0)
spa_memcpy(SPA_MEMBER(d[i].data, l0, void), my_areas[i].addr, l1);
spa_memcpy(SPA_PTROFF(d[i].data, l0, void), my_areas[i].addr, l1);
d[i].chunk->offset = 0;
d[i].chunk->size = n_bytes;
d[i].chunk->stride = state->frame_size;

View file

@ -459,10 +459,10 @@ static void impl_on_notify_events(struct spa_source *source)
if (len <= 0)
break;
e = SPA_MEMBER(&buf, len, void);
e = SPA_PTROFF(&buf, len, void);
for (p = &buf; p < e;
p = SPA_MEMBER(p, sizeof(struct inotify_event) + event->len, void)) {
p = SPA_PTROFF(p, sizeof(struct inotify_event) + event->len, void)) {
unsigned int id;
struct device *device;

View file

@ -1196,7 +1196,7 @@ impl_init(const struct spa_handle_factory *factory,
SPA_VERSION_NODE,
&impl_node, this);
this->hnd_convert = SPA_MEMBER(this, sizeof(struct impl), struct spa_handle);
this->hnd_convert = SPA_PTROFF(this, sizeof(struct impl), struct spa_handle);
spa_handle_factory_init(&spa_audioconvert_factory,
this->hnd_convert,
info, support, n_support);

View file

@ -1288,37 +1288,37 @@ impl_init(const struct spa_handle_factory *factory,
this->info.params = this->params;
this->info.n_params = 4;
this->hnd_merger = SPA_MEMBER(this, sizeof(struct impl), struct spa_handle);
this->hnd_merger = SPA_PTROFF(this, sizeof(struct impl), struct spa_handle);
spa_handle_factory_init(&spa_merger_factory,
this->hnd_merger,
info, support, n_support);
size = spa_handle_factory_get_size(&spa_merger_factory, info);
this->hnd_convert_in = SPA_MEMBER(this->hnd_merger, size, struct spa_handle);
this->hnd_convert_in = SPA_PTROFF(this->hnd_merger, size, struct spa_handle);
spa_handle_factory_init(&spa_fmtconvert_factory,
this->hnd_convert_in,
info, support, n_support);
size = spa_handle_factory_get_size(&spa_fmtconvert_factory, info);
this->hnd_channelmix = SPA_MEMBER(this->hnd_convert_in, size, struct spa_handle);
this->hnd_channelmix = SPA_PTROFF(this->hnd_convert_in, size, struct spa_handle);
spa_handle_factory_init(&spa_channelmix_factory,
this->hnd_channelmix,
info, support, n_support);
size = spa_handle_factory_get_size(&spa_channelmix_factory, info);
this->hnd_resample = SPA_MEMBER(this->hnd_channelmix, size, struct spa_handle);
this->hnd_resample = SPA_PTROFF(this->hnd_channelmix, size, struct spa_handle);
spa_handle_factory_init(&spa_resample_factory,
this->hnd_resample,
info, support, n_support);
size = spa_handle_factory_get_size(&spa_resample_factory, info);
this->hnd_convert_out = SPA_MEMBER(this->hnd_resample, size, struct spa_handle);
this->hnd_convert_out = SPA_PTROFF(this->hnd_resample, size, struct spa_handle);
spa_handle_factory_init(&spa_fmtconvert_factory,
this->hnd_convert_out,
info, support, n_support);
size = spa_handle_factory_get_size(&spa_fmtconvert_factory, info);
this->hnd_splitter = SPA_MEMBER(this->hnd_convert_out, size, struct spa_handle);
this->hnd_splitter = SPA_PTROFF(this->hnd_convert_out, size, struct spa_handle);
spa_handle_factory_init(&spa_splitter_factory,
this->hnd_splitter,
info, support, n_support);

View file

@ -891,7 +891,7 @@ static int impl_node_process(void *object)
struct spa_data *sd = &inb->datas[src_remap];
offs = SPA_MIN(sd->chunk->offset, sd->maxsize);
size = SPA_MIN(size, SPA_MIN(sd->maxsize - offs, sd->chunk->size));
src_datas[i] = SPA_MEMBER(sd->data, offs, void);
src_datas[i] = SPA_PTROFF(sd->data, offs, void);
}
n_samples = size / inport->stride;

View file

@ -1267,7 +1267,7 @@ static int impl_node_process(void *object)
sd = &sbuf->buf->datas[0];
src_datas[i] = SPA_MEMBER(sd->data, sd->chunk->offset, void);
src_datas[i] = SPA_PTROFF(sd->data, sd->chunk->offset, void);
n_samples = SPA_MIN(n_samples, sd->chunk->size / inport->stride);

View file

@ -370,13 +370,13 @@ int resample_native_init(struct resample *r)
d->n_phases = n_phases;
d->in_rate = in_rate;
d->out_rate = out_rate;
d->filter = SPA_MEMBER_ALIGN(d, sizeof(struct native_data), 64, float);
d->hist_mem = SPA_MEMBER_ALIGN(d->filter, filter_size, 64, float);
d->history = SPA_MEMBER(d->hist_mem, history_size, float*);
d->filter = SPA_PTROFF_ALIGN(d, sizeof(struct native_data), 64, float);
d->hist_mem = SPA_PTROFF_ALIGN(d->filter, filter_size, 64, float);
d->history = SPA_PTROFF(d->hist_mem, history_size, float*);
d->filter_stride = filter_stride / sizeof(float);
d->filter_stride_os = d->filter_stride * oversample;
for (c = 0; c < r->channels; c++)
d->history[c] = SPA_MEMBER(d->hist_mem, c * history_stride, float);
d->history[c] = SPA_PTROFF(d->hist_mem, c * history_stride, float);
build_filter(d->filter, d->filter_stride, n_taps, n_phases, scale);

View file

@ -849,10 +849,10 @@ static int impl_node_process(void *object)
flush_in = draining = true;
} else {
for (i = 0; i < sb->n_datas; i++)
src_datas[i] = SPA_MEMBER(sb->datas[i].data, inport->offset, void);
src_datas[i] = SPA_PTROFF(sb->datas[i].data, inport->offset, void);
}
for (i = 0; i < db->n_datas; i++)
dst_datas[i] = SPA_MEMBER(db->datas[i].data, outport->offset, void);
dst_datas[i] = SPA_PTROFF(db->datas[i].data, outport->offset, void);
in_len = (size - inport->offset) / sizeof(float);
out_len = (maxsize - outport->offset) / sizeof(float);

View file

@ -920,7 +920,7 @@ static int impl_node_process(void *object)
maxsize = INT_MAX;
for (i = 0; i < n_src_datas; i++) {
src_datas[i] = SPA_MEMBER(sd[i].data,
src_datas[i] = SPA_PTROFF(sd[i].data,
sd[i].chunk->offset, void);
maxsize = SPA_MIN(sd[i].chunk->size, maxsize);
}

View file

@ -658,10 +658,10 @@ add_port_data(struct impl *this, void *out, size_t outsize, struct port *port, i
n_src = 0;
if (layer > 0) {
s0[n_src] = out;
s1[n_src] = SPA_MEMBER(out, len1, void);
s1[n_src] = SPA_PTROFF(out, len1, void);
n_src++;
}
s0[n_src] = SPA_MEMBER(data, offset, void);
s0[n_src] = SPA_PTROFF(data, offset, void);
s1[n_src] = data;
n_src++;
@ -671,7 +671,7 @@ add_port_data(struct impl *this, void *out, size_t outsize, struct port *port, i
else {
mix_ops_process(&this->ops, out, s0, n_src, len1);
if (len2 > 0)
mix_ops_process(&this->ops, SPA_MEMBER(out, len1, void), s1, n_src, len2);
mix_ops_process(&this->ops, SPA_PTROFF(out, len1, void), s1, n_src, len2);
}
port->queued_bytes -= outsize;
@ -733,7 +733,7 @@ static int mix_output(struct impl *this, size_t n_bytes)
continue;
}
add_port_data(this, SPA_MEMBER(od[0].data, offset, void), len1, in_port, layer);
add_port_data(this, SPA_PTROFF(od[0].data, offset, void), len1, in_port, layer);
if (len2 > 0)
add_port_data(this, od[0].data, len2, in_port, layer);
layer++;

View file

@ -401,7 +401,7 @@ static int make_buffer(struct impl *this)
l0 = SPA_MIN(n_bytes, maxsize - offset) / port->bpf;
l1 = n_samples - l0;
port->render_func(this, SPA_MEMBER(data, offset, void), l0);
port->render_func(this, SPA_PTROFF(data, offset, void), l0);
if (l1 > 0)
port->render_func(this, data, l1);

View file

@ -534,7 +534,7 @@ static int codec_start_encode (void *data,
struct impl *this = data;
this->header = (struct rtp_header *)dst;
this->payload = SPA_MEMBER(dst, sizeof(struct rtp_header), struct rtp_payload);
this->payload = SPA_PTROFF(dst, sizeof(struct rtp_header), struct rtp_payload);
memset(this->header, 0, sizeof(struct rtp_header)+sizeof(struct rtp_payload));
this->payload->frame_count = 0;

View file

@ -577,7 +577,7 @@ static int codec_start_encode (void *data,
struct impl *this = data;
this->header = (struct rtp_header *)dst;
this->payload = SPA_MEMBER(dst, sizeof(struct rtp_header), struct rtp_payload);
this->payload = SPA_PTROFF(dst, sizeof(struct rtp_header), struct rtp_payload);
memset(this->header, 0, sizeof(struct rtp_header)+sizeof(struct rtp_payload));
this->payload->frame_count = 0;

View file

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

View file

@ -1468,7 +1468,7 @@ struct spa_bt_transport *spa_bt_transport_create(struct spa_bt_monitor *monitor,
t->fd = -1;
t->sco_io = NULL;
t->delay = SPA_BT_UNKNOWN_DELAY;
t->user_data = SPA_MEMBER(t, sizeof(struct spa_bt_transport), void);
t->user_data = SPA_PTROFF(t, sizeof(struct spa_bt_transport), void);
spa_hook_list_init(&t->listener_list);
spa_list_append(&monitor->transport_list, &t->link);

View file

@ -120,7 +120,7 @@ static int spa_libcamera_clear_buffers(struct impl *this)
spa_libcamera_buffer_recycle(this, i);
}
if (SPA_FLAG_IS_SET(b->flags, BUFFER_FLAG_MAPPED)) {
munmap(SPA_MEMBER(b->ptr, -d[0].mapoffset, void),
munmap(SPA_PTROFF(b->ptr, -d[0].mapoffset, void),
d[0].maxsize - d[0].mapoffset);
}
if (SPA_FLAG_IS_SET(b->flags, BUFFER_FLAG_ALLOCATED)) {

View file

@ -134,7 +134,7 @@ static void flush_items(struct impl *impl)
struct invoke_item *item;
bool block;
item = SPA_MEMBER(impl->buffer_data, index & (DATAS_SIZE - 1), struct invoke_item);
item = SPA_PTROFF(impl->buffer_data, index & (DATAS_SIZE - 1), struct invoke_item);
block = item->block;
spa_log_trace(impl->log, NAME " %p: flush item %p", impl, item);
@ -183,7 +183,7 @@ loop_invoke(void *object,
l0 = DATAS_SIZE - offset;
item = SPA_MEMBER(impl->buffer_data, offset, struct invoke_item);
item = SPA_PTROFF(impl->buffer_data, offset, struct invoke_item);
item->func = func;
item->seq = seq;
item->size = size;
@ -193,7 +193,7 @@ loop_invoke(void *object,
spa_log_trace(impl->log, NAME " %p: add item %p filled:%d", impl, item, filled);
if (l0 > sizeof(struct invoke_item) + size) {
item->data = SPA_MEMBER(item, sizeof(struct invoke_item), void);
item->data = SPA_PTROFF(item, sizeof(struct invoke_item), void);
item->item_size = SPA_ROUND_UP_N(sizeof(struct invoke_item) + size, 8);
if (l0 < sizeof(struct invoke_item) + item->item_size)
item->item_size = l0;

View file

@ -427,7 +427,7 @@ static int port_get_format(struct impl *this, struct port *port,
if (index > 0)
return 0;
*param = SPA_MEMBER(port->format_buffer, 0, struct spa_pod);
*param = SPA_PTROFF(port->format_buffer, 0, struct spa_pod);
return 1;
}

View file

@ -440,7 +440,7 @@ static int port_get_format(struct impl *this, struct port *port,
if (index > 0)
return 0;
*param = SPA_MEMBER(port->format_buffer, 0, struct spa_pod);
*param = SPA_PTROFF(port->format_buffer, 0, struct spa_pod);
return 1;
}

View file

@ -406,10 +406,10 @@ static void impl_on_notify_events(struct spa_source *source)
if (len <= 0)
break;
e = SPA_MEMBER(&buf, len, void);
e = SPA_PTROFF(&buf, len, void);
for (p = &buf; p < e;
p = SPA_MEMBER(p, sizeof(struct inotify_event) + event->len, void)) {
p = SPA_PTROFF(p, sizeof(struct inotify_event) + event->len, void)) {
unsigned int id;
struct device *device;

View file

@ -893,7 +893,7 @@ impl_init(const struct spa_handle_factory *factory,
spa_hook_list_init(&this->hooks);
#if 0
this->hnd_convert = SPA_MEMBER(this, sizeof(struct impl), struct spa_handle);
this->hnd_convert = SPA_PTROFF(this, sizeof(struct impl), struct spa_handle);
spa_handle_factory_init(&spa_videoconvert_factory,
this->hnd_convert,
info, support, n_support);

View file

@ -648,8 +648,8 @@ static void do_volume(struct impl *this, struct spa_buffer *dbuf, struct spa_buf
uint32_t soffset = sindex % sd[0].maxsize;
uint32_t doffset = dindex % dd[0].maxsize;
src = SPA_MEMBER(sd[0].data, soffset, int16_t);
dst = SPA_MEMBER(dd[0].data, doffset, int16_t);
src = SPA_PTROFF(sd[0].data, soffset, int16_t);
dst = SPA_PTROFF(dd[0].data, doffset, int16_t);
n_bytes = SPA_MIN(towrite, sd[0].maxsize - soffset);
n_bytes = SPA_MIN(n_bytes, dd[0].maxsize - doffset);

View file

@ -133,6 +133,8 @@ static void test_abi(void)
static void test_macros(void)
{
uint8_t ptr[64];
spa_assert(SPA_MIN(1, 2) == 1);
spa_assert(SPA_MIN(1, -2) == -2);
spa_assert(SPA_MAX(1, 2) == 2);
@ -140,6 +142,14 @@ static void test_macros(void)
spa_assert(SPA_CLAMP(23, 1, 16) == 16);
spa_assert(SPA_CLAMP(-1, 1, 16) == 1);
spa_assert(SPA_CLAMP(8, 1, 16) == 8);
/* SPA_MEMBER exists for backwards compatibility but should no
* longer be used, let's make sure it does what we expect it to */
spa_assert(SPA_MEMBER(ptr, 4, void) == SPA_PTROFF(ptr, 4, void));
spa_assert(SPA_MEMBER(ptr, 32, void) == SPA_PTROFF(ptr, 32, void));
spa_assert(SPA_MEMBER(ptr, 0, void) == SPA_PTROFF(ptr, 0, void));
spa_assert(SPA_MEMBER_ALIGN(ptr, 0, 4, void) == SPA_PTROFF_ALIGN(ptr, 0, 4, void));
spa_assert(SPA_MEMBER_ALIGN(ptr, 4, 32, void) == SPA_PTROFF_ALIGN(ptr, 4, 32, void));
}
static void test_result(void)

View file

@ -375,7 +375,7 @@ static int do_render(struct spa_loop *loop, bool async, uint32_t seq,
buf->datas[0].type == SPA_DATA_DmaBuf) {
map = mmap(NULL, buf->datas[0].maxsize + buf->datas[0].mapoffset, PROT_READ,
MAP_PRIVATE, buf->datas[0].fd, 0);
sdata = SPA_MEMBER(map, buf->datas[0].mapoffset, uint8_t);
sdata = SPA_PTROFF(map, buf->datas[0].mapoffset, uint8_t);
} else if (buf->datas[0].type == SPA_DATA_MemPtr) {
map = NULL;
sdata = buf->datas[0].data;

View file

@ -330,7 +330,7 @@ static int impl_port_use_buffers(void *object,
return -errno;
}
b->ptr = SPA_MEMBER(b->ptr, datas[0].mapoffset, void);
b->ptr = SPA_PTROFF(b->ptr, datas[0].mapoffset, void);
b->mapped = true;
}
else {
@ -435,9 +435,9 @@ static int impl_node_process(void *object)
avail = maxsize - offset;
if (d->format.format == SPA_AUDIO_FORMAT_S16)
fill_s16(d, SPA_MEMBER(b->ptr, offset, void), avail);
fill_s16(d, SPA_PTROFF(b->ptr, offset, void), avail);
else if (d->format.format == SPA_AUDIO_FORMAT_F32)
fill_f32(d, SPA_MEMBER(b->ptr, offset, void), avail);
fill_f32(d, SPA_PTROFF(b->ptr, offset, void), avail);
od[0].chunk->offset = 0;
od[0].chunk->size = avail;

View file

@ -271,7 +271,7 @@ static int do_render(struct spa_loop *loop, bool async, uint32_t seq,
buf->datas[0].type == SPA_DATA_DmaBuf) {
map = mmap(NULL, buf->datas[0].maxsize + buf->datas[0].mapoffset, PROT_READ,
MAP_PRIVATE, buf->datas[0].fd, 0);
sdata = SPA_MEMBER(map, buf->datas[0].mapoffset, uint8_t);
sdata = SPA_PTROFF(map, buf->datas[0].mapoffset, uint8_t);
} else if (buf->datas[0].type == SPA_DATA_MemPtr) {
map = NULL;
sdata = buf->datas[0].data;

View file

@ -104,10 +104,10 @@ static void on_notify_events(void *data, int fd, uint32_t mask)
if (len <= 0)
break;
e = SPA_MEMBER(&buf, len, void);
e = SPA_PTROFF(&buf, len, void);
for (p = &buf; p < e;
p = SPA_MEMBER(p, sizeof(struct inotify_event) + event->len, void)) {
p = SPA_PTROFF(p, sizeof(struct inotify_event) + event->len, void)) {
event = (const struct inotify_event *) p;
if ((event->mask & IN_ATTRIB)) {

View file

@ -271,7 +271,7 @@ void *sm_object_add_data(struct sm_object *obj, const char *id, size_t size)
spa_list_append(&obj->data, &d->link);
done:
return SPA_MEMBER(d, sizeof(struct data), void);
return SPA_PTROFF(d, sizeof(struct data), void);
}
void *sm_object_get_data(struct sm_object *obj, const char *id)
@ -280,7 +280,7 @@ void *sm_object_get_data(struct sm_object *obj, const char *id)
d = object_find_data(obj, id);
if (d == NULL)
return NULL;
return SPA_MEMBER(d, sizeof(struct data), void);
return SPA_PTROFF(d, sizeof(struct data), void);
}
int sm_object_remove_data(struct sm_object *obj, const char *id)
@ -390,7 +390,7 @@ static struct param *add_param(struct spa_list *param_list,
return NULL;
p->this.id = id;
p->this.param = SPA_MEMBER(p, sizeof(struct param), struct spa_pod);
p->this.param = SPA_PTROFF(p, sizeof(struct param), struct spa_pod);
memcpy(p->this.param, param, SPA_POD_SIZE(param));
spa_list_append(param_list, &p->this.link);

View file

@ -146,7 +146,7 @@ on_process(void *_data)
data->cursor_rect.x = mcs->position.x;
data->cursor_rect.y = mcs->position.y;
mb = SPA_MEMBER(mcs, mcs->bitmap_offset, struct spa_meta_bitmap);
mb = SPA_PTROFF(mcs, mcs->bitmap_offset, struct spa_meta_bitmap);
data->cursor_rect.w = mb->size.width;
data->cursor_rect.h = mb->size.height;
@ -165,7 +165,7 @@ on_process(void *_data)
}
/* copy the cursor bitmap into the texture */
src = SPA_MEMBER(mb, mb->offset, uint8_t);
src = SPA_PTROFF(mb, mb->offset, uint8_t);
dst = cdata;
ostride = SPA_MIN(cstride, mb->stride);
@ -186,9 +186,9 @@ on_process(void *_data)
NULL,
sdata,
sstride,
SPA_MEMBER(sdata, sstride * data->size.height, void),
SPA_PTROFF(sdata, sstride * data->size.height, void),
sstride / 2,
SPA_MEMBER(sdata, 5 * (sstride * data->size.height) / 4, void),
SPA_PTROFF(sdata, 5 * (sstride * data->size.height) / 4, void),
sstride / 2);
}
else {

View file

@ -145,14 +145,14 @@ static void on_timeout(void *userdata, uint64_t expirations)
mcs->hotspot.y = 0;
mcs->bitmap_offset = sizeof(struct spa_meta_cursor);
mb = SPA_MEMBER(mcs, mcs->bitmap_offset, struct spa_meta_bitmap);
mb = SPA_PTROFF(mcs, mcs->bitmap_offset, struct spa_meta_bitmap);
mb->format = SPA_VIDEO_FORMAT_ARGB;
mb->size.width = CURSOR_WIDTH;
mb->size.height = CURSOR_HEIGHT;
mb->stride = CURSOR_WIDTH * CURSOR_BPP;
mb->offset = sizeof(struct spa_meta_bitmap);
bitmap = SPA_MEMBER(mb, mb->offset, uint32_t);
bitmap = SPA_PTROFF(mb, mb->offset, uint32_t);
color = (cos(data->accumulator) + 1.0) * (1 << 23);
color |= 0xff000000;

View file

@ -147,14 +147,14 @@ static void on_timeout(void *userdata, uint64_t expirations)
mcs->hotspot.y = 0;
mcs->bitmap_offset = sizeof(struct spa_meta_cursor);
mb = SPA_MEMBER(mcs, mcs->bitmap_offset, struct spa_meta_bitmap);
mb = SPA_PTROFF(mcs, mcs->bitmap_offset, struct spa_meta_bitmap);
mb->format = SPA_VIDEO_FORMAT_ARGB;
mb->size.width = CURSOR_WIDTH;
mb->size.height = CURSOR_HEIGHT;
mb->stride = CURSOR_WIDTH * CURSOR_BPP;
mb->offset = sizeof(struct spa_meta_bitmap);
bitmap = SPA_MEMBER(mb, mb->offset, uint32_t);
bitmap = SPA_PTROFF(mb, mb->offset, uint32_t);
color = (cos(data->accumulator) + 1.0) * (1 << 23);
color |= 0xff000000;

View file

@ -143,14 +143,14 @@ static void on_timeout(void *userdata, uint64_t expirations)
mcs->hotspot.y = 0;
mcs->bitmap_offset = sizeof(struct spa_meta_cursor);
mb = SPA_MEMBER(mcs, mcs->bitmap_offset, struct spa_meta_bitmap);
mb = SPA_PTROFF(mcs, mcs->bitmap_offset, struct spa_meta_bitmap);
mb->format = SPA_VIDEO_FORMAT_ARGB;
mb->size.width = CURSOR_WIDTH;
mb->size.height = CURSOR_HEIGHT;
mb->stride = CURSOR_WIDTH * CURSOR_BPP;
mb->offset = sizeof(struct spa_meta_bitmap);
bitmap = SPA_MEMBER(mb, mb->offset, uint32_t);
bitmap = SPA_PTROFF(mb, mb->offset, uint32_t);
color = (cos(data->accumulator) + 1.0) * (1 << 23);
color |= 0xff000000;

View file

@ -577,7 +577,7 @@ convert_1 (ConvertData *d)
spa_pod_builder_pop (&d->b, &f);
return SPA_MEMBER (d->b.data, 0, struct spa_pod);
return SPA_PTROFF (d->b.data, 0, struct spa_pod);
}
struct spa_pod *

View file

@ -292,7 +292,7 @@ struct pw_impl_node *pw_adapter_new(struct pw_context *context,
spa_list_init(&n->ports);
if (user_data_size > 0)
n->user_data = SPA_MEMBER(n, sizeof(struct node), void);
n->user_data = SPA_PTROFF(n, sizeof(struct node), void);
pw_impl_node_add_listener(node, &n->node_listener, &node_events, n);

View file

@ -72,7 +72,7 @@ struct pw_proxy *pw_core_spa_device_export(struct pw_core *core,
return NULL;
data = pw_proxy_get_user_data(proxy);
data = SPA_MEMBER(data, user_data_size, struct device_data);
data = SPA_PTROFF(data, user_data_size, struct device_data);
data->device = device;
data->proxy = proxy;

View file

@ -798,14 +798,14 @@ do_port_use_buffers(struct impl *impl,
if ((mem = pw_mempool_find_ptr(impl->context->pool, baseptr)) == NULL)
return -EINVAL;
endptr = SPA_MEMBER(baseptr, buffers[i]->n_datas * sizeof(struct spa_chunk), void);
endptr = SPA_PTROFF(baseptr, buffers[i]->n_datas * sizeof(struct spa_chunk), void);
for (j = 0; j < buffers[i]->n_metas; j++) {
endptr = SPA_MEMBER(endptr, SPA_ROUND_UP_N(buffers[i]->metas[j].size, 8), void);
endptr = SPA_PTROFF(endptr, SPA_ROUND_UP_N(buffers[i]->metas[j].size, 8), void);
}
for (j = 0; j < buffers[i]->n_datas; j++) {
struct spa_data *d = buffers[i]->datas;
if (d->type == SPA_DATA_MemPtr)
endptr = SPA_MEMBER(d->data, d->maxsize, void);
endptr = SPA_PTROFF(d->data, d->maxsize, void);
}
m = pw_mempool_import_block(this->client->pool, mem);
@ -1375,7 +1375,7 @@ static int port_init_mix(void *data, struct pw_impl_port_mix *mix)
if (mix->id == SPA_ID_INVALID)
return -errno;
mix->io = SPA_MEMBER(impl->io_areas->map->ptr,
mix->io = SPA_PTROFF(impl->io_areas->map->ptr,
mix->id * sizeof(struct spa_io_buffers), void);
*mix->io = SPA_IO_BUFFERS_INIT;

View file

@ -672,8 +672,8 @@ client_node_port_use_buffers(void *object,
}
memcpy(b, buffers[i].buffer, sizeof(struct spa_buffer));
b->metas = SPA_MEMBER(b, sizeof(struct spa_buffer), struct spa_meta);
b->datas = SPA_MEMBER(b->metas, sizeof(struct spa_meta) * b->n_metas,
b->metas = SPA_PTROFF(b, sizeof(struct spa_buffer), struct spa_meta);
b->datas = SPA_PTROFF(b->metas, sizeof(struct spa_meta) * b->n_metas,
struct spa_data);
pw_log_debug("add buffer mem:%d id:%d offset:%u size:%u %p", mm->block->id,
@ -683,7 +683,7 @@ client_node_port_use_buffers(void *object,
for (j = 0; j < b->n_metas; j++) {
struct spa_meta *m = &b->metas[j];
memcpy(m, &buffers[i].buffer->metas[j], sizeof(struct spa_meta));
m->data = SPA_MEMBER(mm->ptr, offset, void);
m->data = SPA_PTROFF(mm->ptr, offset, void);
offset += SPA_ROUND_UP_N(m->size, 8);
}
@ -692,7 +692,7 @@ client_node_port_use_buffers(void *object,
memcpy(d, &buffers[i].buffer->datas[j], sizeof(struct spa_data));
d->chunk =
SPA_MEMBER(mm->ptr, offset + sizeof(struct spa_chunk) * j,
SPA_PTROFF(mm->ptr, offset + sizeof(struct spa_chunk) * j,
struct spa_chunk);
if (flags & SPA_NODE_BUFFERS_FLAG_ALLOC)
@ -717,7 +717,7 @@ client_node_port_use_buffers(void *object,
j, bm->id, bm->fd, d->maxsize);
} else if (d->type == SPA_DATA_MemPtr) {
int offs = SPA_PTR_TO_INT(d->data);
d->data = SPA_MEMBER(mm->ptr, offs, void);
d->data = SPA_PTROFF(mm->ptr, offs, void);
d->fd = -1;
pw_log_debug(" data %d id:%u -> mem:%p offs:%d maxsize:%d",
j, bid->id, d->data, offs, d->maxsize);
@ -1213,7 +1213,7 @@ static struct pw_proxy *node_export(struct pw_core *core, void *object, bool do_
goto error;
data = pw_proxy_get_user_data(client_node);
data = SPA_MEMBER(data, user_data_size, struct node_data);
data = SPA_PTROFF(data, user_data_size, struct node_data);
data->pool = pw_core_get_mempool(core);
data->node = node;
data->do_free = do_free;

View file

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

View file

@ -70,25 +70,25 @@ static void transport_setup_area(void *p, struct pw_client_node0_transport *tran
struct pw_client_node0_area *a;
trans->area = a = p;
p = SPA_MEMBER(p, sizeof(struct pw_client_node0_area), struct spa_io_buffers);
p = SPA_PTROFF(p, sizeof(struct pw_client_node0_area), struct spa_io_buffers);
trans->inputs = p;
p = SPA_MEMBER(p, a->max_input_ports * sizeof(struct spa_io_buffers), void);
p = SPA_PTROFF(p, a->max_input_ports * sizeof(struct spa_io_buffers), void);
trans->outputs = p;
p = SPA_MEMBER(p, a->max_output_ports * sizeof(struct spa_io_buffers), void);
p = SPA_PTROFF(p, a->max_output_ports * sizeof(struct spa_io_buffers), void);
trans->input_buffer = p;
p = SPA_MEMBER(p, sizeof(struct spa_ringbuffer), void);
p = SPA_PTROFF(p, sizeof(struct spa_ringbuffer), void);
trans->input_data = p;
p = SPA_MEMBER(p, INPUT_BUFFER_SIZE, void);
p = SPA_PTROFF(p, INPUT_BUFFER_SIZE, void);
trans->output_buffer = p;
p = SPA_MEMBER(p, sizeof(struct spa_ringbuffer), void);
p = SPA_PTROFF(p, sizeof(struct spa_ringbuffer), void);
trans->output_data = p;
p = SPA_MEMBER(p, OUTPUT_BUFFER_SIZE, void);
p = SPA_PTROFF(p, OUTPUT_BUFFER_SIZE, void);
}
static void transport_reset_area(struct pw_client_node0_transport *trans)

View file

@ -151,7 +151,7 @@ static void process(struct impl *impl)
for (i = 0; i < impl->info.channels; i++) {
/* captured samples, with echo from sink */
ds = &cin->buffer->datas[i];
rec[i] = SPA_MEMBER(ds->data, ds->chunk->offset, void);
rec[i] = SPA_PTROFF(ds->data, ds->chunk->offset, void);
size = ds->chunk->size;
stride = ds->chunk->stride;
@ -165,7 +165,7 @@ static void process(struct impl *impl)
/* echo from sink */
ds = &pin->buffer->datas[i];
play[i] = SPA_MEMBER(ds->data, ds->chunk->offset, void);
play[i] = SPA_PTROFF(ds->data, ds->chunk->offset, void);
/* output to sink, just copy */
dd = &pout->buffer->datas[i];

View file

@ -141,7 +141,7 @@ static void capture_process(void *d)
ds = &in->buffer->datas[i];
memcpy(dd->data,
SPA_MEMBER(ds->data, ds->chunk->offset, void),
SPA_PTROFF(ds->data, ds->chunk->offset, void),
ds->chunk->size);
size = SPA_MAX(size, ds->chunk->size);

View file

@ -72,7 +72,7 @@ struct pw_proxy *pw_core_metadata_export(struct pw_core *core,
return NULL;
data = pw_proxy_get_user_data(proxy);
data = SPA_MEMBER(data, user_data_size, struct object_data);
data = SPA_PTROFF(data, user_data_size, struct object_data);
data->object = object;
data->proxy = proxy;

View file

@ -143,7 +143,7 @@ static void flush_timeout(void *data, uint64_t expirations)
spa_ringbuffer_read_data(&impl->buffer, impl->data, MAX_BUFFER,
idx % MAX_BUFFER,
SPA_MEMBER(p, sizeof(struct spa_pod_struct), void), avail);
SPA_PTROFF(p, sizeof(struct spa_pod_struct), void), avail);
spa_ringbuffer_read_update(&impl->buffer, idx + avail);
spa_list_for_each(resource, &impl->global->resource_list, link)

View file

@ -556,7 +556,7 @@ static inline void *begin_write(struct pw_protocol_native_connection *conn, uint
if ((p = connection_ensure_size(conn, buf, impl->hdr_size + size)) == NULL)
return NULL;
return SPA_MEMBER(p, impl->hdr_size, void);
return SPA_PTROFF(p, impl->hdr_size, void);
}
static int builder_overflow(void *data, uint32_t size)
@ -629,7 +629,7 @@ pw_protocol_native_connection_end(struct pw_protocol_native_connection *conn,
if (debug_messages) {
pw_log_debug(">>>>>>>>> out: id:%d op:%d size:%d seq:%d",
buf->msg.id, buf->msg.opcode, size, buf->msg.seq);
spa_debug_pod(0, NULL, SPA_MEMBER(p, impl->hdr_size, struct spa_pod));
spa_debug_pod(0, NULL, SPA_PTROFF(p, impl->hdr_size, struct spa_pod));
}
buf->seq = (buf->seq + 1) & SPA_ASYNC_SEQ_MASK;
@ -717,7 +717,7 @@ int pw_protocol_native_connection_flush(struct pw_protocol_native_connection *co
outfds);
size -= sent;
data = SPA_MEMBER(data, sent, void);
data = SPA_PTROFF(data, sent, void);
n_fds -= outfds;
fds += outfds;
to_close += outfds;

View file

@ -401,15 +401,15 @@ struct spa_pod_prop_body0 {
/* v2 iterates object as containing spa_pod */
#define SPA_POD_OBJECT_BODY_FOREACH0(body, size, iter) \
for ((iter) = SPA_MEMBER((body), sizeof(struct spa_pod_object_body), struct spa_pod); \
for ((iter) = SPA_PTROFF((body), sizeof(struct spa_pod_object_body), struct spa_pod); \
spa_pod_is_inside(body, size, iter); \
(iter) = spa_pod_next(iter))
#define SPA_POD_PROP_ALTERNATIVE_FOREACH0(body, _size, iter) \
for ((iter) = SPA_MEMBER((body), (body)->value.size + \
for ((iter) = SPA_PTROFF((body), (body)->value.size + \
sizeof(struct spa_pod_prop_body0), __typeof__(*iter)); \
(iter) <= SPA_MEMBER((body), (_size)-(body)->value.size, __typeof__(*iter)); \
(iter) = SPA_MEMBER((iter), (body)->value.size, __typeof__(*iter)))
(iter) <= SPA_PTROFF((body), (_size)-(body)->value.size, __typeof__(*iter)); \
(iter) = SPA_PTROFF((iter), (body)->value.size, __typeof__(*iter)))
#define SPA0_POD_PROP_N_VALUES(b,size) ((size - sizeof(struct spa_pod_prop_body0)) / (b)->value.size)

View file

@ -134,7 +134,7 @@ static struct pw_manager_param *add_param(struct spa_list *params,
p->id = id;
if (param != NULL) {
p->param = SPA_MEMBER(p, sizeof(*p), struct spa_pod);
p->param = SPA_PTROFF(p, sizeof(*p), struct spa_pod);
memcpy(p->param, param, SPA_POD_SIZE(param));
} else {
clear_params(params, id);
@ -836,7 +836,7 @@ void *pw_manager_object_add_data(struct pw_manager_object *obj, const char *id,
spa_list_append(&o->data_list, &d->link);
done:
return SPA_MEMBER(d, sizeof(struct object_data), void);
return SPA_PTROFF(d, sizeof(struct object_data), void);
}
int pw_manager_sync(struct pw_manager *manager)

View file

@ -226,10 +226,10 @@ static int read_arbitrary(struct message *m, const void **val, size_t *length)
static int read_string(struct message *m, char **str)
{
uint32_t n, maxlen = m->length - m->offset;
n = strnlen(SPA_MEMBER(m->data, m->offset, char), maxlen);
n = strnlen(SPA_PTROFF(m->data, m->offset, char), maxlen);
if (n == maxlen)
return -EINVAL;
*str = SPA_MEMBER(m->data, m->offset, char);
*str = SPA_PTROFF(m->data, m->offset, char);
m->offset += n + 1;
return 0;
}
@ -481,7 +481,7 @@ static void write_string(struct message *m, const char *s)
if (s != NULL) {
int len = strlen(s) + 1;
if (ensure_size(m, len) > 0)
strcpy(SPA_MEMBER(m->data, m->length, char), s);
strcpy(SPA_PTROFF(m->data, m->length, char), s);
m->length += len;
}
}

View file

@ -50,7 +50,7 @@ struct module *module_new(struct impl *impl, const struct module_methods *method
module->impl = impl;
module->methods = methods;
spa_hook_list_init(&module->hooks);
module->user_data = SPA_MEMBER(module, sizeof(struct module), void);
module->user_data = SPA_PTROFF(module, sizeof(struct module), void);
return module;
}

View file

@ -226,7 +226,7 @@ static int flush_messages(struct client *client)
desc.offset_lo = 0;
desc.flags = 0;
data = SPA_MEMBER(&desc, client->out_index, void);
data = SPA_PTROFF(&desc, client->out_index, void);
size = sizeof(desc) - client->out_index;
} else if (client->out_index < m->length + sizeof(desc)) {
uint32_t idx = client->out_index - sizeof(desc);
@ -1705,7 +1705,7 @@ static void stream_process(void *data)
spa_ringbuffer_write_data(&stream->ring,
stream->buffer, stream->attr.maxlength,
pd.write_index % stream->attr.maxlength,
SPA_MEMBER(p, buf->datas[0].chunk->offset, void),
SPA_PTROFF(p, buf->datas[0].chunk->offset, void),
SPA_MIN(size, stream->attr.maxlength));
pd.write_index += size;
@ -5532,7 +5532,7 @@ static int do_read(struct client *client)
int res = 0;
if (client->in_index < sizeof(client->desc)) {
data = SPA_MEMBER(&client->desc, client->in_index, void);
data = SPA_PTROFF(&client->desc, client->in_index, void);
size = sizeof(client->desc) - client->in_index;
} else {
uint32_t idx = client->in_index - sizeof(client->desc);
@ -5541,7 +5541,7 @@ static int do_read(struct client *client)
res = -EIO;
goto exit;
}
data = SPA_MEMBER(client->message->data, idx, void);
data = SPA_PTROFF(client->message->data, idx, void);
size = client->message->length - idx;
}
while (true) {
@ -6325,7 +6325,7 @@ error_exit:
void *pw_protocol_pulse_get_user_data(struct pw_protocol_pulse *pulse)
{
return SPA_MEMBER(pulse, sizeof(struct impl), void);
return SPA_PTROFF(pulse, sizeof(struct impl), void);
}
void pw_protocol_pulse_destroy(struct pw_protocol_pulse *pulse)

View file

@ -178,7 +178,7 @@ static struct sample_play *sample_play_new(struct pw_core *core,
p->context = pw_core_get_context(core);
p->main_loop = pw_context_get_main_loop(p->context);
spa_hook_list_init(&p->hooks);
p->user_data = SPA_MEMBER(p, sizeof(struct sample_play), void);
p->user_data = SPA_PTROFF(p, sizeof(struct sample_play), void);
pw_properties_update(props, &sample->props->dict);

View file

@ -226,7 +226,7 @@ static void capture_process(void *data)
while (size > 0) {
res = send(client->source->fd,
SPA_MEMBER(d->data, offset, void),
SPA_PTROFF(d->data, offset, void),
size,
MSG_NOSIGNAL | MSG_DONTWAIT);
if (res < 0) {
@ -270,7 +270,7 @@ static void playback_process(void *data)
offset = 0;
while (size > 0) {
res = recv(client->source->fd,
SPA_MEMBER(d->data, offset, void),
SPA_PTROFF(d->data, offset, void),
size,
MSG_DONTWAIT);
if (res == 0) {

View file

@ -62,7 +62,7 @@ struct pw_proxy *pw_core_endpoint_export(struct pw_core *core,
return NULL;
data = pw_proxy_get_user_data(proxy);
data = SPA_MEMBER(data, user_data_size, struct object_data);
data = SPA_PTROFF(data, user_data_size, struct object_data);
remote_iface = (struct spa_interface*)proxy;
local_iface = (struct spa_interface*)endpoint;
@ -98,7 +98,7 @@ struct pw_proxy *pw_core_endpoint_stream_export(struct pw_core *core,
return NULL;
data = pw_proxy_get_user_data(proxy);
data = SPA_MEMBER(data, user_data_size, struct object_data);
data = SPA_PTROFF(data, user_data_size, struct object_data);
remote_iface = (struct spa_interface*)proxy;
local_iface = (struct spa_interface*)endpoint_stream;
@ -134,7 +134,7 @@ struct pw_proxy *pw_core_endpoint_link_export(struct pw_core *core,
return NULL;
data = pw_proxy_get_user_data(proxy);
data = SPA_MEMBER(data, user_data_size, struct object_data);
data = SPA_PTROFF(data, user_data_size, struct object_data);
remote_iface = (struct spa_interface*)proxy;
local_iface = (struct spa_interface*)endpoint_link;
@ -170,7 +170,7 @@ struct pw_proxy *pw_core_session_export(struct pw_core *core,
return NULL;
data = pw_proxy_get_user_data(proxy);
data = SPA_MEMBER(data, user_data_size, struct object_data);
data = SPA_PTROFF(data, user_data_size, struct object_data);
remote_iface = (struct spa_interface*)proxy;
local_iface = (struct spa_interface*)session;

View file

@ -91,7 +91,7 @@ pw_spa_device_new(struct pw_context *context,
impl->flags = flags;
if (user_data_size > 0)
impl->user_data = SPA_MEMBER(impl, sizeof(struct impl), void);
impl->user_data = SPA_PTROFF(impl, sizeof(struct impl), void);
pw_impl_device_add_listener(this, &impl->device_listener, &device_events, impl);
pw_impl_device_set_implementation(this, impl->device);

View file

@ -124,7 +124,7 @@ pw_spa_node_new(struct pw_context *context,
impl->flags = flags;
if (user_data_size > 0)
impl->user_data = SPA_MEMBER(impl, sizeof(struct impl), void);
impl->user_data = SPA_PTROFF(impl, sizeof(struct impl), void);
pw_impl_node_add_listener(this, &impl->node_listener, &node_events, impl);
if ((res = pw_impl_node_set_implementation(this, impl->node)) < 0)

View file

@ -50,7 +50,7 @@ struct pw_array {
#define PW_ARRAY_INIT(extend) (struct pw_array) { NULL, 0, 0, extend }
#define pw_array_get_len_s(a,s) ((a)->size / (s))
#define pw_array_get_unchecked_s(a,idx,s,t) SPA_MEMBER((a)->data,(idx)*(s),t)
#define pw_array_get_unchecked_s(a,idx,s,t) SPA_PTROFF((a)->data,(idx)*(s),t)
#define pw_array_check_index_s(a,idx,s) ((idx) < pw_array_get_len_s(a,s))
/** Get the number of items of type \a t in array \memberof pw_array */
@ -61,8 +61,8 @@ struct pw_array {
#define pw_array_check_index(a,idx,t) pw_array_check_index_s(a,idx,sizeof(t))
#define pw_array_first(a) ((a)->data)
#define pw_array_end(a) SPA_MEMBER((a)->data, (a)->size, void)
#define pw_array_check(a,p) (SPA_MEMBER(p,sizeof(*p),void) <= pw_array_end(a))
#define pw_array_end(a) SPA_PTROFF((a)->data, (a)->size, void)
#define pw_array_check(a,p) (SPA_PTROFF(p,sizeof(*p),void) <= pw_array_end(a))
#define pw_array_for_each(pos, array) \
for (pos = (__typeof__(pos)) pw_array_first(array); \
@ -77,7 +77,7 @@ struct pw_array {
#define pw_array_remove(a,p) \
({ \
(a)->size -= sizeof(*(p)); \
memmove(p, SPA_MEMBER((p), sizeof(*(p)), void), \
memmove(p, SPA_PTROFF((p), sizeof(*(p)), void), \
SPA_PTRDIFF(pw_array_end(a),(p))); \
})
@ -131,7 +131,7 @@ static inline void *pw_array_add(struct pw_array *arr, size_t size)
if (pw_array_ensure_size(arr, size) < 0)
return NULL;
p = SPA_MEMBER(arr->data, arr->size, void);
p = SPA_PTROFF(arr->data, arr->size, void);
arr->size += size;
return p;
@ -148,7 +148,7 @@ static inline void *pw_array_add_fixed(struct pw_array *arr, size_t size)
return NULL;
}
p = SPA_MEMBER(arr->data, arr->size, void);
p = SPA_PTROFF(arr->data, arr->size, void);
arr->size += size;
return p;

View file

@ -121,7 +121,7 @@ static int alloc_buffers(struct pw_mempool *pool,
if (buffers == NULL)
return -errno;
skel = SPA_MEMBER(buffers, n_buffers * sizeof(struct spa_buffer *), void);
skel = SPA_PTROFF(buffers, n_buffers * sizeof(struct spa_buffer *), void);
skel = SPA_PTR_ALIGN(skel, info.max_align, void);
if (SPA_FLAG_IS_SET(flags, PW_BUFFERS_FLAG_SHARED)) {
@ -271,7 +271,7 @@ int pw_buffers_negotiate(struct pw_context *context, uint32_t flags,
params = alloca(n_params * sizeof(struct spa_pod *));
for (i = 0, offset = 0; i < n_params; i++) {
params[i] = SPA_MEMBER(buffer, offset, struct spa_pod);
params[i] = SPA_PTROFF(buffer, offset, struct spa_pod);
spa_pod_fixate(params[i]);
pw_log_debug(NAME" %p: fixated param %d:", result, i);
pw_log_pod(SPA_LOG_LEVEL_DEBUG, params[i]);

View file

@ -213,7 +213,7 @@ struct pw_context *pw_context_new(struct pw_loop *main_loop,
pw_log_debug(NAME" %p: new", this);
if (user_data_size > 0)
this->user_data = SPA_MEMBER(impl, sizeof(struct impl), void);
this->user_data = SPA_PTROFF(impl, sizeof(struct impl), void);
if (properties == NULL)
properties = pw_properties_new(NULL, NULL);

View file

@ -76,7 +76,7 @@ pw_control_new(struct pw_context *context,
spa_list_init(&this->links);
if (user_data_size > 0)
this->user_data = SPA_MEMBER(impl, sizeof(struct impl), void);
this->user_data = SPA_PTROFF(impl, sizeof(struct impl), void);
spa_hook_list_init(&this->listener_list);

View file

@ -335,7 +335,7 @@ static struct pw_core *core_new(struct pw_context *context,
p->pool = pw_mempool_new(NULL);
p->core = p;
if (user_data_size > 0)
p->user_data = SPA_MEMBER(p, sizeof(struct pw_core), void);
p->user_data = SPA_PTROFF(p, sizeof(struct pw_core), void);
p->proxy.user_data = p->user_data;
pw_map_init(&p->objects, 64, 32);

View file

@ -213,7 +213,7 @@ static struct param *add_param(struct filter *impl, struct port *port,
p->id = id;
p->flags = flags;
p->param = SPA_MEMBER(p, sizeof(struct param), struct spa_pod);
p->param = SPA_PTROFF(p, sizeof(struct param), struct spa_pod);
memcpy(p->param, param, SPA_POD_SIZE(param));
SPA_POD_OBJECT_ID(p->param) = id;
@ -576,7 +576,7 @@ static int map_data(struct filter *impl, struct spa_data *data, int prot)
pw_log_error(NAME" %p: failed to mmap buffer mem: %m", impl);
return -errno;
}
data->data = SPA_MEMBER(ptr, range.start, void);
data->data = SPA_PTROFF(ptr, range.start, void);
pw_log_debug(NAME" %p: fd %"PRIi64" mapped %d %d %p", impl, data->fd,
range.offset, range.size, data->data);
@ -600,7 +600,7 @@ static int unmap_data(struct filter *impl, struct spa_data *data)
pw_map_range_init(&range, data->mapoffset, data->maxsize, impl->context->sc_pagesize);
if (munmap(SPA_MEMBER(data->data, -range.start, void), range.size) < 0)
if (munmap(SPA_PTROFF(data->data, -range.start, void), range.size) < 0)
pw_log_warn(NAME" %p: failed to unmap: %m", impl);
pw_log_debug(NAME" %p: fd %"PRIi64" unmapped", impl, data->fd);

View file

@ -430,7 +430,7 @@ struct pw_impl_client *pw_context_create_client(struct pw_impl_core *core,
this->permission_data = impl;
if (user_data_size > 0)
this->user_data = SPA_MEMBER(impl, sizeof(struct impl), void);
this->user_data = SPA_PTROFF(impl, sizeof(struct impl), void);
spa_hook_list_init(&this->listener_list);

View file

@ -455,7 +455,7 @@ struct pw_impl_core *pw_context_create_core(struct pw_context *context,
spa_hook_list_init(&this->listener_list);
if (user_data_size > 0)
this->user_data = SPA_MEMBER(this, sizeof(*this), void);
this->user_data = SPA_PTROFF(this, sizeof(*this), void);
pw_log_debug(NAME" %p: new %s", this, name);

View file

@ -175,7 +175,7 @@ struct pw_impl_device *pw_context_create_device(struct pw_context *context,
spa_list_init(&this->object_list);
if (user_data_size > 0)
this->user_data = SPA_MEMBER(this, sizeof(struct impl), void);
this->user_data = SPA_PTROFF(this, sizeof(struct impl), void);
check_properties(this);

View file

@ -65,7 +65,7 @@ struct pw_impl_factory *pw_context_create_factory(struct pw_context *context,
spa_hook_list_init(&this->listener_list);
if (user_data_size > 0)
this->user_data = SPA_MEMBER(this, sizeof(*this), void);
this->user_data = SPA_PTROFF(this, sizeof(*this), void);
pw_log_debug(NAME" %p: new %s", this, name);

View file

@ -1076,7 +1076,7 @@ struct pw_impl_link *pw_context_create_link(struct pw_context *context,
pw_log_debug(NAME" %p: new out-port:%p -> in-port:%p", this, output, input);
if (user_data_size > 0)
this->user_data = SPA_MEMBER(impl, sizeof(struct impl), void);
this->user_data = SPA_PTROFF(impl, sizeof(struct impl), void);
impl->work = pw_work_queue_new(context->main_loop);

View file

@ -1149,7 +1149,7 @@ struct pw_impl_node *pw_context_create_node(struct pw_context *context,
this->group_id = SPA_ID_INVALID;
if (user_data_size > 0)
this->user_data = SPA_MEMBER(impl, sizeof(struct impl), void);
this->user_data = SPA_PTROFF(impl, sizeof(struct impl), void);
if (properties == NULL)
properties = pw_properties_new(NULL, NULL);

View file

@ -449,7 +449,7 @@ struct pw_impl_port *pw_context_create_port(
this->rt.io = SPA_IO_BUFFERS_INIT;
if (user_data_size > 0)
this->user_data = SPA_MEMBER(impl, sizeof(struct impl), void);
this->user_data = SPA_PTROFF(impl, sizeof(struct impl), void);
this->info.direction = direction;
this->info.params = this->params;

View file

@ -238,7 +238,7 @@ int pw_memblock_map_old(struct pw_memblock *mem)
return -ENOMEM;
}
wrap = SPA_MEMBER(mem->ptr, mem->size, void);
wrap = SPA_PTROFF(mem->ptr, mem->size, void);
ptr =
mmap(wrap, mem->size, prot, MAP_FIXED | MAP_SHARED,
@ -391,7 +391,7 @@ struct pw_memmap * pw_memblock_map(struct pw_memblock *block,
mm->this.flags = flags;
mm->this.offset = offset;
mm->this.size = size;
mm->this.ptr = SPA_MEMBER(m->ptr, range.start, void);
mm->this.ptr = SPA_PTROFF(m->ptr, range.start, void);
pw_log_debug(NAME" %p: map:%p block:%p fd:%d ptr:%p (%d %d) mapping:%p ref:%d", p,
&mm->this, b, b->this.fd, mm->this.ptr, offset, size, m, m->ref);
@ -737,7 +737,7 @@ struct pw_memblock * pw_mempool_find_ptr(struct pw_mempool *pool, const void *pt
spa_list_for_each(b, &impl->blocks, link) {
spa_list_for_each(m, &b->mappings, link) {
if (ptr >= m->ptr && ptr < SPA_MEMBER(m->ptr, m->size, void)) {
if (ptr >= m->ptr && ptr < SPA_PTROFF(m->ptr, m->size, void)) {
pw_log_debug(NAME" %p: block:%p id:%d for %p", pool,
b, b->this.id, ptr);
return &b->this;

View file

@ -125,7 +125,7 @@ static inline struct pw_param *pw_param_add(struct spa_list *params,
p->id = id;
if (param != NULL) {
p->param = SPA_MEMBER(p, sizeof(*p), struct spa_pod);
p->param = SPA_PTROFF(p, sizeof(*p), struct spa_pod);
memcpy(p->param, param, SPA_POD_SIZE(param));
} else {
pw_param_clear(params, id);

View file

@ -63,7 +63,7 @@ struct pw_protocol *pw_protocol_new(struct pw_context *context,
spa_hook_list_init(&protocol->listener_list);
if (user_data_size > 0)
protocol->user_data = SPA_MEMBER(protocol, sizeof(struct impl), void);
protocol->user_data = SPA_PTROFF(protocol, sizeof(struct impl), void);
spa_list_append(&context->protocol_list, &protocol->link);

View file

@ -107,7 +107,7 @@ struct pw_proxy *pw_proxy_new(struct pw_proxy *factory,
goto error_init;
if (user_data_size > 0)
this->user_data = SPA_MEMBER(impl, sizeof(struct proxy), void);
this->user_data = SPA_PTROFF(impl, sizeof(struct proxy), void);
pw_log_debug(NAME" %p: new %u type %s/%d core-proxy:%p, marshal:%p",
this, this->id, type, version, this->core, this->marshal);

View file

@ -86,7 +86,7 @@ struct pw_resource *pw_resource_new(struct pw_impl_client *client,
if (user_data_size > 0)
this->user_data = SPA_MEMBER(impl, sizeof(struct impl), void);
this->user_data = SPA_PTROFF(impl, sizeof(struct impl), void);
pw_log_debug(NAME" %p: new %u type %s/%d client:%p marshal:%p",
this, id, type, version, client, this->marshal);

View file

@ -231,7 +231,7 @@ static struct param *add_param(struct stream *impl,
p->id = id;
p->flags = flags;
p->param = SPA_MEMBER(p, sizeof(struct param), struct spa_pod);
p->param = SPA_PTROFF(p, sizeof(struct param), struct spa_pod);
memcpy(p->param, param, SPA_POD_SIZE(param));
SPA_POD_OBJECT_ID(p->param) = id;
@ -626,7 +626,7 @@ static int map_data(struct stream *impl, struct spa_data *data, int prot)
return -errno;
}
data->data = SPA_MEMBER(ptr, range.start, void);
data->data = SPA_PTROFF(ptr, range.start, void);
pw_log_debug(NAME" %p: fd %"PRIi64" mapped %d %d %p", impl, data->fd,
range.offset, range.size, data->data);
@ -650,7 +650,7 @@ static int unmap_data(struct stream *impl, struct spa_data *data)
pw_map_range_init(&range, data->mapoffset, data->maxsize, impl->context->sc_pagesize);
if (munmap(SPA_MEMBER(data->data, -range.start, void), range.size) < 0)
if (munmap(SPA_PTROFF(data->data, -range.start, void), range.size) < 0)
pw_log_warn(NAME" %p: failed to unmap: %m", impl);
pw_log_debug(NAME" %p: fd %"PRIi64" unmapped", impl, data->fd);
@ -999,7 +999,7 @@ static int node_event_param(void *object, int seq,
return 0;
c = calloc(1, sizeof(*c) + SPA_POD_SIZE(param));
c->info = SPA_MEMBER(c, sizeof(*c), struct spa_pod);
c->info = SPA_PTROFF(c, sizeof(*c), struct spa_pod);
memcpy(c->info, param, SPA_POD_SIZE(param));
c->control.n_values = 0;
c->control.max_values = 0;

View file

@ -155,7 +155,7 @@ static struct param *add_param(struct spa_list *params, uint32_t id, const struc
p->id = id;
if (param != NULL) {
p->param = SPA_MEMBER(p, sizeof(*p), struct spa_pod);
p->param = SPA_PTROFF(p, sizeof(*p), struct spa_pod);
memcpy(p->param, param, SPA_POD_SIZE(param));
} else {
clear_params(params, id);
@ -1152,12 +1152,12 @@ static int metadata_property(void *object,
if (e == NULL)
return -errno;
e->key = SPA_MEMBER(e, sizeof(*e), void);
e->key = SPA_PTROFF(e, sizeof(*e), void);
strcpy(e->key, key);
e->value = SPA_MEMBER(e->key, strlen(e->key) + 1, void);
e->value = SPA_PTROFF(e->key, strlen(e->key) + 1, void);
strcpy(e->value, value);
if (type) {
e->type = SPA_MEMBER(e->value, strlen(e->value) + 1, void);
e->type = SPA_PTROFF(e->value, strlen(e->value) + 1, void);
strcpy(e->type, type);
} else {
e->type = NULL;

View file

@ -146,7 +146,7 @@ static void event_param(void *object, int seq, uint32_t id,
p->id = id;
p->seq = seq;
p->param = SPA_MEMBER(p, sizeof(struct param), struct spa_pod);
p->param = SPA_PTROFF(p, sizeof(struct param), struct spa_pod);
p->changed = true;
memcpy(p->param, param, SPA_POD_SIZE(param));
spa_list_append(&data->param_list, &p->link);