mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
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:
parent
e598d0a422
commit
2405f0942b
92 changed files with 248 additions and 227 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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++;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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)) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue