Make buffer data point to memory blocks

Make buffer data point to a registered memory block by its mem_id.
Add some more helpers to allocate memfd backed memory.
Allocate buffers in memfd so that we easily share them between client
and server.
Update pts and seq in v4l2 now that this change will actually be visible
at the client.
This commit is contained in:
Wim Taymans 2016-08-03 21:33:57 +02:00
parent 98993c680b
commit 1169c2419b
19 changed files with 383 additions and 356 deletions

View file

@ -21,6 +21,7 @@
#include <stdio.h>
#include <spa/node.h>
#include <spa/memory.h>
#include <spa/audio/format.h>
#define MAX_PORTS 128
@ -590,16 +591,19 @@ add_port_data (SpaAudioMixer *this, SpaBuffer *out, SpaAudioMixerPort *port)
size_t os, is, chunk;
SpaData *odatas = SPA_BUFFER_DATAS (out);
SpaData *idatas = SPA_BUFFER_DATAS (port->buffer);
SpaMemory *mem;
op = ip = NULL;
while (true) {
if (op == NULL) {
op = odatas[oi].ptr;
mem = spa_memory_find (0, odatas[oi].mem_id);
op = (uint8_t*)mem->ptr + odatas[oi].offset;
os = odatas[oi].size;
}
if (ip == NULL) {
ip = idatas[port->buffer_index].ptr;
mem = spa_memory_find (0, idatas[port->buffer_index].mem_id);
ip = (uint8_t*)mem->ptr + odatas[oi].offset;
is = idatas[port->buffer_index].size;
ip += port->buffer_offset;
is -= port->buffer_offset;