Commit 265c852c authored by Wim Taymans's avatar Wim Taymans
Browse files

Try a different way of doing buffer memory

parent 5e8a3afe
......@@ -278,7 +278,7 @@ typedef struct {
SpaDirection direction;
uint32_t port_id;
uint32_t mem_id;
SpaDataType type;
SpaMemType type;
int memfd;
uint32_t flags;
off_t offset;
......@@ -291,13 +291,31 @@ typedef struct {
size_t size;
} PinosMessageMemRef;
typedef struct {
SpaMetaType type;
PinosMessageMemRef meta;
} PinosMessageBufferMeta;
typedef struct {
PinosMessageMemRef mem;
PinosMessageMemRef chunk;
} PinosMessageBufferMem;
typedef struct {
uint32_t id;
uint32_t n_metas;
PinosMessageBufferMeta *metas;
uint32_t n_mems;
PinosMessageBufferMem *mems;
} PinosMessageBuffer;
/* PINOS_MESSAGE_USE_BUFFERS */
typedef struct {
uint32_t seq;
SpaDirection direction;
uint32_t port_id;
unsigned int n_buffers;
PinosMessageMemRef *buffers;
PinosMessageBuffer *buffers;
} PinosMessageUseBuffers;
PinosConnection * pinos_connection_new (int fd);
......
......@@ -31,8 +31,8 @@ pinos_serialize_buffer_get_size (const SpaBuffer *buffer)
size = sizeof (SpaBuffer);
for (i = 0; i < buffer->n_metas; i++)
size += sizeof (SpaMeta) + buffer->metas[i].size;
for (i = 0; i < buffer->n_datas; i++)
size += sizeof (SpaData);
for (i = 0; i < buffer->n_mems; i++)
size += sizeof (SpaMem);
return size;
}
......@@ -41,7 +41,7 @@ pinos_serialize_buffer_serialize (void *dest, const SpaBuffer *buffer)
{
SpaBuffer *tb;
SpaMeta *mp;
SpaData *dp;
SpaMem *dp;
void *p;
unsigned int i;
......@@ -51,11 +51,11 @@ pinos_serialize_buffer_serialize (void *dest, const SpaBuffer *buffer)
tb = dest;
memcpy (tb, buffer, sizeof (SpaBuffer));
mp = SPA_MEMBER (tb, sizeof(SpaBuffer), SpaMeta);
dp = SPA_MEMBER (mp, sizeof(SpaMeta) * tb->n_metas, SpaData);
p = SPA_MEMBER (dp, sizeof(SpaData) * tb->n_datas, void);
dp = SPA_MEMBER (mp, sizeof(SpaMeta) * tb->n_metas, SpaMem);
p = SPA_MEMBER (dp, sizeof(SpaMem) * tb->n_mems, void);
tb->metas = SPA_INT_TO_PTR (SPA_PTRDIFF (mp, tb));
tb->datas = SPA_INT_TO_PTR (SPA_PTRDIFF (dp, tb));
tb->mems = SPA_INT_TO_PTR (SPA_PTRDIFF (dp, tb));
for (i = 0; i < tb->n_metas; i++) {
memcpy (&mp[i], &buffer->metas[i], sizeof (SpaMeta));
......@@ -63,8 +63,8 @@ pinos_serialize_buffer_serialize (void *dest, const SpaBuffer *buffer)
mp[i].data = SPA_INT_TO_PTR (SPA_PTRDIFF (p, tb));
p += mp[i].size;
}
for (i = 0; i < tb->n_datas; i++)
memcpy (&dp[i], &buffer->datas[i], sizeof (SpaData));
for (i = 0; i < tb->n_mems; i++)
memcpy (&dp[i], &buffer->mems[i], sizeof (SpaMem));
return SPA_PTRDIFF (p, tb);
}
......@@ -83,9 +83,13 @@ pinos_serialize_buffer_deserialize (void *src, off_t offset)
if (m->data)
m->data = SPA_MEMBER (b, SPA_PTR_TO_INT (m->data), void);
}
if (b->datas)
b->datas = SPA_MEMBER (b, SPA_PTR_TO_INT (b->datas), SpaData);
if (b->mems)
b->mems = SPA_MEMBER (b, SPA_PTR_TO_INT (b->mems), SpaMem);
for (i = 0; i < b->n_mems; i++) {
SpaMem *m = &b->mems[i];
if (m->chunk)
m->chunk = SPA_MEMBER (b, SPA_PTR_TO_INT (m->chunk), void);
}
return b;
}
......
......@@ -52,7 +52,7 @@ typedef struct {
bool used;
void *buf_ptr;
SpaBuffer *buf;
SpaData *datas;
SpaMem *mems;
} BufferId;
typedef struct
......@@ -462,8 +462,8 @@ on_rtsocket_condition (SpaSource *source,
continue;
if ((bid = find_buffer (stream, input->buffer_id))) {
for (i = 0; i < bid->buf->n_datas; i++) {
bid->buf->datas[i].size = bid->datas[i].size;
for (i = 0; i < bid->buf->n_mems; i++) {
SPA_BUFFER_SIZE (bid->buf, i) = SPA_BUFFER_SIZE (bid, i);
}
pinos_signal_emit (&stream->new_buffer, stream, bid->id);
}
......@@ -703,17 +703,17 @@ stream_dispatch_func (void *object,
m = SPA_MEMBER (b, SPA_PTR_TO_INT (b->metas), SpaMeta);
for (i = 0; i < b->n_metas; i++)
size += sizeof (SpaMeta) + m[i].size;
for (i = 0; i < b->n_datas; i++)
size += sizeof (SpaData);
for (i = 0; i < b->n_mems; i++)
size += sizeof (SpaMem);
b = bid->buf = malloc (size);
memcpy (b, bid->buf_ptr, size);
if (b->metas)
b->metas = SPA_MEMBER (b, SPA_PTR_TO_INT (b->metas), SpaMeta);
if (b->datas) {
bid->datas = SPA_MEMBER (bid->buf_ptr, SPA_PTR_TO_INT (b->datas), SpaData);
b->datas = SPA_MEMBER (b, SPA_PTR_TO_INT (b->datas), SpaData);
if (b->mems) {
bid->mems = SPA_MEMBER (bid->buf_ptr, SPA_PTR_TO_INT (b->mems), SpaMem);
b->mems = SPA_MEMBER (b, SPA_PTR_TO_INT (b->mems), SpaMem);
}
}
......@@ -731,28 +731,28 @@ stream_dispatch_func (void *object,
m->data = SPA_MEMBER (bid->buf_ptr, SPA_PTR_TO_INT (m->data), void);
}
for (j = 0; j < b->n_datas; j++) {
SpaData *d = &b->datas[j];
for (j = 0; j < b->n_mems; j++) {
SpaMem *m = &b->mems[j];
switch (d->type) {
case SPA_DATA_TYPE_ID:
switch (m->type) {
case SPA_MEM_TYPE_ID:
{
MemId *bmid = find_mem (stream, SPA_PTR_TO_UINT32 (d->data));
d->type = SPA_DATA_TYPE_MEMFD;
d->data = NULL;
d->fd = bmid->fd;
MemId *bmid = find_mem (stream, SPA_PTR_TO_UINT32 (m->ptr));
m->type = SPA_MEM_TYPE_MEMFD;
m->ptr = NULL;
m->fd = bmid->fd;
pinos_log_debug (" data %d %u -> fd %d", j, bmid->id, bmid->fd);
break;
}
case SPA_DATA_TYPE_MEMPTR:
case SPA_MEM_TYPE_MEMPTR:
{
d->data = SPA_MEMBER (bid->buf_ptr, SPA_PTR_TO_INT (d->data), void);
d->fd = -1;
pinos_log_debug (" data %d %u -> mem %p", j, bid->id, d->data);
m->ptr = SPA_MEMBER (bid->buf_ptr, SPA_PTR_TO_INT (m->ptr), void);
m->fd = -1;
pinos_log_debug (" data %d %u -> mem %p", j, bid->id, m->ptr);
break;
}
default:
pinos_log_warn ("unknown buffer data type %d", d->type);
pinos_log_warn ("unknown buffer data type %d", m->type);
break;
}
}
......@@ -1096,8 +1096,8 @@ pinos_stream_send_buffer (PinosStream *stream,
uint8_t cmd = PINOS_TRANSPORT_CMD_HAVE_DATA;
bid->used = true;
for (i = 0; i < bid->buf->n_datas; i++) {
bid->datas[i].size = bid->buf->datas[i].size;
for (i = 0; i < bid->buf->n_mems; i++) {
SPA_BUFFER_SIZE (bid, i) = SPA_BUFFER_SIZE (bid->buf, i);
}
impl->trans->outputs[0].buffer_id = id;
impl->trans->outputs[0].status = SPA_RESULT_OK;
......
......@@ -394,22 +394,22 @@ on_add_buffer (PinosListener *listener,
break;
}
}
for (i = 0; i < b->n_datas; i++) {
SpaData *d = &b->datas[i];
for (i = 0; i < b->n_mems; i++) {
SpaMem *m = &b->mems[i];
GstMemory *gmem = NULL;
switch (d->type) {
case SPA_DATA_TYPE_MEMFD:
case SPA_DATA_TYPE_DMABUF:
switch (m->type) {
case SPA_MEM_TYPE_MEMFD:
case SPA_MEM_TYPE_DMABUF:
{
gmem = gst_fd_allocator_alloc (pinossink->allocator, dup (d->fd),
d->maxsize, GST_FD_MEMORY_FLAG_NONE);
gst_memory_resize (gmem, d->offset, d->size);
gmem = gst_fd_allocator_alloc (pinossink->allocator, dup (m->fd),
m->size, GST_FD_MEMORY_FLAG_NONE);
gst_memory_resize (gmem, m->offset + m->chunk->offset, m->chunk->size);
break;
}
case SPA_DATA_TYPE_MEMPTR:
gmem = gst_memory_new_wrapped (0, d->data, d->maxsize, d->offset,
d->size, NULL, NULL);
case SPA_MEM_TYPE_MEMPTR:
gmem = gst_memory_new_wrapped (0, m->ptr, m->size, m->chunk->offset,
m->chunk->size, NULL, NULL);
break;
default:
break;
......@@ -641,11 +641,11 @@ gst_pinos_sink_render (GstBaseSink * bsink, GstBuffer * buffer)
data->header->pts = GST_BUFFER_PTS (buffer);
data->header->dts_offset = GST_BUFFER_DTS (buffer);
}
for (i = 0; i < data->buf->n_datas; i++) {
SpaData *d = &data->buf->datas[i];
for (i = 0; i < data->buf->n_mems; i++) {
SpaMem *m = &data->buf->mems[i];
GstMemory *mem = gst_buffer_peek_memory (buffer, i);
d->offset = mem->offset;
d->size = mem->size;
m->chunk->offset = mem->offset;
m->chunk->size = mem->size;
}
gst_buffer_ref (buffer);
......
......@@ -408,22 +408,22 @@ on_add_buffer (PinosListener *listener,
break;
}
}
for (i = 0; i < b->n_datas; i++) {
SpaData *d = &b->datas[i];
for (i = 0; i < b->n_mems; i++) {
SpaMem *m = &b->mems[i];
GstMemory *gmem = NULL;
switch (d->type) {
case SPA_DATA_TYPE_MEMFD:
case SPA_DATA_TYPE_DMABUF:
switch (m->type) {
case SPA_MEM_TYPE_MEMFD:
case SPA_MEM_TYPE_DMABUF:
{
gmem = gst_fd_allocator_alloc (pinossrc->fd_allocator, dup (d->fd),
d->maxsize, GST_FD_MEMORY_FLAG_NONE);
gst_memory_resize (gmem, d->offset, d->size);
gmem = gst_fd_allocator_alloc (pinossrc->fd_allocator, dup (m->fd),
m->size, GST_FD_MEMORY_FLAG_NONE);
gst_memory_resize (gmem, m->offset + m->chunk->offset, m->chunk->size);
break;
}
case SPA_DATA_TYPE_MEMPTR:
gmem = gst_memory_new_wrapped (0, d->data, d->maxsize, d->offset,
d->size, NULL, NULL);
case SPA_MEM_TYPE_MEMPTR:
gmem = gst_memory_new_wrapped (0, m->ptr, m->size, m->chunk->offset,
m->chunk->size, NULL, NULL);
default:
break;
}
......@@ -485,11 +485,11 @@ on_new_buffer (PinosListener *listener,
}
GST_BUFFER_OFFSET (buf) = h->seq;
}
for (i = 0; i < data->buf->n_datas; i++) {
SpaData *d = &data->buf->datas[i];
for (i = 0; i < data->buf->n_mems; i++) {
SpaMem *m = &data->buf->mems[i];
GstMemory *mem = gst_buffer_peek_memory (buf, i);
mem->offset = d->offset;
mem->size = d->size;
mem->offset = m->chunk->offset;
mem->size = m->chunk->size;
}
g_queue_push_tail (&pinossrc->queue, buf);
......
......@@ -62,7 +62,7 @@ struct _ProxyBuffer {
SpaBuffer *outbuf;
SpaBuffer buffer;
SpaMeta metas[4];
SpaData datas[4];
SpaMem mems[4];
off_t offset;
size_t size;
bool outstanding;
......@@ -638,8 +638,8 @@ spa_proxy_node_port_use_buffers (SpaNode *node,
b->outbuf = buffers[i];
memcpy (&b->buffer, buffers[i], sizeof (SpaBuffer));
b->buffer.datas = b->datas;
b->buffer.metas = b->metas;
b->buffer.mems = b->mems;
b->size = SPA_ROUND_UP_N (pinos_serialize_buffer_get_size (buffers[i]), 64);
b->offset = size;
......@@ -648,38 +648,37 @@ spa_proxy_node_port_use_buffers (SpaNode *node,
memcpy (&b->buffer.metas[j], &buffers[i]->metas[j], sizeof (SpaMeta));
}
for (j = 0; j < buffers[i]->n_datas; j++) {
SpaData *d = &buffers[i]->datas[j];
for (j = 0; j < buffers[i]->n_mems; j++) {
SpaMem *m = &buffers[i]->mems[j];
memcpy (&b->buffer.datas[j], d, sizeof (SpaData));
memcpy (&b->buffer.mems[j], m, sizeof (SpaMem));
switch (d->type) {
case SPA_DATA_TYPE_DMABUF:
case SPA_DATA_TYPE_MEMFD:
switch (m->type) {
case SPA_MEM_TYPE_DMABUF:
case SPA_MEM_TYPE_MEMFD:
am.direction = direction;
am.port_id = port_id;
am.mem_id = n_mem;
am.type = d->type;
am.memfd = d->fd;
am.flags = d->flags;
am.offset = d->offset;
am.size = d->maxsize;
am.type = m->type;
am.memfd = m->fd;
am.flags = m->flags;
am.offset = m->offset;
am.size = m->size;
pinos_resource_send_message (this->resource,
PINOS_MESSAGE_ADD_MEM,
&am,
false);
b->buffer.datas[j].type = SPA_DATA_TYPE_ID;
b->buffer.datas[j].data = SPA_UINT32_TO_PTR (n_mem);
b->buffer.mems[j].type = SPA_MEM_TYPE_ID;
b->buffer.mems[j].ptr = SPA_UINT32_TO_PTR (n_mem);
n_mem++;
break;
case SPA_DATA_TYPE_MEMPTR:
b->buffer.datas[j].data = SPA_INT_TO_PTR (b->size);
b->size += d->size;
case SPA_MEM_TYPE_MEMPTR:
b->buffer.mems[j].ptr = SPA_INT_TO_PTR (b->size);
break;
default:
b->buffer.datas[j].type = SPA_DATA_TYPE_INVALID;
b->buffer.datas[j].data = 0;
spa_log_error (this->log, "invalid memory type %d", d->type);
b->buffer.mems[j].type = SPA_MEM_TYPE_INVALID;
b->buffer.mems[j].ptr = 0;
spa_log_error (this->log, "invalid memory type %d", m->type);
break;
}
}
......@@ -703,29 +702,32 @@ spa_proxy_node_port_use_buffers (SpaNode *node,
ProxyBuffer *b = &port->buffers[i];
SpaBuffer *sb;
SpaMeta *sbm;
SpaData *sbd;
SpaMem *sbmem;
pinos_serialize_buffer_serialize (p, &b->buffer);
sb = p;
b->buffer.datas = SPA_MEMBER (sb, SPA_PTR_TO_INT (sb->datas), SpaData);
b->buffer.mems = SPA_MEMBER (sb, SPA_PTR_TO_INT (sb->mems), SpaMem);
sbm = SPA_MEMBER (sb, SPA_PTR_TO_INT (sb->metas), SpaMeta);
sbd = SPA_MEMBER (sb, SPA_PTR_TO_INT (sb->datas), SpaData);
sbmem = SPA_MEMBER (sb, SPA_PTR_TO_INT (sb->mems), SpaMem);
for (j = 0; j < b->buffer.n_metas; j++)
b->metas[j].data = SPA_MEMBER (sb, SPA_PTR_TO_INT (sbm[j].data), void);
for (j = 0; j < b->buffer.n_datas; j++) {
if (b->datas[j].type == SPA_DATA_TYPE_MEMPTR)
b->datas[j].data = SPA_MEMBER (sb, SPA_PTR_TO_INT (sbd[j].data), void);
for (j = 0; j < b->buffer.n_mems; j++) {
if (b->mems[j].type == SPA_MEM_TYPE_MEMPTR)
b->mems[j].ptr = SPA_MEMBER (sb, SPA_PTR_TO_INT (sbmem[j].ptr), void);
}
p += b->size;
spa_debug_buffer (b->outbuf);
spa_debug_buffer (&b->buffer);
}
am.direction = direction;
am.port_id = port_id;
am.mem_id = port->buffer_mem_id;
am.type = SPA_DATA_TYPE_MEMFD;
am.type = SPA_MEM_TYPE_MEMFD;
am.memfd = port->buffer_mem.fd;
am.flags = 0;
am.offset = 0;
......@@ -795,13 +797,15 @@ copy_meta_in (SpaProxy *this, SpaProxyPort *port, uint32_t buffer_id)
for (i = 0; i < b->outbuf->n_metas; i++) {
SpaMeta *sm = &b->buffer.metas[i];
SpaMeta *dm = &b->outbuf->metas[i];
spa_log_info (this->log, "%d/%d memcpy meta %p -> %p %zd", i, b->outbuf->n_metas,
sm->data, dm->data, dm->size);
memcpy (dm->data, sm->data, dm->size);
}
for (i = 0; i < b->outbuf->n_datas; i++) {
b->outbuf->datas[i].size = b->buffer.datas[i].size;
if (b->outbuf->datas[i].type == SPA_DATA_TYPE_MEMPTR) {
spa_log_info (this->log, "memcpy in %zd", b->buffer.datas[i].size);
memcpy (b->outbuf->datas[i].data, b->datas[i].data, b->buffer.datas[i].size);
for (i = 0; i < b->outbuf->n_mems; i++) {
SPA_BUFFER_SIZE (b->outbuf, i) = SPA_BUFFER_SIZE (&b->buffer, i);
if (SPA_BUFFER_MEM_TYPE (b->outbuf, i) == SPA_MEM_TYPE_MEMPTR) {
spa_log_info (this->log, "memcpy in %zd", SPA_BUFFER_SIZE (&b->buffer, i));
memcpy (b->outbuf->mems[i].ptr, b->mems[i].ptr, SPA_BUFFER_SIZE (&b->buffer, i));
}
}
}
......@@ -817,11 +821,11 @@ copy_meta_out (SpaProxy *this, SpaProxyPort *port, uint32_t buffer_id)
SpaMeta *dm = &b->buffer.metas[i];
memcpy (dm->data, sm->data, dm->size);
}
for (i = 0; i < b->outbuf->n_datas; i++) {
b->buffer.datas[i].size = b->outbuf->datas[i].size;
if (b->datas[i].type == SPA_DATA_TYPE_MEMPTR) {
spa_log_info (this->log, "memcpy out %zd", b->outbuf->datas[i].size);
memcpy (b->datas[i].data, b->outbuf->datas[i].data, b->outbuf->datas[i].size);
for (i = 0; i < b->outbuf->n_mems; i++) {
SPA_BUFFER_SIZE (&b->buffer, i) = SPA_BUFFER_SIZE (b->outbuf, i);
if (b->mems[i].type == SPA_MEM_TYPE_MEMPTR) {
spa_log_info (this->log, "memcpy out %zd", SPA_BUFFER_SIZE (b->outbuf, i));
memcpy (b->mems[i].ptr, b->outbuf->mems[i].ptr, SPA_BUFFER_SIZE (b->outbuf, i));
}
}
}
......
......@@ -318,54 +318,69 @@ do_allocation (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
pinos_log_debug ("reusing %d output buffers %p", impl->n_buffers, impl->buffers);
} else {
unsigned int i, j;
size_t hdr_size, buf_size, arr_size;
void *p;
unsigned int n_metas, n_datas;
size_t hdr_size, buf_size, arr_size, meta_size;
void *meta_p, *chunk_p, *data_p;
unsigned int n_metas, n_mems;
n_metas = 0;
n_datas = 1;
n_mems = 1;
hdr_size = sizeof (SpaBuffer);
hdr_size += n_datas * sizeof (SpaData);
impl->n_buffers = max_buffers;
/* buffer size contains, the data + metadata + chunk info. This allocated
* in shared memory. */
buf_size = minsize * blocks;
buf_size += n_mems * sizeof (SpaMemChunk);
meta_size = 0;
for (i = 0; i < oinfo->n_params; i++) {
SpaAllocParam *ap = oinfo->params[i];
if (ap->type == SPA_ALLOC_PARAM_TYPE_META_ENABLE) {
SpaAllocParamMetaEnable *pme = (SpaAllocParamMetaEnable *) ap;
hdr_size += spa_meta_type_get_size (pme->type);
meta_size += spa_meta_type_get_size (pme->type);
n_metas++;
}
}
hdr_size += n_metas * sizeof (SpaMeta);
buf_size = SPA_ROUND_UP_N (hdr_size + (minsize * blocks), 64);
buf_size += meta_size;
buf_size = SPA_ROUND_UP_N (buf_size, 64);
impl->n_buffers = max_buffers;
pinos_memblock_alloc (PINOS_MEMBLOCK_FLAG_WITH_FD |
PINOS_MEMBLOCK_FLAG_MAP_READWRITE |
PINOS_MEMBLOCK_FLAG_SEAL,
impl->n_buffers * (sizeof (SpaBuffer*) + buf_size),
buf_size * impl->n_buffers,
&impl->buffer_mem);
meta_p = SPA_MEMBER (impl->buffer_mem.ptr, 0, void);
chunk_p = SPA_MEMBER (meta_p, impl->n_buffers * meta_size, void);
data_p = SPA_MEMBER (chunk_p, impl->n_buffers * n_mems * sizeof (SpaMemChunk), void);
/* header conatain the buffer, mem and metadata headers along with
* the array of buffers. This is allocated in local memory */
hdr_size = sizeof (SpaBuffer);
hdr_size += n_metas * sizeof (SpaMeta);
hdr_size += n_mems * sizeof (SpaMem);
impl->buffers = calloc (impl->n_buffers, sizeof (SpaBuffer *) + hdr_size);
arr_size = impl->n_buffers * sizeof (SpaBuffer*);
impl->buffers = p = impl->buffer_mem.ptr;
p = SPA_MEMBER (p, arr_size, void);
for (i = 0; i < impl->n_buffers; i++) {
SpaBuffer *b;
SpaData *d;
SpaMem *m;
void *pd;
unsigned int mi;
b = impl->buffers[i] = SPA_MEMBER (p, buf_size * i, SpaBuffer);
b = impl->buffers[i] = SPA_MEMBER (impl->buffers, arr_size + (hdr_size * i), SpaBuffer);
b->id = i;
b->n_metas = n_metas;
b->metas = SPA_MEMBER (b, sizeof (SpaBuffer), SpaMeta);
b->n_datas = n_datas;
b->datas = SPA_MEMBER (b->metas, sizeof (SpaMeta) * n_metas, SpaData);
pd = SPA_MEMBER (b->datas, sizeof (SpaData) * n_datas, void);
b->n_mems = n_mems;
b->mems = SPA_MEMBER (b->metas, sizeof (SpaMeta) * n_metas, SpaMem);
pd = SPA_MEMBER (meta_p, meta_size * i, void);
for (j = 0, mi = 0; j < oinfo->n_params; j++) {
SpaAllocParam *ap = oinfo->params[j];
......@@ -392,20 +407,22 @@ do_allocation (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
}
}
d = &b->datas[0];
m = &b->mems[0];
if (minsize > 0) {
d->type = SPA_DATA_TYPE_MEMFD;
d->flags = 0;
d->data = impl->buffer_mem.ptr;
d->fd = impl->buffer_mem.fd;
d->maxsize = impl->buffer_mem.size;
d->offset = arr_size + hdr_size + (buf_size * i);
d->size = minsize;
d->stride = stride;
m->type = SPA_MEM_TYPE_MEMFD;
m->flags = SPA_MEM_FLAG_NONE;
m->fd = impl->buffer_mem.fd;
m->offset = SPA_PTRDIFF (data_p, impl->buffer_mem.ptr) + (minsize * blocks) * i;
m->size = impl->buffer_mem.size;
m->ptr = SPA_MEMBER (impl->buffer_mem.ptr, m->offset, void);
m->chunk->offset = 0,
m->chunk->size = minsize;
m->chunk->stride = stride;
} else {
d->type = SPA_DATA_TYPE_INVALID;
d->data = NULL;
m->type = SPA_MEM_TYPE_INVALID;
m->ptr = NULL;
}
spa_debug_buffer (b);
}
pinos_log_debug ("allocated %d buffers %p %zd", impl->n_buffers, impl->buffers, minsize);
impl->allocated = true;
......