audioconvert: improve scheduling

This commit is contained in:
Wim Taymans 2018-06-22 17:27:57 +02:00
parent 4afda5405f
commit 725e41d715
3 changed files with 28 additions and 14 deletions

View file

@ -756,6 +756,7 @@ static int impl_node_process(struct spa_node *node)
{ {
struct impl *this; struct impl *this;
int r, i, res = SPA_STATUS_OK; int r, i, res = SPA_STATUS_OK;
int ready;
spa_return_val_if_fail(node != NULL, -EINVAL); spa_return_val_if_fail(node != NULL, -EINVAL);
@ -763,22 +764,25 @@ static int impl_node_process(struct spa_node *node)
spa_log_trace(this->log, NAME " %p: process %d", this, this->n_links); spa_log_trace(this->log, NAME " %p: process %d", this, this->n_links);
for (i = 0; i < this->n_nodes; i++) { while (1) {
r = spa_node_process(this->nodes[i]); res = SPA_STATUS_OK;
spa_log_trace(this->log, NAME " %p: process %d %d", this, i, r); ready = 0;
for (i = 0; i < this->n_nodes; i++) {
r = spa_node_process(this->nodes[i]);
spa_log_trace(this->log, NAME " %p: process %d %d", this, i, r);
if (i == 0) if (r & SPA_STATUS_HAVE_BUFFER)
res |= r & SPA_STATUS_NEED_BUFFER; ready++;
if (i == this->n_nodes-1)
res |= r & SPA_STATUS_HAVE_BUFFER;
if (!SPA_FLAG_CHECK(r, SPA_STATUS_HAVE_BUFFER)) { if (i == 0)
if (SPA_FLAG_CHECK(r, SPA_STATUS_NEED_BUFFER) && i == 0) res |= r & SPA_STATUS_NEED_BUFFER;
break; if (i == this->n_nodes-1)
res = SPA_STATUS_OK; res |= r & SPA_STATUS_HAVE_BUFFER;
i = -1;
continue;
} }
if (res & SPA_STATUS_HAVE_BUFFER)
break;
if (ready == 0)
break;
} }
spa_log_trace(this->log, NAME " %p: process result: %d", this, res); spa_log_trace(this->log, NAME " %p: process result: %d", this, res);

View file

@ -777,7 +777,7 @@ static int impl_node_process(struct spa_node *node)
spa_log_trace(this->log, NAME " %p: status %d %d", this, inio->status, outio->status); spa_log_trace(this->log, NAME " %p: status %d %d", this, inio->status, outio->status);
if (outio->status == SPA_STATUS_HAVE_BUFFER) if (outio->status == SPA_STATUS_HAVE_BUFFER)
return outio->status; goto done;
if (inio->status != SPA_STATUS_HAVE_BUFFER) if (inio->status != SPA_STATUS_HAVE_BUFFER)
return SPA_STATUS_NEED_BUFFER; return SPA_STATUS_NEED_BUFFER;
@ -824,6 +824,7 @@ static int impl_node_process(struct spa_node *node)
inio->status = SPA_STATUS_NEED_BUFFER; inio->status = SPA_STATUS_NEED_BUFFER;
done:
return SPA_STATUS_HAVE_BUFFER | SPA_STATUS_NEED_BUFFER; return SPA_STATUS_HAVE_BUFFER | SPA_STATUS_NEED_BUFFER;
} }

View file

@ -78,7 +78,10 @@ struct port {
struct spa_io_buffers *io; struct spa_io_buffers *io;
struct spa_io_control_range *ctrl; struct spa_io_control_range *ctrl;
struct spa_port_info info; struct spa_port_info info;
struct spa_dict info_props;
struct spa_dict_item info_props_items[2];
bool have_format; bool have_format;
struct spa_audio_info format; struct spa_audio_info format;
@ -367,8 +370,14 @@ static int init_port(struct impl *this, enum spa_direction direction, uint32_t p
spa_list_init(&port->queue); spa_list_init(&port->queue);
port->info.flags = flags; port->info.flags = flags;
port->info_props_items[0] = SPA_DICT_ITEM_INIT("port.dsp", "32 bit float mono audio");
port->info_props = SPA_DICT_INIT(port->info_props_items, 1);
port->info.props = &port->info_props;
this->n_ports[direction]++; this->n_ports[direction]++;
port->have_format = false; port->have_format = false;
return 0; return 0;
} }