summaryrefslogtreecommitdiff
path: root/spa/plugins
diff options
context:
space:
mode:
authorWim Taymans <wtaymans@redhat.com>2016-12-14 14:56:50 +0100
committerWim Taymans <wtaymans@redhat.com>2016-12-14 14:56:50 +0100
commita9ba35359c302280c66ddd28596ffae11ddde071 (patch)
treec23f239837e084b06bc2b16c41ae5591eec7e6f0 /spa/plugins
parent5e8a3afe17d954dc278eed6a7f1dab16daa49701 (diff)
another mem testmem2
Diffstat (limited to 'spa/plugins')
-rw-r--r--spa/plugins/alsa/alsa-sink.c10
-rw-r--r--spa/plugins/alsa/alsa-source.c10
-rw-r--r--spa/plugins/alsa/alsa-utils.c21
-rw-r--r--spa/plugins/audiomixer/audiomixer.c8
-rw-r--r--spa/plugins/audiotestsrc/audiotestsrc.c14
-rw-r--r--spa/plugins/v4l2/v4l2-utils.c73
-rw-r--r--spa/plugins/videotestsrc/videotestsrc.c14
-rw-r--r--spa/plugins/volume/volume.c10
8 files changed, 84 insertions, 76 deletions
diff --git a/spa/plugins/alsa/alsa-sink.c b/spa/plugins/alsa/alsa-sink.c
index 736ab3b2..969051da 100644
--- a/spa/plugins/alsa/alsa-sink.c
+++ b/spa/plugins/alsa/alsa-sink.c
@@ -544,11 +544,11 @@ spa_alsa_sink_node_port_use_buffers (SpaNode *node,
if (b->rb)
this->ringbuffer = b;
- switch (buffers[i]->datas[0].type) {
- case SPA_DATA_TYPE_MEMFD:
- case SPA_DATA_TYPE_DMABUF:
- case SPA_DATA_TYPE_MEMPTR:
- if (buffers[i]->datas[0].data == NULL) {
+ switch (SPA_DATA_MEM_TYPE (&buffers[i]->datas[0])) {
+ case SPA_MEM_TYPE_MEMFD:
+ case SPA_MEM_TYPE_DMABUF:
+ case SPA_MEM_TYPE_MEMPTR:
+ if (SPA_DATA_MEM_PTR (&buffers[i]->datas[0]) == NULL) {
spa_log_error (this->log, "alsa-source: need mapped memory");
continue;
}
diff --git a/spa/plugins/alsa/alsa-source.c b/spa/plugins/alsa/alsa-source.c
index 9c79791d..eb34a63a 100644
--- a/spa/plugins/alsa/alsa-source.c
+++ b/spa/plugins/alsa/alsa-source.c
@@ -578,11 +578,11 @@ spa_alsa_source_node_port_use_buffers (SpaNode *node,
b->h = spa_buffer_find_meta (b->outbuf, SPA_META_TYPE_HEADER);
- switch (buffers[i]->datas[0].type) {
- case SPA_DATA_TYPE_MEMFD:
- case SPA_DATA_TYPE_DMABUF:
- case SPA_DATA_TYPE_MEMPTR:
- if (buffers[i]->datas[0].data == NULL) {
+ switch (SPA_DATA_MEM_TYPE (&buffers[i]->datas[0])) {
+ case SPA_MEM_TYPE_MEMFD:
+ case SPA_MEM_TYPE_DMABUF:
+ case SPA_MEM_TYPE_MEMPTR:
+ if (SPA_DATA_MEM_PTR (&buffers[i]->datas[0]) == NULL) {
spa_log_error (this->log, "alsa-source: need mapped memory");
continue;
}
diff --git a/spa/plugins/alsa/alsa-utils.c b/spa/plugins/alsa/alsa-utils.c
index 4fa72e06..994c0a91 100644
--- a/spa/plugins/alsa/alsa-utils.c
+++ b/spa/plugins/alsa/alsa-utils.c
@@ -272,18 +272,20 @@ pull_frames_queue (SpaALSAState *state,
uint8_t *src, *dst;
size_t n_bytes;
SpaALSABuffer *b;
+ SpaData *d;
b = spa_list_first (&state->ready, SpaALSABuffer, list);
+ d = &b->outbuf->datas[0];
- src = SPA_MEMBER (b->outbuf->datas[0].data, b->outbuf->datas[0].offset + state->ready_offset, uint8_t);
+ src = SPA_MEMBER (SPA_DATA_CHUNK_PTR (d), state->ready_offset, uint8_t);
dst = SPA_MEMBER (my_areas[0].addr, offset * state->frame_size, uint8_t);
- n_bytes = SPA_MIN (b->outbuf->datas[0].size - state->ready_offset, frames * state->frame_size);
+ n_bytes = SPA_MIN (SPA_DATA_CHUNK_SIZE (d) - state->ready_offset, frames * state->frame_size);
frames = SPA_MIN (frames, n_bytes / state->frame_size);
memcpy (dst, src, n_bytes);
state->ready_offset += n_bytes;
- if (state->ready_offset >= b->outbuf->datas[0].size) {
+ if (state->ready_offset >= SPA_DATA_CHUNK_SIZE (d)) {
SpaNodeEventReuseBuffer rb;
spa_list_remove (&b->list);
@@ -315,10 +317,12 @@ pull_frames_ringbuffer (SpaALSAState *state,
SpaALSABuffer *b;
uint8_t *src, *dst;
SpaNodeEventReuseBuffer rb;
+ SpaData *d;
b = state->ringbuffer;
+ d = &b->outbuf->datas[0];
- src = SPA_MEMBER (b->outbuf->datas[0].data, b->outbuf->datas[0].offset, void);
+ src = SPA_DATA_CHUNK_PTR (d);
dst = SPA_MEMBER (my_areas[0].addr, offset * state->frame_size, uint8_t);
avail = spa_ringbuffer_get_read_areas (&b->rb->ringbuffer, areas);
@@ -420,6 +424,7 @@ mmap_read (SpaALSAState *state)
int64_t now;
uint8_t *dest = NULL;
size_t destsize;
+ SpaData *d;
snd_pcm_status_alloca(&status);
@@ -442,8 +447,10 @@ mmap_read (SpaALSAState *state)
b = spa_list_first (&state->free, SpaALSABuffer, list);
spa_list_remove (&b->list);
- dest = SPA_MEMBER (b->outbuf->datas[0].data, b->outbuf->datas[0].offset, void);
- destsize = b->outbuf->datas[0].size;
+ d = &b->outbuf->datas[0];
+
+ dest = SPA_DATA_CHUNK_PTR (d);
+ destsize = SPA_DATA_CHUNK_SIZE (d);
if (b->h) {
b->h->seq = state->sample_count;
@@ -484,7 +491,7 @@ mmap_read (SpaALSAState *state)
SpaData *d;
d = b->outbuf->datas;
- d[0].size = avail * state->frame_size;
+ SPA_DATA_CHUNK_SIZE (&d[0]) = avail * state->frame_size;
spa_list_insert (state->ready.prev, &b->list);
diff --git a/spa/plugins/audiomixer/audiomixer.c b/spa/plugins/audiomixer/audiomixer.c
index 654745a8..f1bc1922 100644
--- a/spa/plugins/audiomixer/audiomixer.c
+++ b/spa/plugins/audiomixer/audiomixer.c
@@ -598,12 +598,12 @@ add_port_data (SpaAudioMixer *this, SpaBuffer *out, SpaAudioMixerPort *port)
while (true) {
if (op == NULL) {
- op = (uint8_t*)odatas[oi].data + odatas[oi].offset;
- os = odatas[oi].size;
+ op = SPA_DATA_CHUNK_PTR (&odatas[oi]);
+ os = SPA_DATA_CHUNK_SIZE (&odatas[oi]);
}
if (ip == NULL) {
- ip = (uint8_t*)idatas[port->buffer_index].data + idatas[port->buffer_index].offset;
- is = idatas[port->buffer_index].size;
+ ip = SPA_DATA_CHUNK_PTR (&idatas[port->buffer_index]);
+ is = SPA_DATA_CHUNK_SIZE (&idatas[port->buffer_index]);
ip += port->buffer_offset;
is -= port->buffer_offset;
}
diff --git a/spa/plugins/audiotestsrc/audiotestsrc.c b/spa/plugins/audiotestsrc/audiotestsrc.c
index 11a024b6..cc8a1cdc 100644
--- a/spa/plugins/audiotestsrc/audiotestsrc.c
+++ b/spa/plugins/audiotestsrc/audiotestsrc.c
@@ -682,16 +682,16 @@ spa_audiotestsrc_node_port_use_buffers (SpaNode *node,
b->outstanding = true;
b->h = spa_buffer_find_meta (buffers[i], SPA_META_TYPE_HEADER);
- switch (d[0].type) {
- case SPA_DATA_TYPE_MEMPTR:
- case SPA_DATA_TYPE_MEMFD:
- case SPA_DATA_TYPE_DMABUF:
- if (d[0].data == NULL) {
+ switch (SPA_DATA_MEM_TYPE (&d[0])) {
+ case SPA_MEM_TYPE_MEMPTR:
+ case SPA_MEM_TYPE_MEMFD:
+ case SPA_MEM_TYPE_DMABUF:
+ if (SPA_DATA_MEM_PTR (&d[0]) == NULL) {
spa_log_error (this->log, "audiotestsrc %p: invalid memory on buffer %p", this, buffers[i]);
continue;
}
- b->ptr = SPA_MEMBER (d[0].data, d[0].offset, void);
- b->size = d[0].size;
+ b->ptr = SPA_DATA_CHUNK_PTR (&d[0]);
+ b->size = SPA_DATA_CHUNK_SIZE (&d[0]);
break;
default:
break;
diff --git a/spa/plugins/v4l2/v4l2-utils.c b/spa/plugins/v4l2/v4l2-utils.c
index de291aa1..d3f3510e 100644
--- a/spa/plugins/v4l2/v4l2-utils.c
+++ b/spa/plugins/v4l2/v4l2-utils.c
@@ -108,19 +108,19 @@ spa_v4l2_clear_buffers (SpaV4l2Source *this)
return SPA_RESULT_OK;
for (i = 0; i < state->n_buffers; i++) {
- V4l2Buffer *b;
+ V4l2Buffer *b = &state->buffers[i];
+ SpaData *d = &b->outbuf->datas[0];
- b = &state->buffers[i];
if (b->outstanding) {
spa_log_info (state->log, "v4l2: queueing outstanding buffer %p", b);
spa_v4l2_buffer_recycle (this, i);
}
if (b->allocated) {
- if (b->outbuf->datas[0].data)
- munmap (b->outbuf->datas[0].data, b->outbuf->datas[0].maxsize);
- if (b->outbuf->datas[0].fd != -1)
- close (b->outbuf->datas[0].fd);
- b->outbuf->datas[0].type = SPA_DATA_TYPE_INVALID;
+ if (SPA_DATA_MEM_PTR (d))
+ munmap (SPA_DATA_MEM_PTR (d), SPA_DATA_MEM_SIZE (d));
+ if (SPA_DATA_MEM_FD (d) != -1)
+ close (SPA_DATA_MEM_FD (d));
+ SPA_DATA_MEM_TYPE (d) = SPA_MEM_TYPE_INVALID;
}
}
@@ -876,7 +876,8 @@ mmap_read (SpaV4l2Source *this)
}
d = b->outbuf->datas;
- d[0].size = buf.bytesused;
+ SPA_DATA_CHUNK_OFFSET (&d[0]) = 0;
+ SPA_DATA_CHUNK_SIZE (&d[0]) = buf.bytesused;
spa_list_insert (state->ready.prev, &b->list);
@@ -913,12 +914,12 @@ spa_v4l2_use_buffers (SpaV4l2Source *this, SpaBuffer **buffers, uint32_t n_buffe
SpaData *d;
if (n_buffers > 0) {
- switch (buffers[0]->datas[0].type) {
- case SPA_DATA_TYPE_MEMPTR:
- case SPA_DATA_TYPE_MEMFD:
+ switch (SPA_DATA_MEM_TYPE (&buffers[0]->datas[0])) {
+ case SPA_MEM_TYPE_MEMPTR:
+ case SPA_MEM_TYPE_MEMFD:
state->memtype = V4L2_MEMORY_USERPTR;
break;
- case SPA_DATA_TYPE_DMABUF:
+ case SPA_MEM_TYPE_DMABUF:
state->memtype = V4L2_MEMORY_DMABUF;
break;
default:
@@ -963,18 +964,18 @@ spa_v4l2_use_buffers (SpaV4l2Source *this, SpaBuffer **buffers, uint32_t n_buffe
b->v4l2_buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
b->v4l2_buffer.memory = state->memtype;
b->v4l2_buffer.index = i;
- switch (d[0].type) {
- case SPA_DATA_TYPE_MEMPTR:
- case SPA_DATA_TYPE_MEMFD:
- if (d[0].data == NULL) {
+ switch (SPA_DATA_MEM_TYPE (&d[0])) {
+ case SPA_MEM_TYPE_MEMPTR:
+ case SPA_MEM_TYPE_MEMFD:
+ if (SPA_DATA_MEM_PTR (&d[0]) == NULL) {
spa_log_error (state->log, "v4l2: need mmaped memory");
continue;
}
- b->v4l2_buffer.m.userptr = (unsigned long) SPA_MEMBER (d[0].data, d[0].offset, void *);
- b->v4l2_buffer.length = d[0].size;
+ b->v4l2_buffer.m.userptr = (unsigned long) SPA_DATA_CHUNK_PTR (&d[0]);
+ b->v4l2_buffer.length = SPA_DATA_CHUNK_SIZE (&d[0]);
break;
- case SPA_DATA_TYPE_DMABUF:
- b->v4l2_buffer.m.fd = d[0].fd;
+ case SPA_MEM_TYPE_DMABUF:
+ b->v4l2_buffer.m.fd = SPA_DATA_MEM_FD (&d[0]);
break;
default:
break;
@@ -1045,10 +1046,10 @@ mmap_init (SpaV4l2Source *this,
}
d = buffers[i]->datas;
- d[0].offset = 0;
- d[0].size = b->v4l2_buffer.length;
- d[0].maxsize = b->v4l2_buffer.length;
- d[0].stride = state->fmt.fmt.pix.bytesperline;
+ SPA_DATA_MEM_SIZE (&d[0]) = b->v4l2_buffer.length;
+ SPA_DATA_CHUNK_OFFSET (&d[0]) = 0;
+ SPA_DATA_CHUNK_SIZE (&d[0]) = b->v4l2_buffer.length;
+ SPA_DATA_CHUNK_STRIDE (&d[0]) = state->fmt.fmt.pix.bytesperline;
if (state->export_buf) {
struct v4l2_exportbuffer expbuf;
@@ -1061,19 +1062,19 @@ mmap_init (SpaV4l2Source *this,
perror("VIDIOC_EXPBUF");
continue;
}
- d[0].type = SPA_DATA_TYPE_DMABUF;
- d[0].fd = expbuf.fd;
- d[0].data = NULL;
+ SPA_DATA_MEM_TYPE (&d[0]) = SPA_MEM_TYPE_DMABUF;
+ SPA_DATA_MEM_FD (&d[0]) = expbuf.fd;
+ SPA_DATA_MEM_PTR (&d[0]) = NULL;
} else {
- d[0].type = SPA_DATA_TYPE_MEMPTR;
- d[0].fd = -1;
- d[0].data = mmap (NULL,
- b->v4l2_buffer.length,
- PROT_READ,
- MAP_SHARED,
- state->fd,
- b->v4l2_buffer.m.offset);
- if (d[0].data == MAP_FAILED) {
+ SPA_DATA_MEM_TYPE (&d[0]) = SPA_MEM_TYPE_MEMPTR;
+ SPA_DATA_MEM_FD (&d[0]) = -1;
+ SPA_DATA_MEM_PTR (&d[0]) = mmap (NULL,
+ b->v4l2_buffer.length,
+ PROT_READ,
+ MAP_SHARED,
+ state->fd,
+ b->v4l2_buffer.m.offset);
+ if (SPA_DATA_MEM_PTR (&d[0]) == MAP_FAILED) {
perror ("mmap");
continue;
}
diff --git a/spa/plugins/videotestsrc/videotestsrc.c b/spa/plugins/videotestsrc/videotestsrc.c
index be8cf93b..3f8cbd24 100644
--- a/spa/plugins/videotestsrc/videotestsrc.c
+++ b/spa/plugins/videotestsrc/videotestsrc.c
@@ -649,16 +649,16 @@ spa_videotestsrc_node_port_use_buffers (SpaNode *node,
b->outstanding = true;
b->h = spa_buffer_find_meta (buffers[i], SPA_META_TYPE_HEADER);
- switch (d[0].type) {
- case SPA_DATA_TYPE_MEMPTR:
- case SPA_DATA_TYPE_MEMFD:
- case SPA_DATA_TYPE_DMABUF:
- if (d[0].data == NULL) {
+ switch (SPA_DATA_MEM_TYPE (&d[0])) {
+ case SPA_MEM_TYPE_MEMPTR:
+ case SPA_MEM_TYPE_MEMFD:
+ case SPA_MEM_TYPE_DMABUF:
+ if (SPA_DATA_MEM_PTR (&d[0]) == NULL) {
spa_log_error (this->log, "videotestsrc %p: invalid memory on buffer %p", this, buffers[i]);
continue;
}
- b->ptr = SPA_MEMBER (d[0].data, d[0].offset, void);
- b->stride = d[0].stride;
+ b->ptr = SPA_DATA_CHUNK_PTR (&d[0]);
+ b->stride = SPA_DATA_CHUNK_STRIDE (&d[0]);
break;
default:
break;
diff --git a/spa/plugins/volume/volume.c b/spa/plugins/volume/volume.c
index 4a64e8d4..9e1c7220 100644
--- a/spa/plugins/volume/volume.c
+++ b/spa/plugins/volume/volume.c
@@ -582,10 +582,10 @@ spa_volume_node_process_output (SpaNode *node)
sd = &sbuf->datas[si];
dd = &dbuf->datas[di];
- src = (uint16_t*) ((uint8_t*)sd->data + sd->offset + soff);
- dst = (uint16_t*) ((uint8_t*)dd->data + dd->offset + doff);
+ src = (uint16_t*) ((uint8_t*)SPA_DATA_CHUNK_PTR (sd) + soff);
+ dst = (uint16_t*) ((uint8_t*)SPA_DATA_CHUNK_PTR (dd) + doff);
- n_bytes = SPA_MIN (sd->size - soff, dd->size - doff);
+ n_bytes = SPA_MIN (SPA_DATA_CHUNK_SIZE (sd) - soff, SPA_DATA_CHUNK_SIZE (dd) - doff);
n_samples = n_bytes / sizeof (uint16_t);
for (i = 0; i < n_samples; i++)
@@ -594,11 +594,11 @@ spa_volume_node_process_output (SpaNode *node)
soff += n_bytes;
doff += n_bytes;
- if (soff >= sd->size) {
+ if (soff >= SPA_DATA_CHUNK_SIZE (sd)) {
si++;
soff = 0;
}
- if (doff >= dd->size) {
+ if (doff >= SPA_DATA_CHUNK_SIZE (dd)) {
di++;
doff = 0;
}