diff options
Diffstat (limited to 'spa')
-rw-r--r-- | spa/include/spa/buffer.h | 114 | ||||
-rw-r--r-- | spa/lib/debug.c | 23 | ||||
-rw-r--r-- | spa/plugins/alsa/alsa-sink.c | 10 | ||||
-rw-r--r-- | spa/plugins/alsa/alsa-source.c | 10 | ||||
-rw-r--r-- | spa/plugins/alsa/alsa-utils.c | 20 | ||||
-rw-r--r-- | spa/plugins/audiomixer/audiomixer.c | 20 | ||||
-rw-r--r-- | spa/plugins/audiotestsrc/audiotestsrc.c | 16 | ||||
-rw-r--r-- | spa/plugins/ffmpeg/ffmpeg-enc.c | 2 | ||||
-rw-r--r-- | spa/plugins/v4l2/v4l2-source.c | 1 | ||||
-rw-r--r-- | spa/plugins/v4l2/v4l2-utils.c | 85 | ||||
-rw-r--r-- | spa/plugins/videotestsrc/videotestsrc.c | 16 | ||||
-rw-r--r-- | spa/plugins/volume/volume.c | 18 | ||||
-rw-r--r-- | spa/plugins/xv/xv-sink.c | 2 |
13 files changed, 194 insertions, 143 deletions
diff --git a/spa/include/spa/buffer.h b/spa/include/spa/buffer.h index 1b58c56a..cb0fa61d 100644 --- a/spa/include/spa/buffer.h +++ b/spa/include/spa/buffer.h @@ -43,24 +43,37 @@ typedef enum { SPA_META_TYPE_POINTER, SPA_META_TYPE_VIDEO_CROP, SPA_META_TYPE_RINGBUFFER, + SPA_META_TYPE_SHARED, } SpaMetaType; /** - * SpaDataType: - * @SPA_DATA_TYPE_INVALID: invalid data, should be ignored - * @SPA_DATA_TYPE_MEMPTR: data points to CPU accessible memory - * @SPA_DATA_TYPE_MEMFD: fd is memfd, data can be mmapped - * @SPA_DATA_TYPE_DMABUF: fd is dmabuf, data can be mmapped - * @SPA_DATA_TYPE_ID: data is an id use SPA_PTR_TO_INT32. The definition of + * SpaMemType: + * @SPA_MEM_TYPE_INVALID: invalid ptr, should be ignored + * @SPA_MEM_TYPE_MEMPTR: ptr points to CPU accessible memory + * @SPA_MEM_TYPE_MEMFD: fd is memfd, ptr can be mmapped + * @SPA_MEM_TYPE_DMABUF: fd is dmabuf, ptr can be mmapped + * @SPA_MEM_TYPE_ID: ptr is an id use SPA_PTR_TO_INT32. The definition of * the ID is conveyed in some other way */ typedef enum { - SPA_DATA_TYPE_INVALID = 0, - SPA_DATA_TYPE_MEMPTR, - SPA_DATA_TYPE_MEMFD, - SPA_DATA_TYPE_DMABUF, - SPA_DATA_TYPE_ID, -} SpaDataType; + SPA_MEM_TYPE_INVALID = 0, + SPA_MEM_TYPE_MEMPTR, + SPA_MEM_TYPE_MEMFD, + SPA_MEM_TYPE_DMABUF, + SPA_MEM_TYPE_ID, +} SpaMemType; + +/** + * SpaMemFlag: + * @SPA_MEM_FLAG_NONE: no flags + * @SPA_MEM_FLAG_READ: mem is readable + * @SPA_MEM_FLAG_WRITE: mem is writable + */ +typedef enum { + SPA_MEM_FLAG_NONE = 0, + SPA_MEM_FLAG_READ = (1 << 0), + SPA_MEM_FLAG_WRITE = (1 << 1), +} SpaMemFlag; #include <spa/defs.h> #include <spa/port.h> @@ -132,43 +145,79 @@ typedef struct { } SpaMeta; /** - * SpaData: - * @type: memory type - * @flags: memory flags - * @data: pointer to memory - * @fd: file descriptor - * @maxsize: maximum size of the memory - * @offset: offset in @data - * @size: valid size of @data - * @stride: stride of data if applicable + * SpaMemArea: + * @offset: offset of start of data + * @size: size of the data + * @stride: stride of data + * + * The valid data in a data block. Offset and size are clamped + * to the maxsize of the data block. */ typedef struct { - SpaDataType type; - int flags; - void *data; - int fd; - size_t maxsize; off_t offset; size_t size; ssize_t stride; -} SpaData; +} SpaMemChunk; + +/** + * SpaMem: + * @type: memory type + * @flags: memory flags + * @fd: file descriptor, can be -1 + * @offset: offset in @fd + * @size: maximum size of the memory + * @ptr: pointer to memory, can be NULL + * @chunk: valid memory chunk + * + * A memory block. + */ +typedef struct { + SpaMemType type; + SpaMemFlag flags; + int fd; + off_t offset; + size_t size; + void *ptr; +} SpaMem; + +typedef struct { + SpaMem mem; + SpaMemChunk *chunk; +} SpaMemRef; /** * SpaBuffer: * @id: buffer id * @n_metas: number of metadata - * @metas: offset of array of @n_metas metadata - * @n_datas: number of data pointers - * @datas: offset of array of @n_datas data pointers + * @metas: array of @n_metas metadata + * @n_mems: number of memory blocks + * @mems: array of @n_mems memory blocks */ struct _SpaBuffer { uint32_t id; unsigned int n_metas; SpaMeta *metas; - unsigned int n_datas; - SpaData *datas; + unsigned int n_mems; + SpaMemRef *mems; }; +typedef struct { + SpaMem meta_mem; + SpaMem chunk_mem; +} SpaMetaShared; + +#define SPA_BUFFER_MEM_TYPE(b,n) ((b)->mems[n].mem.type) +#define SPA_BUFFER_MEM_FLAGS(b,n) ((b)->mems[n].mem.flags) +#define SPA_BUFFER_MEM_FD(b,n) ((b)->mems[n].mem.fd) +#define SPA_BUFFER_MEM_OFFSET(b,n) ((b)->mems[n].mem.offset) +#define SPA_BUFFER_MEM_SIZE(b,n) ((b)->mems[n].mem.size) +#define SPA_BUFFER_MEM_PTR(b,n) ((b)->mems[n].mem.ptr) + +#define SPA_BUFFER_OFFSET(b,n) ((b)->mems[n].chunk->offset) +#define SPA_BUFFER_SIZE(b,n) ((b)->mems[n].chunk->size) +#define SPA_BUFFER_STRIDE(b,n) ((b)->mems[n].chunk->stride) +#define SPA_BUFFER_DATA(b,n) (SPA_BUFFER_MEM_PTR (b,n) + SPA_BUFFER_OFFSET (b,n)) + static inline void * spa_buffer_find_meta (SpaBuffer *b, SpaMetaType type) { @@ -189,6 +238,7 @@ spa_meta_type_get_size (SpaMetaType type) sizeof (SpaMetaPointer), sizeof (SpaMetaVideoCrop), sizeof (SpaMetaRingbuffer), + sizeof (SpaMetaShared), }; if (type <= 0 || type >= SPA_N_ELEMENTS (header_sizes)) return 0; diff --git a/spa/lib/debug.c b/spa/lib/debug.c index 02e8bb32..535777f7 100644 --- a/spa/lib/debug.c +++ b/spa/lib/debug.c @@ -177,17 +177,18 @@ spa_debug_buffer (const SpaBuffer *buffer) break; } } - fprintf (stderr, " n_datas: \t%u (at %p)\n", buffer->n_datas, buffer->datas); - for (i = 0; i < buffer->n_datas; i++) { - SpaData *d = &buffer->datas[i]; - fprintf (stderr, " type: %d (%s)\n", d->type, DATA_TYPE_NAME (d->type)); - fprintf (stderr, " flags: %d\n", d->flags); - fprintf (stderr, " data: %p\n", d->data); - fprintf (stderr, " fd: %d\n", d->fd); - fprintf (stderr, " maxsize: %zd\n", d->maxsize); - fprintf (stderr, " offset: %zd\n", d->offset); - fprintf (stderr, " size: %zd\n", d->size); - fprintf (stderr, " stride: %zd\n", d->stride); + fprintf (stderr, " n_datas: \t%u (at %p)\n", buffer->n_mems, buffer->mems); + for (i = 0; i < buffer->n_mems; i++) { + SpaMemRef *m = &buffer->mems[i]; + fprintf (stderr, " type: %d (%s)\n", m->mem.type, DATA_TYPE_NAME (m->mem.type)); + fprintf (stderr, " flags: %d\n", m->mem.flags); + fprintf (stderr, " fd: %d\n", m->mem.fd); + fprintf (stderr, " fd_offset: %zd\n", m->mem.offset); + fprintf (stderr, " fd_size: %zd\n", m->mem.size); + fprintf (stderr, " ptr: %p\n", m->mem.ptr); + fprintf (stderr, " offset: %zd\n", m->chunk->offset); + fprintf (stderr, " size: %zd\n", m->chunk->size); + fprintf (stderr, " stride: %zd\n", m->chunk->stride); } return SPA_RESULT_OK; } diff --git a/spa/plugins/alsa/alsa-sink.c b/spa/plugins/alsa/alsa-sink.c index 736ab3b2..b28bc1e8 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 (buffers[i]->mems[0].type) { + case SPA_MEM_TYPE_MEMFD: + case SPA_MEM_TYPE_DMABUF: + case SPA_MEM_TYPE_MEMPTR: + if (buffers[i]->mems[0].ptr == 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..4f68eab8 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_BUFFER_MEM_TYPE (buffers[i], 0)) { + case SPA_MEM_TYPE_MEMFD: + case SPA_MEM_TYPE_DMABUF: + case SPA_MEM_TYPE_MEMPTR: + if (buffers[i]->mems[0].ptr == 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..1ff8d30c 100644 --- a/spa/plugins/alsa/alsa-utils.c +++ b/spa/plugins/alsa/alsa-utils.c @@ -275,15 +275,15 @@ pull_frames_queue (SpaALSAState *state, b = spa_list_first (&state->ready, SpaALSABuffer, list); - src = SPA_MEMBER (b->outbuf->datas[0].data, b->outbuf->datas[0].offset + state->ready_offset, uint8_t); + src = SPA_MEMBER (SPA_BUFFER_DATA (b->outbuf, 0), 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_BUFFER_SIZE (b->outbuf, 0) - 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_BUFFER_SIZE (b->outbuf, 0)) { SpaNodeEventReuseBuffer rb; spa_list_remove (&b->list); @@ -318,7 +318,7 @@ pull_frames_ringbuffer (SpaALSAState *state, b = state->ringbuffer; - src = SPA_MEMBER (b->outbuf->datas[0].data, b->outbuf->datas[0].offset, void); + src = SPA_BUFFER_DATA (b->outbuf, 0); dst = SPA_MEMBER (my_areas[0].addr, offset * state->frame_size, uint8_t); avail = spa_ringbuffer_get_read_areas (&b->rb->ringbuffer, areas); @@ -442,8 +442,8 @@ 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; + dest = SPA_BUFFER_DATA (b->outbuf, 0); + destsize = SPA_BUFFER_SIZE (b->outbuf, 0); if (b->h) { b->h->seq = state->sample_count; @@ -481,10 +481,12 @@ mmap_read (SpaALSAState *state) if (b) { SpaNodeEventHaveOutput ho; - SpaData *d; + SpaMemChunk *c; - d = b->outbuf->datas; - d[0].size = avail * state->frame_size; + c = b->outbuf->mems[0].chunk; + c->offset = 0; + c->size = avail * state->frame_size; + c->stride = 0; spa_list_insert (state->ready.prev, &b->list); diff --git a/spa/plugins/audiomixer/audiomixer.c b/spa/plugins/audiomixer/audiomixer.c index 654745a8..ae6b7844 100644 --- a/spa/plugins/audiomixer/audiomixer.c +++ b/spa/plugins/audiomixer/audiomixer.c @@ -42,9 +42,9 @@ typedef struct _MixerBuffer MixerBuffer; struct _MixerBuffer { SpaBuffer buffer; - SpaMeta meta[1]; + SpaMeta metas[1]; SpaMetaHeader header; - SpaData data[1]; + SpaMem mems[1]; uint16_t samples[4096]; }; @@ -591,19 +591,19 @@ add_port_data (SpaAudioMixer *this, SpaBuffer *out, SpaAudioMixerPort *port) int i, oi = 0; uint8_t *op, *ip; size_t os, is, chunk; - SpaData *odatas = out->datas; - SpaData *idatas = port->buffer->datas; + SpaMem *omems = out->mems; + SpaMem *imems = port->buffer->mems; op = ip = NULL; while (true) { if (op == NULL) { - op = (uint8_t*)odatas[oi].data + odatas[oi].offset; - os = odatas[oi].size; + op = (uint8_t*)omems[oi].ptr + omems[oi].chunk->offset; + os = omems[oi].chunk->size; } if (ip == NULL) { - ip = (uint8_t*)idatas[port->buffer_index].data + idatas[port->buffer_index].offset; - is = idatas[port->buffer_index].size; + ip = (uint8_t*)imems[port->buffer_index].ptr + imems[port->buffer_index].chunk->offset; + is = imems[port->buffer_index].chunk->size; ip += port->buffer_offset; is -= port->buffer_offset; } @@ -614,7 +614,7 @@ add_port_data (SpaAudioMixer *this, SpaBuffer *out, SpaAudioMixerPort *port) op[i] += ip[i]; if ((is -= chunk) == 0) { - if (++port->buffer_index == port->buffer->n_datas) { + if (++port->buffer_index == port->buffer->n_mems) { port->buffer = NULL; ((SpaPortInput*)port->io)->flags = SPA_PORT_STATUS_FLAG_NEED_INPUT; ((SpaPortOutput*)this->out_ports[0].io)->flags = SPA_PORT_STATUS_FLAG_HAVE_OUTPUT; @@ -628,7 +628,7 @@ add_port_data (SpaAudioMixer *this, SpaBuffer *out, SpaAudioMixerPort *port) port->buffer_queued -= chunk; if ((os -= chunk) == 0) { - if (++oi == out->n_datas) + if (++oi == out->n_mems) break; op = NULL; } diff --git a/spa/plugins/audiotestsrc/audiotestsrc.c b/spa/plugins/audiotestsrc/audiotestsrc.c index 11a024b6..8f8879d7 100644 --- a/spa/plugins/audiotestsrc/audiotestsrc.c +++ b/spa/plugins/audiotestsrc/audiotestsrc.c @@ -675,23 +675,23 @@ spa_audiotestsrc_node_port_use_buffers (SpaNode *node, for (i = 0; i < n_buffers; i++) { ATSBuffer *b; - SpaData *d = buffers[i]->datas; + SpaMem *m = buffers[i]->mems; b = &this->buffers[i]; b->outbuf = buffers[i]; 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 (m[0].type) { + case SPA_MEM_TYPE_MEMPTR: + case SPA_MEM_TYPE_MEMFD: + case SPA_MEM_TYPE_DMABUF: + if (m[0].ptr == 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 = m[0].ptr; + b->size = m[0].size; break; default: break; diff --git a/spa/plugins/ffmpeg/ffmpeg-enc.c b/spa/plugins/ffmpeg/ffmpeg-enc.c index b555c437..c6152aaa 100644 --- a/spa/plugins/ffmpeg/ffmpeg-enc.c +++ b/spa/plugins/ffmpeg/ffmpeg-enc.c @@ -48,7 +48,7 @@ struct _FFMpegBuffer { SpaBuffer buffer; SpaMeta metas[1]; SpaMetaHeader header; - SpaData datas[1]; + SpaMem mems[1]; SpaFFMpegEnc *enc; SpaBuffer *imported; bool outstanding; diff --git a/spa/plugins/v4l2/v4l2-source.c b/spa/plugins/v4l2/v4l2-source.c index 9dafb5f9..cbd717e6 100644 --- a/spa/plugins/v4l2/v4l2-source.c +++ b/spa/plugins/v4l2/v4l2-source.c @@ -61,7 +61,6 @@ struct _V4l2Buffer { bool outstanding; bool allocated; struct v4l2_buffer v4l2_buffer; -// V4l2Buffer *next; SpaList list; }; diff --git a/spa/plugins/v4l2/v4l2-utils.c b/spa/plugins/v4l2/v4l2-utils.c index de291aa1..79a40beb 100644 --- a/spa/plugins/v4l2/v4l2-utils.c +++ b/spa/plugins/v4l2/v4l2-utils.c @@ -116,11 +116,11 @@ spa_v4l2_clear_buffers (SpaV4l2Source *this) 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 (b->outbuf->mems[0].ptr) + munmap (b->outbuf->mems[0].ptr, b->outbuf->mems[0].size); + if (b->outbuf->mems[0].fd != -1) + close (b->outbuf->mems[0].fd); + b->outbuf->mems[0].type = SPA_MEM_TYPE_INVALID; } } @@ -840,7 +840,7 @@ mmap_read (SpaV4l2Source *this) SpaV4l2State *state = &this->state[0]; struct v4l2_buffer buf; V4l2Buffer *b; - SpaData *d; + SpaMemChunk *mc; int64_t pts; CLEAR(buf); @@ -875,8 +875,10 @@ mmap_read (SpaV4l2Source *this) b->h->pts = pts; } - d = b->outbuf->datas; - d[0].size = buf.bytesused; + mc = b->outbuf->mems[0].chunk; + mc->offset = 0; + mc->size = buf.bytesused; + mc->stride = state->fmt.fmt.pix.bytesperline; spa_list_insert (state->ready.prev, &b->list); @@ -910,15 +912,14 @@ spa_v4l2_use_buffers (SpaV4l2Source *this, SpaBuffer **buffers, uint32_t n_buffe SpaV4l2State *state = &this->state[0]; struct v4l2_requestbuffers reqbuf; int i; - SpaData *d; if (n_buffers > 0) { - switch (buffers[0]->datas[0].type) { - case SPA_DATA_TYPE_MEMPTR: - case SPA_DATA_TYPE_MEMFD: + switch (buffers[0]->mems[0].type) { + 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: @@ -944,6 +945,7 @@ spa_v4l2_use_buffers (SpaV4l2Source *this, SpaBuffer **buffers, uint32_t n_buffe for (i = 0; i < reqbuf.count; i++) { V4l2Buffer *b; + SpaMem *m; b = &state->buffers[i]; b->outbuf = buffers[i]; @@ -953,28 +955,28 @@ spa_v4l2_use_buffers (SpaV4l2Source *this, SpaBuffer **buffers, uint32_t n_buffe spa_log_info (state->log, "v4l2: import buffer %p", buffers[i]); - if (buffers[i]->n_datas < 1) { + if (buffers[i]->n_mems < 1) { spa_log_error (state->log, "v4l2: invalid memory on buffer %p", buffers[i]); continue; } - d = buffers[i]->datas; + m = buffers[i]->mems; CLEAR (b->v4l2_buffer); 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 (m[0].type) { + case SPA_MEM_TYPE_MEMPTR: + case SPA_MEM_TYPE_MEMFD: + if (m[0].ptr == 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_MEMBER (m[0].ptr, m[0].offset, void *); + b->v4l2_buffer.length = m[0].size; break; - case SPA_DATA_TYPE_DMABUF: - b->v4l2_buffer.m.fd = d[0].fd; + case SPA_MEM_TYPE_DMABUF: + b->v4l2_buffer.m.fd = m[0].fd; break; default: break; @@ -1021,9 +1023,9 @@ mmap_init (SpaV4l2Source *this, for (i = 0; i < reqbuf.count; i++) { V4l2Buffer *b; - SpaData *d; + SpaMem *m; - if (buffers[i]->n_datas < 1) { + if (buffers[i]->n_mems < 1) { spa_log_error (state->log, "v4l2: invalid buffer data"); return SPA_RESULT_ERROR; } @@ -1044,11 +1046,9 @@ mmap_init (SpaV4l2Source *this, return SPA_RESULT_ERROR; } - 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; + m = buffers[i]->mems; + m[0].flags = SPA_MEM_FLAG_READ; + m[0].size = b->v4l2_buffer.length; if (state->export_buf) { struct v4l2_exportbuffer expbuf; @@ -1061,19 +1061,20 @@ mmap_init (SpaV4l2Source *this, perror("VIDIOC_EXPBUF"); continue; } - d[0].type = SPA_DATA_TYPE_DMABUF; - d[0].fd = expbuf.fd; - d[0].data = NULL; + m[0].type = SPA_MEM_TYPE_DMABUF; + m[0].fd = expbuf.fd; + m[0].offset = 0; + m[0].ptr = 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) { + m[0].type = SPA_MEM_TYPE_MEMPTR; + m[0].fd = -1; + m[0].ptr = mmap (NULL, + b->v4l2_buffer.length, + PROT_READ, + MAP_SHARED, + state->fd, + b->v4l2_buffer.m.offset); + if (m[0].ptr == MAP_FAILED) { perror ("mmap"); continue; } diff --git a/spa/plugins/videotestsrc/videotestsrc.c b/spa/plugins/videotestsrc/videotestsrc.c index be8cf93b..7a2dfecd 100644 --- a/spa/plugins/videotestsrc/videotestsrc.c +++ b/spa/plugins/videotestsrc/videotestsrc.c @@ -57,7 +57,6 @@ struct _VTSBuffer { bool outstanding; SpaMetaHeader *h; void *ptr; - size_t stride; SpaList list; }; @@ -642,23 +641,22 @@ spa_videotestsrc_node_port_use_buffers (SpaNode *node, for (i = 0; i < n_buffers; i++) { VTSBuffer *b = &this->buffers[i]; - SpaData *d = buffers[i]->datas; + SpaMem *m = buffers[i]->mems; b = &this->buffers[i]; b->outbuf = buffers[i]; 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 (m[0].type) { + case SPA_MEM_TYPE_MEMPTR: + case SPA_MEM_TYPE_MEMFD: + case SPA_MEM_TYPE_DMABUF: + if (m[0].ptr == 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 = m[0].ptr; break; default: break; diff --git a/spa/plugins/volume/volume.c b/spa/plugins/volume/volume.c index 4a64e8d4..b5318ddd 100644 --- a/spa/plugins/volume/volume.c +++ b/spa/plugins/volume/volume.c @@ -543,7 +543,7 @@ spa_volume_node_process_output (SpaNode *node) SpaVolumePort *port; unsigned int si, di, i, n_samples, n_bytes, soff, doff ; SpaBuffer *sbuf, *dbuf; - SpaData *sd, *dd; + SpaMem *sm, *dm; uint16_t *src, *dst; double volume; SpaPortInput *input; @@ -576,16 +576,16 @@ spa_volume_node_process_output (SpaNode *node) soff = doff = 0; while (true) { - if (si == sbuf->n_datas || di == dbuf->n_datas) + if (si == sbuf->n_mems || di == dbuf->n_mems) break; - sd = &sbuf->datas[si]; - dd = &dbuf->datas[di]; + sm = &sbuf->mems[si]; + dm = &sbuf->mems[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*)sm->ptr + sm->chunk->offset + soff); + dst = (uint16_t*) ((uint8_t*)dm->ptr + dm->chunk->offset + doff); - n_bytes = SPA_MIN (sd->size - soff, dd->size - doff); + n_bytes = SPA_MIN (sm->chunk->size - soff, dm->chunk->size - 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 >= sm->chunk->size) { si++; soff = 0; } - if (doff >= dd->size) { + if (doff >= dm->chunk->size) { di++; doff = 0; } diff --git a/spa/plugins/xv/xv-sink.c b/spa/plugins/xv/xv-sink.c index 12e0a593..f1be7700 100644 --- a/spa/plugins/xv/xv-sink.c +++ b/spa/plugins/xv/xv-sink.c @@ -55,7 +55,7 @@ struct _XvBuffer { SpaBuffer buffer; SpaMeta meta[1]; SpaMetaHeader header; - SpaData data[1]; + SpaMem mems[1]; XvBuffer *next; uint32_t index; SpaXvSink *sink; |