mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-05 13:30:02 -05:00
buffer: make data and meta types dynamic
Use dynamic types for the data and meta types. Move the meta into a separate header. Remove port state, we can keep track of that ourselves. Add size to MetaDataEnable params
This commit is contained in:
parent
ed273ec465
commit
b51d3e4862
36 changed files with 543 additions and 553 deletions
|
|
@ -613,16 +613,15 @@ spa_proxy_node_port_use_buffers (SpaNode *node,
|
|||
uint32_t n_buffers)
|
||||
{
|
||||
SpaProxy *this;
|
||||
PinosClientNodeImpl *impl;
|
||||
SpaProxyPort *port;
|
||||
uint32_t i, j;
|
||||
size_t n_mem;
|
||||
PinosClientNodeBuffer *mb;
|
||||
SpaMetaShared *msh;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaProxy, node);
|
||||
impl = this->impl;
|
||||
spa_log_info (this->log, "proxy %p: use buffers %p %u", this, buffers, n_buffers);
|
||||
|
||||
if (!CHECK_PORT (this, direction, port_id))
|
||||
|
|
@ -650,7 +649,7 @@ spa_proxy_node_port_use_buffers (SpaNode *node,
|
|||
for (i = 0; i < n_buffers; i++) {
|
||||
ProxyBuffer *b = &port->buffers[i];
|
||||
|
||||
msh = spa_buffer_find_meta (buffers[i], SPA_META_TYPE_SHARED);
|
||||
msh = spa_buffer_find_meta (buffers[i], impl->core->type.meta.Shared);
|
||||
if (msh == NULL) {
|
||||
spa_log_error (this->log, "missing shared metadata on buffer %d", i);
|
||||
return SPA_RESULT_ERROR;
|
||||
|
|
@ -670,7 +669,7 @@ spa_proxy_node_port_use_buffers (SpaNode *node,
|
|||
direction,
|
||||
port_id,
|
||||
mb[i].mem_id,
|
||||
SPA_DATA_TYPE_MEMFD,
|
||||
impl->core->type.data.MemFd,
|
||||
msh->fd,
|
||||
msh->flags,
|
||||
msh->offset,
|
||||
|
|
@ -685,31 +684,29 @@ spa_proxy_node_port_use_buffers (SpaNode *node,
|
|||
|
||||
memcpy (&b->buffer.datas[j], d, sizeof (SpaData));
|
||||
|
||||
switch (d->type) {
|
||||
case SPA_DATA_TYPE_DMABUF:
|
||||
case SPA_DATA_TYPE_MEMFD:
|
||||
pinos_client_node_notify_add_mem (this->resource,
|
||||
direction,
|
||||
port_id,
|
||||
n_mem,
|
||||
d->type,
|
||||
d->fd,
|
||||
d->flags,
|
||||
d->mapoffset,
|
||||
d->maxsize);
|
||||
b->buffer.datas[j].type = SPA_DATA_TYPE_ID;
|
||||
b->buffer.datas[j].data = 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->maxsize;
|
||||
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);
|
||||
break;
|
||||
if (d->type == impl->core->type.data.DmaBuf ||
|
||||
d->type == impl->core->type.data.MemFd) {
|
||||
pinos_client_node_notify_add_mem (this->resource,
|
||||
direction,
|
||||
port_id,
|
||||
n_mem,
|
||||
d->type,
|
||||
d->fd,
|
||||
d->flags,
|
||||
d->mapoffset,
|
||||
d->maxsize);
|
||||
b->buffer.datas[j].type = impl->core->type.data.Id;
|
||||
b->buffer.datas[j].data = SPA_UINT32_TO_PTR (n_mem);
|
||||
n_mem++;
|
||||
}
|
||||
else if (d->type == impl->core->type.data.MemPtr) {
|
||||
b->buffer.datas[j].data = SPA_INT_TO_PTR (b->size);
|
||||
b->size += d->maxsize;
|
||||
}
|
||||
else {
|
||||
b->buffer.datas[j].type = SPA_ID_INVALID;
|
||||
b->buffer.datas[j].data = 0;
|
||||
spa_log_error (this->log, "invalid memory type %d", d->type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -833,9 +830,6 @@ spa_proxy_node_process_output (SpaNode *node)
|
|||
int i;
|
||||
bool send_need = false, flush = false;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaProxy, node);
|
||||
impl = this->impl;
|
||||
|
||||
|
|
|
|||
|
|
@ -654,12 +654,12 @@ pinos_core_find_format (PinosCore *core,
|
|||
|
||||
pinos_log_debug ("core %p: finding best format %d %d", core, out_state, in_state);
|
||||
|
||||
if (out_state > SPA_PORT_STATE_CONFIGURE && output->node->state == PINOS_NODE_STATE_IDLE)
|
||||
out_state = SPA_PORT_STATE_CONFIGURE;
|
||||
if (in_state > SPA_PORT_STATE_CONFIGURE && input->node->state == PINOS_NODE_STATE_IDLE)
|
||||
in_state = SPA_PORT_STATE_CONFIGURE;
|
||||
if (out_state > PINOS_PORT_STATE_CONFIGURE && output->node->state == PINOS_NODE_STATE_IDLE)
|
||||
out_state = PINOS_PORT_STATE_CONFIGURE;
|
||||
if (in_state > PINOS_PORT_STATE_CONFIGURE && input->node->state == PINOS_NODE_STATE_IDLE)
|
||||
in_state = PINOS_PORT_STATE_CONFIGURE;
|
||||
|
||||
if (in_state == SPA_PORT_STATE_CONFIGURE && out_state > SPA_PORT_STATE_CONFIGURE) {
|
||||
if (in_state == PINOS_PORT_STATE_CONFIGURE && out_state > PINOS_PORT_STATE_CONFIGURE) {
|
||||
/* only input needs format */
|
||||
if ((res = spa_node_port_get_format (output->node->node,
|
||||
SPA_DIRECTION_OUTPUT,
|
||||
|
|
@ -668,7 +668,7 @@ pinos_core_find_format (PinosCore *core,
|
|||
asprintf (error, "error get output format: %d", res);
|
||||
goto error;
|
||||
}
|
||||
} else if (out_state == SPA_PORT_STATE_CONFIGURE && in_state > SPA_PORT_STATE_CONFIGURE) {
|
||||
} else if (out_state == PINOS_PORT_STATE_CONFIGURE && in_state > PINOS_PORT_STATE_CONFIGURE) {
|
||||
/* only output needs format */
|
||||
if ((res = spa_node_port_get_format (input->node->node,
|
||||
SPA_DIRECTION_INPUT,
|
||||
|
|
@ -677,7 +677,7 @@ pinos_core_find_format (PinosCore *core,
|
|||
asprintf (error, "error get input format: %d", res);
|
||||
goto error;
|
||||
}
|
||||
} else if (in_state == SPA_PORT_STATE_CONFIGURE && out_state == SPA_PORT_STATE_CONFIGURE) {
|
||||
} else if (in_state == PINOS_PORT_STATE_CONFIGURE && out_state == PINOS_PORT_STATE_CONFIGURE) {
|
||||
again:
|
||||
/* both ports need a format */
|
||||
pinos_log_debug ("core %p: finding best format", core);
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ complete_ready (void *obj,
|
|||
{
|
||||
PinosPort *port = data;
|
||||
if (SPA_RESULT_IS_OK (res)) {
|
||||
port->state = SPA_PORT_STATE_READY;
|
||||
port->state = PINOS_PORT_STATE_READY;
|
||||
pinos_log_debug ("port %p: state READY", port);
|
||||
}
|
||||
else
|
||||
|
|
@ -98,7 +98,7 @@ complete_paused (void *obj,
|
|||
{
|
||||
PinosPort *port = data;
|
||||
if (SPA_RESULT_IS_OK (res)) {
|
||||
port->state = SPA_PORT_STATE_PAUSED;
|
||||
port->state = PINOS_PORT_STATE_PAUSED;
|
||||
pinos_log_debug ("port %p: state PAUSED", port);
|
||||
}
|
||||
else
|
||||
|
|
@ -113,7 +113,7 @@ complete_streaming (void *obj,
|
|||
{
|
||||
PinosPort *port = data;
|
||||
if (SPA_RESULT_IS_OK (res)) {
|
||||
port->state = SPA_PORT_STATE_STREAMING;
|
||||
port->state = PINOS_PORT_STATE_STREAMING;
|
||||
pinos_log_debug ("port %p: state STREAMING", port);
|
||||
}
|
||||
else
|
||||
|
|
@ -128,7 +128,7 @@ do_negotiate (PinosLink *this, uint32_t in_state, uint32_t out_state)
|
|||
SpaFormat *format;
|
||||
char *error = NULL;
|
||||
|
||||
if (in_state != SPA_PORT_STATE_CONFIGURE && out_state != SPA_PORT_STATE_CONFIGURE)
|
||||
if (in_state != PINOS_PORT_STATE_CONFIGURE && out_state != PINOS_PORT_STATE_CONFIGURE)
|
||||
return SPA_RESULT_OK;
|
||||
|
||||
pinos_link_update_state (this, PINOS_LINK_STATE_NEGOTIATING, NULL);
|
||||
|
|
@ -143,20 +143,20 @@ do_negotiate (PinosLink *this, uint32_t in_state, uint32_t out_state)
|
|||
if (format == NULL)
|
||||
goto error;
|
||||
|
||||
if (out_state > SPA_PORT_STATE_CONFIGURE && this->output->node->state == PINOS_NODE_STATE_IDLE) {
|
||||
if (out_state > PINOS_PORT_STATE_CONFIGURE && this->output->node->state == PINOS_NODE_STATE_IDLE) {
|
||||
pinos_node_set_state (this->output->node, PINOS_NODE_STATE_SUSPENDED);
|
||||
out_state = SPA_PORT_STATE_CONFIGURE;
|
||||
out_state = PINOS_PORT_STATE_CONFIGURE;
|
||||
}
|
||||
if (in_state > SPA_PORT_STATE_CONFIGURE && this->input->node->state == PINOS_NODE_STATE_IDLE) {
|
||||
if (in_state > PINOS_PORT_STATE_CONFIGURE && this->input->node->state == PINOS_NODE_STATE_IDLE) {
|
||||
pinos_node_set_state (this->input->node, PINOS_NODE_STATE_SUSPENDED);
|
||||
in_state = SPA_PORT_STATE_CONFIGURE;
|
||||
in_state = PINOS_PORT_STATE_CONFIGURE;
|
||||
}
|
||||
|
||||
pinos_log_debug ("link %p: doing set format", this);
|
||||
if (pinos_log_level_enabled (SPA_LOG_LEVEL_DEBUG))
|
||||
spa_debug_format (format, this->core->type.map);
|
||||
|
||||
if (out_state == SPA_PORT_STATE_CONFIGURE) {
|
||||
if (out_state == PINOS_PORT_STATE_CONFIGURE) {
|
||||
pinos_log_debug ("link %p: doing set format on output", this);
|
||||
if ((res = spa_node_port_set_format (this->output->node->node,
|
||||
SPA_DIRECTION_OUTPUT,
|
||||
|
|
@ -168,7 +168,7 @@ do_negotiate (PinosLink *this, uint32_t in_state, uint32_t out_state)
|
|||
}
|
||||
pinos_work_queue_add (impl->work, this->output->node, res, complete_ready, this->output);
|
||||
}
|
||||
if (in_state == SPA_PORT_STATE_CONFIGURE) {
|
||||
if (in_state == PINOS_PORT_STATE_CONFIGURE) {
|
||||
pinos_log_debug ("link %p: doing set format on input", this);
|
||||
if ((res2 = spa_node_port_set_format (this->input->node->node,
|
||||
SPA_DIRECTION_INPUT,
|
||||
|
|
@ -203,7 +203,7 @@ find_param (const SpaPortInfo *info, uint32_t type)
|
|||
}
|
||||
|
||||
static void *
|
||||
find_meta_enable (PinosCore *core, const SpaPortInfo *info, SpaMetaType type)
|
||||
find_meta_enable (PinosCore *core, const SpaPortInfo *info, uint32_t type)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
|
|
@ -212,7 +212,7 @@ find_meta_enable (PinosCore *core, const SpaPortInfo *info, SpaMetaType type)
|
|||
uint32_t qtype;
|
||||
|
||||
if (spa_alloc_param_query (info->params[i],
|
||||
core->type.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, &qtype, 0) != 1)
|
||||
core->type.alloc_param_meta_enable.type, SPA_POD_TYPE_ID, &qtype, 0) != 1)
|
||||
continue;
|
||||
|
||||
if (qtype == type)
|
||||
|
|
@ -248,8 +248,8 @@ alloc_buffers (PinosLink *this,
|
|||
metas = alloca (sizeof (SpaMeta) * n_params + 1);
|
||||
|
||||
/* add shared metadata */
|
||||
metas[n_metas].type = SPA_META_TYPE_SHARED;
|
||||
metas[n_metas].size = spa_meta_type_get_size (SPA_META_TYPE_SHARED);
|
||||
metas[n_metas].type = this->core->type.meta.Shared;
|
||||
metas[n_metas].size = sizeof (SpaMetaShared);
|
||||
meta_size += metas[n_metas].size;
|
||||
n_metas++;
|
||||
skel_size += sizeof (SpaMeta);
|
||||
|
|
@ -259,15 +259,16 @@ alloc_buffers (PinosLink *this,
|
|||
SpaAllocParam *ap = params[i];
|
||||
|
||||
if (ap->pod.type == this->core->type.alloc_param_meta_enable.MetaEnable) {
|
||||
uint32_t type;
|
||||
uint32_t type, size;
|
||||
|
||||
if (spa_alloc_param_query (ap,
|
||||
this->core->type.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, &type,
|
||||
this->core->type.alloc_param_meta_enable.type, SPA_POD_TYPE_ID, &type,
|
||||
this->core->type.alloc_param_meta_enable.size, SPA_POD_TYPE_INT, &size,
|
||||
0) != 1)
|
||||
continue;
|
||||
|
||||
metas[n_metas].type = type;
|
||||
metas[n_metas].size = spa_meta_type_get_size (type);
|
||||
metas[n_metas].size = size;
|
||||
meta_size += metas[n_metas].size;
|
||||
n_metas++;
|
||||
skel_size += sizeof (SpaMeta);
|
||||
|
|
@ -312,26 +313,17 @@ alloc_buffers (PinosLink *this,
|
|||
m->data = p;
|
||||
m->size = metas[j].size;
|
||||
|
||||
switch (m->type) {
|
||||
case SPA_META_TYPE_SHARED:
|
||||
{
|
||||
SpaMetaShared *msh = p;
|
||||
if (m->type == this->core->type.meta.Shared) {
|
||||
SpaMetaShared *msh = p;
|
||||
|
||||
msh->type = SPA_DATA_TYPE_MEMFD;
|
||||
msh->flags = 0;
|
||||
msh->fd = mem->fd;
|
||||
msh->offset = data_size * i;
|
||||
msh->size = data_size;
|
||||
break;
|
||||
}
|
||||
case SPA_META_TYPE_RINGBUFFER:
|
||||
{
|
||||
SpaMetaRingbuffer *rb = p;
|
||||
spa_ringbuffer_init (&rb->ringbuffer, data_sizes[0]);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
msh->flags = 0;
|
||||
msh->fd = mem->fd;
|
||||
msh->offset = data_size * i;
|
||||
msh->size = data_size;
|
||||
}
|
||||
else if (m->type == this->core->type.meta.Ringbuffer) {
|
||||
SpaMetaRingbuffer *rb = p;
|
||||
spa_ringbuffer_init (&rb->ringbuffer, data_sizes[0]);
|
||||
}
|
||||
p += m->size;
|
||||
}
|
||||
|
|
@ -347,7 +339,7 @@ alloc_buffers (PinosLink *this,
|
|||
|
||||
d->chunk = &cdp[j];
|
||||
if (data_sizes[j] > 0) {
|
||||
d->type = SPA_DATA_TYPE_MEMFD;
|
||||
d->type = this->core->type.data.MemFd;
|
||||
d->flags = 0;
|
||||
d->fd = mem->fd;
|
||||
d->mapoffset = SPA_PTRDIFF (ddp, mem->ptr);
|
||||
|
|
@ -358,7 +350,7 @@ alloc_buffers (PinosLink *this,
|
|||
d->chunk->stride = data_strides[j];
|
||||
ddp += data_sizes[j];
|
||||
} else {
|
||||
d->type = SPA_DATA_TYPE_INVALID;
|
||||
d->type = SPA_ID_INVALID;
|
||||
d->data = NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -375,7 +367,7 @@ do_allocation (PinosLink *this, uint32_t in_state, uint32_t out_state)
|
|||
SpaPortInfoFlags in_flags, out_flags;
|
||||
char *error = NULL;
|
||||
|
||||
if (in_state != SPA_PORT_STATE_READY && out_state != SPA_PORT_STATE_READY)
|
||||
if (in_state != PINOS_PORT_STATE_READY && out_state != PINOS_PORT_STATE_READY)
|
||||
return SPA_RESULT_OK;
|
||||
|
||||
pinos_link_update_state (this, PINOS_LINK_STATE_ALLOCATING, NULL);
|
||||
|
|
@ -406,7 +398,7 @@ do_allocation (PinosLink *this, uint32_t in_state, uint32_t out_state)
|
|||
this->input->node->live = true;
|
||||
}
|
||||
|
||||
if (in_state == SPA_PORT_STATE_READY && out_state == SPA_PORT_STATE_READY) {
|
||||
if (in_state == PINOS_PORT_STATE_READY && out_state == PINOS_PORT_STATE_READY) {
|
||||
if ((out_flags & SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS) &&
|
||||
(in_flags & SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS)) {
|
||||
out_flags = SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS;
|
||||
|
|
@ -428,10 +420,10 @@ do_allocation (PinosLink *this, uint32_t in_state, uint32_t out_state)
|
|||
res = SPA_RESULT_ERROR;
|
||||
goto error;
|
||||
}
|
||||
} else if (in_state == SPA_PORT_STATE_READY && out_state > SPA_PORT_STATE_READY) {
|
||||
} else if (in_state == PINOS_PORT_STATE_READY && out_state > PINOS_PORT_STATE_READY) {
|
||||
out_flags &= ~SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS;
|
||||
in_flags &= ~SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS;
|
||||
} else if (out_state == SPA_PORT_STATE_READY && in_state > SPA_PORT_STATE_READY) {
|
||||
} else if (out_state == PINOS_PORT_STATE_READY && in_state > PINOS_PORT_STATE_READY) {
|
||||
in_flags &= ~SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS;
|
||||
out_flags &= ~SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS;
|
||||
} else {
|
||||
|
|
@ -450,8 +442,8 @@ do_allocation (PinosLink *this, uint32_t in_state, uint32_t out_state)
|
|||
uint32_t max_buffers;
|
||||
size_t minsize = 1024, stride = 0;
|
||||
|
||||
in_me = find_meta_enable (this->core, iinfo, SPA_META_TYPE_RINGBUFFER);
|
||||
out_me = find_meta_enable (this->core, oinfo, SPA_META_TYPE_RINGBUFFER);
|
||||
in_me = find_meta_enable (this->core, iinfo, this->core->type.meta.Ringbuffer);
|
||||
out_me = find_meta_enable (this->core, oinfo, this->core->type.meta.Ringbuffer);
|
||||
if (in_me && out_me) {
|
||||
uint32_t ms1, ms2, s1, s2;
|
||||
max_buffers = 1;
|
||||
|
|
@ -631,18 +623,18 @@ do_start (PinosLink *this, uint32_t in_state, uint32_t out_state)
|
|||
SpaResult res = SPA_RESULT_OK;
|
||||
PinosLinkImpl *impl = SPA_CONTAINER_OF (this, PinosLinkImpl, this);
|
||||
|
||||
if (in_state < SPA_PORT_STATE_PAUSED || out_state < SPA_PORT_STATE_PAUSED)
|
||||
if (in_state < PINOS_PORT_STATE_PAUSED || out_state < PINOS_PORT_STATE_PAUSED)
|
||||
return SPA_RESULT_OK;
|
||||
else if (in_state == SPA_PORT_STATE_STREAMING && out_state == SPA_PORT_STATE_STREAMING) {
|
||||
else if (in_state == PINOS_PORT_STATE_STREAMING && out_state == PINOS_PORT_STATE_STREAMING) {
|
||||
pinos_link_update_state (this, PINOS_LINK_STATE_RUNNING, NULL);
|
||||
} else {
|
||||
pinos_link_update_state (this, PINOS_LINK_STATE_PAUSED, NULL);
|
||||
|
||||
if (in_state == SPA_PORT_STATE_PAUSED) {
|
||||
if (in_state == PINOS_PORT_STATE_PAUSED) {
|
||||
res = pinos_node_set_state (this->input->node, PINOS_NODE_STATE_RUNNING);
|
||||
pinos_work_queue_add (impl->work, this->input->node, res, complete_streaming, this->input);
|
||||
}
|
||||
if (out_state == SPA_PORT_STATE_PAUSED) {
|
||||
if (out_state == PINOS_PORT_STATE_PAUSED) {
|
||||
res = pinos_node_set_state (this->output->node, PINOS_NODE_STATE_RUNNING);
|
||||
pinos_work_queue_add (impl->work, this->output->node, res, complete_streaming, this->output);
|
||||
}
|
||||
|
|
@ -940,7 +932,7 @@ clear_port_buffers (PinosLink *link, PinosPort *port)
|
|||
{
|
||||
PinosLinkImpl *impl = SPA_CONTAINER_OF (link, PinosLinkImpl, this);
|
||||
|
||||
if (impl->buffer_owner != port && port->state > SPA_PORT_STATE_READY) {
|
||||
if (impl->buffer_owner != port && port->state > PINOS_PORT_STATE_READY) {
|
||||
pinos_log_debug ("link %p: clear buffers on port %p", link, port);
|
||||
spa_node_port_use_buffers (port->node->node,
|
||||
port->direction,
|
||||
|
|
@ -948,7 +940,7 @@ clear_port_buffers (PinosLink *link, PinosPort *port)
|
|||
NULL, 0);
|
||||
port->buffers = NULL;
|
||||
port->n_buffers = 0;
|
||||
port->state = SPA_PORT_STATE_READY;
|
||||
port->state = PINOS_PORT_STATE_READY;
|
||||
pinos_log_debug ("port %p: state READY", port);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ suspend_node (PinosNode *this)
|
|||
if (p->allocated)
|
||||
pinos_memblock_free (&p->buffer_mem);
|
||||
p->allocated = false;
|
||||
p->state = SPA_PORT_STATE_CONFIGURE;
|
||||
p->state = PINOS_PORT_STATE_CONFIGURE;
|
||||
}
|
||||
|
||||
spa_list_for_each (p, &this->output_ports, link) {
|
||||
|
|
@ -219,7 +219,7 @@ suspend_node (PinosNode *this)
|
|||
if (p->allocated)
|
||||
pinos_memblock_free (&p->buffer_mem);
|
||||
p->allocated = false;
|
||||
p->state = SPA_PORT_STATE_CONFIGURE;
|
||||
p->state = PINOS_PORT_STATE_CONFIGURE;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ pinos_port_new (PinosNode *node,
|
|||
this->node = node;
|
||||
this->direction = direction;
|
||||
this->port_id = port_id;
|
||||
this->state = SPA_PORT_STATE_CONFIGURE;
|
||||
this->state = PINOS_PORT_STATE_CONFIGURE;
|
||||
this->io.status = SPA_RESULT_OK;
|
||||
this->io.buffer_id = SPA_ID_INVALID;
|
||||
|
||||
|
|
@ -205,14 +205,14 @@ pinos_port_pause_rt (PinosPort *port)
|
|||
SpaCommand cmd = SPA_COMMAND_INIT (port->node->core->type.command_node.Pause);
|
||||
SpaResult res;
|
||||
|
||||
if (port->state <= SPA_PORT_STATE_PAUSED)
|
||||
if (port->state <= PINOS_PORT_STATE_PAUSED)
|
||||
return SPA_RESULT_OK;
|
||||
|
||||
res = spa_node_port_send_command (port->node->node,
|
||||
port->direction,
|
||||
port->port_id,
|
||||
&cmd);
|
||||
port->state = SPA_PORT_STATE_PAUSED;
|
||||
port->state = PINOS_PORT_STATE_PAUSED;
|
||||
pinos_log_debug ("port %p: state PAUSED", port);
|
||||
return res;
|
||||
}
|
||||
|
|
@ -244,7 +244,7 @@ do_remove_link_done (SpaLoop *loop,
|
|||
}
|
||||
}
|
||||
|
||||
if (!port->allocated && port->state > SPA_PORT_STATE_READY) {
|
||||
if (!port->allocated && port->state > PINOS_PORT_STATE_READY) {
|
||||
pinos_log_debug ("port %p: clear buffers on port", port);
|
||||
spa_node_port_use_buffers (port->node->node,
|
||||
port->direction,
|
||||
|
|
@ -252,7 +252,7 @@ do_remove_link_done (SpaLoop *loop,
|
|||
NULL, 0);
|
||||
port->buffers = NULL;
|
||||
port->n_buffers = 0;
|
||||
port->state = SPA_PORT_STATE_READY;
|
||||
port->state = PINOS_PORT_STATE_READY;
|
||||
pinos_log_debug ("port %p: state READY", port);
|
||||
}
|
||||
|
||||
|
|
@ -324,7 +324,7 @@ do_clear_buffers_done (SpaLoop *loop,
|
|||
PinosPort *port = user_data;
|
||||
SpaResult res;
|
||||
|
||||
if (port->state <= SPA_PORT_STATE_READY)
|
||||
if (port->state <= PINOS_PORT_STATE_READY)
|
||||
return SPA_RESULT_OK;
|
||||
|
||||
pinos_log_debug ("port %p: clear buffers finish", port);
|
||||
|
|
@ -334,7 +334,7 @@ do_clear_buffers_done (SpaLoop *loop,
|
|||
NULL, 0);
|
||||
port->buffers = NULL;
|
||||
port->n_buffers = 0;
|
||||
port->state = SPA_PORT_STATE_READY;
|
||||
port->state = PINOS_PORT_STATE_READY;
|
||||
pinos_log_debug ("port %p: state READY", port);
|
||||
|
||||
return res;
|
||||
|
|
|
|||
|
|
@ -37,6 +37,15 @@ typedef struct _PinosPort PinosPort;
|
|||
#include <pinos/server/core.h>
|
||||
#include <pinos/server/link.h>
|
||||
|
||||
typedef enum {
|
||||
PINOS_PORT_STATE_ERROR = -1,
|
||||
PINOS_PORT_STATE_INIT = 0,
|
||||
PINOS_PORT_STATE_CONFIGURE = 1,
|
||||
PINOS_PORT_STATE_READY = 2,
|
||||
PINOS_PORT_STATE_PAUSED = 3,
|
||||
PINOS_PORT_STATE_STREAMING = 4,
|
||||
} PinosPortState;
|
||||
|
||||
struct _PinosPort {
|
||||
SpaList link;
|
||||
|
||||
|
|
@ -45,7 +54,7 @@ struct _PinosPort {
|
|||
PinosNode *node;
|
||||
PinosDirection direction;
|
||||
uint32_t port_id;
|
||||
uint32_t state;
|
||||
PinosPortState state;
|
||||
SpaPortIO io;
|
||||
|
||||
bool allocated;
|
||||
|
|
|
|||
|
|
@ -658,7 +658,7 @@ client_node_marshal_add_mem (void *object,
|
|||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
uint32_t mem_id,
|
||||
SpaDataType type,
|
||||
uint32_t type,
|
||||
int memfd,
|
||||
uint32_t flags,
|
||||
uint32_t offset,
|
||||
|
|
@ -675,7 +675,7 @@ client_node_marshal_add_mem (void *object,
|
|||
SPA_POD_TYPE_INT, direction,
|
||||
SPA_POD_TYPE_INT, port_id,
|
||||
SPA_POD_TYPE_INT, mem_id,
|
||||
SPA_POD_TYPE_INT, type,
|
||||
SPA_POD_TYPE_ID, type,
|
||||
SPA_POD_TYPE_INT, pinos_connection_add_fd (connection, memfd),
|
||||
SPA_POD_TYPE_INT, flags,
|
||||
SPA_POD_TYPE_INT, offset,
|
||||
|
|
@ -720,14 +720,14 @@ client_node_marshal_use_buffers (void *object,
|
|||
for (j = 0; j < buf->n_metas; j++) {
|
||||
SpaMeta *m = &buf->metas[j];
|
||||
spa_pod_builder_add (&b.b,
|
||||
SPA_POD_TYPE_INT, m->type,
|
||||
SPA_POD_TYPE_ID, m->type,
|
||||
SPA_POD_TYPE_INT, m->size, 0);
|
||||
}
|
||||
spa_pod_builder_add (&b.b, SPA_POD_TYPE_INT, buf->n_datas, 0);
|
||||
for (j = 0; j < buf->n_datas; j++) {
|
||||
SpaData *d = &buf->datas[j];
|
||||
spa_pod_builder_add (&b.b,
|
||||
SPA_POD_TYPE_INT, d->type,
|
||||
SPA_POD_TYPE_ID, d->type,
|
||||
SPA_POD_TYPE_INT, SPA_PTR_TO_UINT32 (d->data),
|
||||
SPA_POD_TYPE_INT, d->flags,
|
||||
SPA_POD_TYPE_INT, d->mapoffset,
|
||||
|
|
@ -865,6 +865,7 @@ client_node_demarshal_port_update (void *object,
|
|||
if (!spa_pod_iter_pod (&it2, ipod) ||
|
||||
!spa_pod_iter_get (&it2,
|
||||
SPA_POD_TYPE_INT, &info.flags,
|
||||
SPA_POD_TYPE_INT, &info.rate,
|
||||
SPA_POD_TYPE_LONG, &info.maxbuffering,
|
||||
SPA_POD_TYPE_LONG, &info.latency,
|
||||
SPA_POD_TYPE_INT, &info.n_params,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue