small fixes

This commit is contained in:
Wim Taymans 2017-04-08 20:59:38 +02:00
parent d3682067fa
commit 9bd92b781c
3 changed files with 30 additions and 9 deletions

View file

@ -175,6 +175,7 @@ pause_node (PinosNode *this)
if ((res = spa_node_send_command (this->node, &cmd)) < 0)
pinos_log_debug ("got error %d", res);
}
return res;
}
@ -208,6 +209,7 @@ suspend_node (PinosNode *this)
if (p->allocated)
pinos_memblock_free (&p->buffer_mem);
p->allocated = false;
p->state = SPA_PORT_STATE_CONFIGURE;
}
spa_list_for_each (p, &this->output_ports, link) {
@ -218,6 +220,7 @@ suspend_node (PinosNode *this)
if (p->allocated)
pinos_memblock_free (&p->buffer_mem);
p->allocated = false;
p->state = SPA_PORT_STATE_CONFIGURE;
}
return res;
}
@ -735,6 +738,7 @@ pinos_node_get_free_port (PinosNode *node,
SpaList *ports;
PinosPort *port = NULL, *p, **portmap;
SpaPortIO *io;
SpaResult res;
int i;
if (direction == PINOS_DIRECTION_INPUT) {
@ -769,8 +773,12 @@ pinos_node_get_free_port (PinosNode *node,
port = portmap[i] = pinos_port_new (node, direction, i);
port->io = &io[i];
(*n_ports)++;
spa_node_add_port (node->node, direction, i);
spa_node_port_set_io (node->node, direction, i, port->io);
if ((res = spa_node_add_port (node->node, direction, i)) < 0) {
pinos_log_error ("node %p: could not add port %d", node, i);
}
else {
spa_node_port_set_io (node->node, direction, i, port->io);
}
}
}
} else {

View file

@ -576,6 +576,17 @@ spa_audiomixer_node_port_send_command (SpaNode *node,
return SPA_RESULT_NOT_IMPLEMENTED;
}
static void
clear_buffer (SpaAudioMixer *this, MixerBuffer *out)
{
int16_t *op;
size_t os;
op = SPA_MEMBER (out->outbuf->datas[0].data, out->outbuf->datas[0].chunk->offset, void);
os = out->outbuf->datas[0].chunk->size;
memset (op, 0, os);
}
static void
add_port_data (SpaAudioMixer *this, MixerBuffer *out, SpaAudioMixerPort *port, int layer)
{
@ -634,7 +645,7 @@ spa_audiomixer_node_process_input (SpaNode *node)
SpaAudioMixerPort *port = &this->in_ports[i];
SpaPortIO *input;
if ((input = port->io) == NULL)
if ((input = port->io) == NULL || port->n_buffers == 0)
continue;
if (input->buffer_id != SPA_ID_INVALID) {
@ -691,6 +702,9 @@ spa_audiomixer_node_process_input (SpaNode *node)
add_port_data (this, outbuf, port, layer++);
}
if (layer == 0)
clear_buffer (this, outbuf);
output = outport->io;
output->buffer_id = outbuf->outbuf->id;
output->status = SPA_RESULT_OK;

View file

@ -403,13 +403,12 @@ negotiate_formats (AppData *data)
if ((res = spa_node_add_port (data->mix, SPA_DIRECTION_INPUT, 0)) < 0)
return res;
spa_node_port_set_io (data->source1, SPA_DIRECTION_OUTPUT, 0, &data->source1_mix_io[0]);
spa_node_port_set_io (data->mix, SPA_DIRECTION_INPUT, 0, &data->source1_mix_io[0]);
if ((res = spa_node_port_set_format (data->mix, SPA_DIRECTION_INPUT, data->mix_ports[0], 0, format)) < 0)
return res;
spa_node_port_set_io (data->source1, SPA_DIRECTION_OUTPUT, 0, &data->source1_mix_io[0]);
spa_node_port_set_io (data->mix, SPA_DIRECTION_INPUT, 0, &data->source1_mix_io[0]);
if ((res = spa_node_port_set_format (data->source1, SPA_DIRECTION_OUTPUT, 0, 0, format)) < 0)
return res;
@ -424,12 +423,12 @@ negotiate_formats (AppData *data)
if ((res = spa_node_add_port (data->mix, SPA_DIRECTION_INPUT, 1)) < 0)
return res;
if ((res = spa_node_port_set_format (data->mix, SPA_DIRECTION_INPUT, data->mix_ports[1], 0, format)) < 0)
return res;
spa_node_port_set_io (data->source2, SPA_DIRECTION_OUTPUT, 0, &data->source2_mix_io[0]);
spa_node_port_set_io (data->mix, SPA_DIRECTION_INPUT, 1, &data->source2_mix_io[0]);
if ((res = spa_node_port_set_format (data->mix, SPA_DIRECTION_INPUT, data->mix_ports[1], 0, format)) < 0)
return res;
if ((res = spa_node_port_set_format (data->source2, SPA_DIRECTION_OUTPUT, 0, 0, format)) < 0)
return res;