node: schedule upstream first

In pull mode, schedule all upstream nodes first, if any of them
produce output, push it into the current node.
Underrun streams without input on audiomixer, avoids glitch when
starting a new stream.
This commit is contained in:
Wim Taymans 2017-04-12 11:24:11 +02:00
parent 4c7b56020a
commit d9bb116d27
3 changed files with 18 additions and 17 deletions

View file

@ -733,7 +733,7 @@ spa_audiomixer_node_process_input (SpaNode *node)
spa_log_trace (this->log, "audiomixer %p: queue buffer %d on port %d %zd %zd",
this, b->outbuf->id, i, port->queued_bytes, min_queued);
}
if (min_queued == SIZE_MAX || port->queued_bytes < min_queued)
if (port->queued_bytes > 0 && port->queued_bytes < min_queued)
min_queued = port->queued_bytes;
}
@ -772,7 +772,7 @@ spa_audiomixer_node_process_output (SpaNode *node)
res = SPA_RESULT_NEED_INPUT;
/* produce more output if possible */
if (this->state == STATE_OUT) {
size_t min_queued = -1;
size_t min_queued = SIZE_MAX;
for (i = 0; i < MAX_PORTS; i++) {
SpaAudioMixerPort *port = &this->in_ports[i];
@ -780,10 +780,10 @@ spa_audiomixer_node_process_output (SpaNode *node)
if (port->io == NULL || port->n_buffers == 0)
continue;
if (min_queued == -1 || port->queued_bytes < min_queued)
if (port->queued_bytes > 0 && port->queued_bytes < min_queued)
min_queued = port->queued_bytes;
}
if (min_queued != -1 && min_queued > 0) {
if (min_queued != SIZE_MAX && min_queued > 0) {
res = mix_output (this, min_queued);
} else {
this->state = STATE_IN;