improve node io

Unify input and output io areas.
Add support for ranges in the io area.
Automatically recycle buffers in the output areas in process_output
Improve the mixer, add use_buffer support, use a queue of input buffers,
fix mixing, add support for ranges.
Fix mixer and v4l2 tests
This commit is contained in:
Wim Taymans 2017-04-03 14:56:04 +02:00
parent 29fbf2e841
commit 01c13adab5
28 changed files with 983 additions and 747 deletions

View file

@ -565,41 +565,24 @@ spa_proxy_node_port_set_props (SpaNode *node,
}
static SpaResult
spa_proxy_node_port_set_input (SpaNode *node,
uint32_t port_id,
SpaPortInput *input)
spa_proxy_node_port_set_io (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaPortIO *io)
{
SpaProxy *this;
SpaProxyPort *port;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
this = SPA_CONTAINER_OF (node, SpaProxy, node);
if (!CHECK_PORT (this, SPA_DIRECTION_INPUT, port_id))
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
this->in_ports[port_id].io = input;
return SPA_RESULT_OK;
}
static SpaResult
spa_proxy_node_port_set_output (SpaNode *node,
uint32_t port_id,
SpaPortOutput *output)
{
SpaProxy *this;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
this = SPA_CONTAINER_OF (node, SpaProxy, node);
if (!CHECK_PORT (this, SPA_DIRECTION_OUTPUT, port_id))
return SPA_RESULT_INVALID_PORT;
this->out_ports[port_id].io = output;
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
port->io = io;
return SPA_RESULT_OK;
}
@ -815,11 +798,14 @@ static SpaResult
spa_proxy_node_process_output (SpaNode *node)
{
SpaProxy *this;
PinosNode *pnode;
int i;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
this = SPA_CONTAINER_OF (node, SpaProxy, node);
pnode = this->pnode;
send_need_input (this);
@ -982,8 +968,7 @@ static const SpaNode proxy_node = {
spa_proxy_node_port_set_props,
spa_proxy_node_port_use_buffers,
spa_proxy_node_port_alloc_buffers,
spa_proxy_node_port_set_input,
spa_proxy_node_port_set_output,
spa_proxy_node_port_set_io,
spa_proxy_node_port_reuse_buffer,
spa_proxy_node_port_send_command,
spa_proxy_node_process_input,

View file

@ -150,9 +150,9 @@ update_port_ids (PinosNode *node, bool create)
node->transport->area->n_outputs = n_output_ports;
for (i = 0; i < max_input_ports; i++)
spa_node_port_set_input (node->node, i, &node->transport->inputs[i]);
spa_node_port_set_io (node->node, SPA_DIRECTION_INPUT, i, &node->transport->inputs[i]);
for (i = 0; i < max_output_ports; i++)
spa_node_port_set_output (node->node, i, &node->transport->outputs[i]);
spa_node_port_set_io (node->node, SPA_DIRECTION_OUTPUT, i, &node->transport->outputs[i]);
pinos_signal_emit (&node->transport_changed, node);
}
@ -272,8 +272,8 @@ on_node_event (SpaNode *node, SpaEvent *event, void *user_data)
for (i = 0; i < this->transport->area->n_inputs; i++) {
PinosLink *link;
PinosPort *inport, *outport;
SpaPortInput *pi;
SpaPortOutput *po;
SpaPortIO *pi;
SpaPortIO *po;
pi = &this->transport->inputs[i];
if (pi->buffer_id != SPA_ID_INVALID)
@ -289,16 +289,8 @@ on_node_event (SpaNode *node, SpaEvent *event, void *user_data)
if (po->buffer_id != SPA_ID_INVALID) {
processed = true;
pi->buffer_id = po->buffer_id;
if ((res = spa_node_port_reuse_buffer (outport->node->node,
outport->port_id,
po->buffer_id)) < 0)
pinos_log_warn ("node %p: error reuse buffer: %d", outport->node, res);
po->buffer_id = SPA_ID_INVALID;
*pi = *po;
}
if ((res = spa_node_process_output (outport->node->node)) < 0)
pinos_log_warn ("node %p: got process output %d", outport->node, res);
}
@ -316,8 +308,7 @@ on_node_event (SpaNode *node, SpaEvent *event, void *user_data)
for (i = 0; i < this->transport->area->n_outputs; i++) {
PinosLink *link;
PinosPort *inport, *outport;
SpaPortInput *pi;
SpaPortOutput *po;
SpaPortIO *po;
po = &this->transport->outputs[i];
if (po->buffer_id == SPA_ID_INVALID)
@ -331,22 +322,12 @@ on_node_event (SpaNode *node, SpaEvent *event, void *user_data)
continue;
inport = link->rt.input;
pi = &inport->node->transport->inputs[inport->port_id];
pi->buffer_id = po->buffer_id;
inport->node->transport->inputs[inport->port_id] = *po;
if ((res = spa_node_process_input (inport->node->node)) < 0)
pinos_log_warn ("node %p: got process input %d", inport->node, res);
}
if ((res = spa_node_port_reuse_buffer (this->node,
outport->port_id,
po->buffer_id)) < 0)
pinos_log_warn ("node %p: error reuse buffer: %d", this, res);
processed = true;
po->buffer_id = SPA_ID_INVALID;
}
if (processed) {
if ((res = spa_node_process_output (this->node)) < 0)

View file

@ -72,7 +72,7 @@ pinos_resource_destroy (PinosResource *resource)
{
PinosClient *client = resource->client;
pinos_log_debug ("resource %p: destroy %u", resource, resource->id);
pinos_log_trace ("resource %p: destroy %u", resource, resource->id);
pinos_signal_emit (&resource->destroy_signal, resource);
pinos_map_insert_at (&client->objects, resource->id, NULL);
@ -84,6 +84,5 @@ pinos_resource_destroy (PinosResource *resource)
if (client->core_resource)
pinos_core_notify_remove_id (client->core_resource, resource->id);
pinos_log_debug ("resource %p: free", resource);
free (resource);
}