From e68624fe7b65bf57d4f16c8fe325f9629c1bbd00 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 2 Jul 2018 12:06:22 +0200 Subject: [PATCH] client-stream: improve scheduling --- .../module-client-node/client-stream.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/modules/module-client-node/client-stream.c b/src/modules/module-client-node/client-stream.c index fdd90cf82..6a6c406d8 100644 --- a/src/modules/module-client-node/client-stream.c +++ b/src/modules/module-client-node/client-stream.c @@ -744,7 +744,7 @@ static int impl_node_process(struct spa_node *node) { struct node *this = SPA_CONTAINER_OF(node, struct node, node); struct impl *impl = this->impl; - int status, trigger = 1; + int status, trigger; impl->ctrl.min_size = impl->ctrl.max_size = impl->this.node->driver_node->rt.quantum->size; @@ -753,12 +753,7 @@ static int impl_node_process(struct spa_node *node) if (impl->use_converter) { status = spa_node_process(impl->adapter); - - if (impl->direction == SPA_DIRECTION_OUTPUT) - trigger = status & SPA_STATUS_NEED_BUFFER; - else - trigger = status & SPA_STATUS_HAVE_BUFFER; - } + } else { struct spa_io_buffers tmp; @@ -771,10 +766,18 @@ static int impl_node_process(struct spa_node *node) *impl->io = *impl->client_port_mix.io; *impl->client_port_mix.io = tmp; - status = impl->io->status; + status = impl->client_port_mix.io->status | impl->io->status; } spa_log_trace(this->log, "%p: process %d", this, status); + if (impl->direction == SPA_DIRECTION_OUTPUT) { + if (!(status & SPA_STATUS_HAVE_BUFFER)) + spa_log_warn(this->log, "%p: process underrun", this); + trigger = status & SPA_STATUS_NEED_BUFFER; + } + else + trigger = status & SPA_STATUS_HAVE_BUFFER; + if (trigger) spa_graph_run(impl->client_node->node->rt.root.graph);