mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
buffer: add ptr_type to the data
We can give more info about the memory or fd that way and we can also pass other structures as data later if we need to.
This commit is contained in:
parent
16d2a3a69c
commit
61caf0e19c
9 changed files with 44 additions and 31 deletions
|
|
@ -232,7 +232,8 @@ pull_input (SpaALSASink *this, void *data, snd_pcm_uframes_t frames)
|
|||
buffer->meta[0].size = sizeof (buffer->header);
|
||||
|
||||
buffer->data[0].type = SPA_DATA_TYPE_MEMPTR;
|
||||
buffer->data[0].data = data;
|
||||
buffer->data[0].ptr = data;
|
||||
buffer->data[0].ptr_type = "sysmem";
|
||||
buffer->data[0].size = frames * sizeof (uint16_t) * 2;
|
||||
|
||||
this->event_cb (&this->handle, &event,this->user_data);
|
||||
|
|
|
|||
|
|
@ -548,7 +548,8 @@ pull_port (SpaAudioMixer *this, uint32_t port_id, SpaOutputInfo *info, size_t pu
|
|||
buffer->meta[0].size = sizeof (buffer->header);
|
||||
|
||||
buffer->data[0].type = SPA_DATA_TYPE_MEMPTR;
|
||||
buffer->data[0].data = buffer->samples;
|
||||
buffer->data[0].ptr = buffer->samples;
|
||||
buffer->data[0].ptr_type = "sysmem";
|
||||
buffer->data[0].size = pull_size;
|
||||
|
||||
this->event_cb (&this->handle, &event, this->user_data);
|
||||
|
|
@ -565,11 +566,11 @@ add_port_data (SpaAudioMixer *this, SpaBuffer *out, SpaAudioMixerPort *port)
|
|||
|
||||
while (true) {
|
||||
if (op == NULL) {
|
||||
op = out->datas[oi].data;
|
||||
op = out->datas[oi].ptr;
|
||||
os = out->datas[oi].size;
|
||||
}
|
||||
if (ip == NULL) {
|
||||
ip = port->buffer->datas[port->buffer_index].data;
|
||||
ip = port->buffer->datas[port->buffer_index].ptr;
|
||||
is = port->buffer->datas[port->buffer_index].size;
|
||||
ip += port->buffer_offset;
|
||||
is -= port->buffer_offset;
|
||||
|
|
|
|||
|
|
@ -467,7 +467,7 @@ spa_audiotestsrc_node_port_pull_output (SpaHandle *handle,
|
|||
continue;
|
||||
}
|
||||
|
||||
ptr = info[i].buffer->datas[0].data;
|
||||
ptr = info[i].buffer->datas[0].ptr;
|
||||
size = info[i].buffer->datas[0].size;
|
||||
|
||||
for (j = 0; j < size; j++)
|
||||
|
|
|
|||
|
|
@ -459,7 +459,7 @@ spa_v4l2_import_buffers (SpaV4l2Source *this, SpaBuffer **buffers, uint32_t n_bu
|
|||
b->v4l2_buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
b->v4l2_buffer.memory = state->memtype;
|
||||
b->v4l2_buffer.index = i;
|
||||
b->v4l2_buffer.m.userptr = (unsigned long) b->buffer.datas[0].data;
|
||||
b->v4l2_buffer.m.userptr = (unsigned long) b->buffer.datas[0].ptr;
|
||||
b->v4l2_buffer.length = b->buffer.datas[0].size;
|
||||
|
||||
v4l2_buffer_free (b);
|
||||
|
|
@ -542,22 +542,24 @@ mmap_init (SpaV4l2Source *this)
|
|||
|
||||
b->dmafd = expbuf.fd;
|
||||
b->datas[0].type = SPA_DATA_TYPE_FD;
|
||||
b->datas[0].data = &b->dmafd;
|
||||
b->datas[0].ptr = &b->dmafd;
|
||||
b->datas[0].ptr_type = "dmabuf";
|
||||
b->datas[0].offset = 0;
|
||||
b->datas[0].size = buf.length;
|
||||
b->datas[0].stride = state->fmt.fmt.pix.bytesperline;
|
||||
} else {
|
||||
b->datas[0].type = SPA_DATA_TYPE_MEMPTR;
|
||||
b->datas[0].data = mmap (NULL,
|
||||
buf.length,
|
||||
PROT_READ | PROT_WRITE,
|
||||
MAP_SHARED,
|
||||
state->fd,
|
||||
buf.m.offset);
|
||||
b->datas[0].ptr_type = "sysmem";
|
||||
b->datas[0].ptr = mmap (NULL,
|
||||
buf.length,
|
||||
PROT_READ | PROT_WRITE,
|
||||
MAP_SHARED,
|
||||
state->fd,
|
||||
buf.m.offset);
|
||||
b->datas[0].offset = 0;
|
||||
b->datas[0].size = buf.length;
|
||||
b->datas[0].stride = state->fmt.fmt.pix.bytesperline;
|
||||
if (b->datas[0].data == MAP_FAILED) {
|
||||
if (b->datas[0].ptr == MAP_FAILED) {
|
||||
perror ("mmap");
|
||||
continue;
|
||||
}
|
||||
|
|
@ -662,7 +664,7 @@ spa_v4l2_stop (SpaV4l2Source *this)
|
|||
if (state->export_buf) {
|
||||
close (b->dmafd);
|
||||
} else {
|
||||
munmap (b->datas[0].data, b->datas[0].size);
|
||||
munmap (b->datas[0].ptr, b->datas[0].size);
|
||||
}
|
||||
}
|
||||
state->have_buffers = false;
|
||||
|
|
|
|||
|
|
@ -520,8 +520,8 @@ spa_volume_node_port_pull_output (SpaHandle *handle,
|
|||
di++;
|
||||
continue;
|
||||
}
|
||||
src = (uint16_t*) ((uint8_t*)sd->data + soff);
|
||||
dst = (uint16_t*) ((uint8_t*)dd->data + doff);
|
||||
src = (uint16_t*) ((uint8_t*)sd->ptr + soff);
|
||||
dst = (uint16_t*) ((uint8_t*)dd->ptr + doff);
|
||||
|
||||
n_bytes = MIN (sd->size - soff, dd->size - doff);
|
||||
n_samples = n_bytes / sizeof (uint16_t);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue