mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
scheduler: add new scheduler
Make port status SPA_RESULT_OK until events changes it and data processing can start Only start pulling on ports in the OK state Change we way we handle client-nodes, handle them async and continue processing after they signaled completion Add a new scheduler that decouples push and pull. It pushes to peer elements when all inputs are provided and pulls from nodes when all peer outputs are processed.
This commit is contained in:
parent
3315de187c
commit
df59183a66
10 changed files with 188 additions and 37 deletions
|
|
@ -756,16 +756,12 @@ static int spa_proxy_node_process_input(struct spa_node *node)
|
|||
impl = this->impl;
|
||||
|
||||
for (i = 0; i < MAX_INPUTS; i++) {
|
||||
struct spa_port_io *io = this->in_ports[i].io, tmp;
|
||||
struct spa_port_io *io = this->in_ports[i].io;
|
||||
|
||||
if (!io)
|
||||
continue;
|
||||
|
||||
tmp = impl->transport->inputs[i];
|
||||
impl->transport->inputs[i] = *io;
|
||||
if (res == SPA_RESULT_OK)
|
||||
res = tmp.status;
|
||||
*io = tmp;
|
||||
pw_log_trace("%d %d -> %d %d", io->status, io->buffer_id,
|
||||
impl->transport->inputs[i].status,
|
||||
impl->transport->inputs[i].buffer_id);
|
||||
|
|
@ -793,16 +789,12 @@ static int spa_proxy_node_process_output(struct spa_node *node)
|
|||
impl = this->impl;
|
||||
|
||||
for (i = 0; i < MAX_OUTPUTS; i++) {
|
||||
struct spa_port_io *io = this->out_ports[i].io, tmp;
|
||||
struct spa_port_io *io = this->out_ports[i].io;
|
||||
|
||||
if (!io)
|
||||
continue;
|
||||
|
||||
tmp = impl->transport->outputs[i];
|
||||
impl->transport->outputs[i] = *io;
|
||||
if (res == SPA_RESULT_OK)
|
||||
res = tmp.status;
|
||||
*io = tmp;
|
||||
pw_log_trace("%d %d -> %d %d", io->status, io->buffer_id,
|
||||
impl->transport->outputs[i].status,
|
||||
impl->transport->outputs[i].buffer_id);
|
||||
|
|
@ -828,12 +820,19 @@ static int handle_node_message(struct proxy *this, struct pw_client_node_message
|
|||
continue;
|
||||
|
||||
*io = impl->transport->outputs[i];
|
||||
impl->transport->outputs[i].buffer_id = SPA_ID_INVALID;
|
||||
impl->transport->outputs[i].status = SPA_RESULT_OK;
|
||||
pw_log_trace("%d %d", io->status, io->buffer_id);
|
||||
}
|
||||
this->callbacks->have_output(this->callbacks_data);
|
||||
} else if (PW_CLIENT_NODE_MESSAGE_TYPE(message) == PW_CLIENT_NODE_MESSAGE_NEED_INPUT) {
|
||||
for (i = 0; i < MAX_INPUTS; i++) {
|
||||
struct spa_port_io *io = this->in_ports[i].io;
|
||||
|
||||
if (!io)
|
||||
continue;
|
||||
|
||||
*io = impl->transport->inputs[i];
|
||||
pw_log_trace("%d %d", io->status, io->buffer_id);
|
||||
}
|
||||
this->callbacks->need_input(this->callbacks_data);
|
||||
} else if (PW_CLIENT_NODE_MESSAGE_TYPE(message) == PW_CLIENT_NODE_MESSAGE_REUSE_BUFFER) {
|
||||
if (impl->client_reuse) {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
#include <pipewire/core.h>
|
||||
#include <pipewire/data-loop.h>
|
||||
|
||||
#include <spa/graph-scheduler3.h>
|
||||
#include <spa/graph-scheduler6.h>
|
||||
|
||||
/** \cond */
|
||||
struct resource_data {
|
||||
|
|
|
|||
|
|
@ -1124,8 +1124,7 @@ struct pw_link *pw_link_new(struct pw_core *core,
|
|||
this->info.format = NULL;
|
||||
this->info.props = this->properties ? &this->properties->dict : NULL;
|
||||
|
||||
this->io.buffer_id = SPA_ID_INVALID;
|
||||
this->io.status = SPA_RESULT_NEED_BUFFER;
|
||||
this->io = SPA_PORT_IO_INIT;
|
||||
|
||||
spa_graph_port_init(&this->rt.out_port,
|
||||
PW_DIRECTION_OUTPUT,
|
||||
|
|
|
|||
|
|
@ -174,8 +174,7 @@ struct pw_port *pw_port_new(enum pw_direction direction,
|
|||
this->port_id = port_id;
|
||||
this->properties = properties;
|
||||
this->state = PW_PORT_STATE_INIT;
|
||||
this->io.status = SPA_RESULT_NEED_BUFFER;
|
||||
this->io.buffer_id = SPA_ID_INVALID;
|
||||
this->io = SPA_PORT_IO_INIT;
|
||||
|
||||
if (user_data_size > 0)
|
||||
this->user_data = SPA_MEMBER(impl, sizeof(struct impl), void);
|
||||
|
|
|
|||
|
|
@ -565,8 +565,7 @@ static void client_node_transport(void *object, uint32_t node_id,
|
|||
sizeof(struct port));
|
||||
|
||||
for (i = 0; i < data->trans->area->max_input_ports; i++) {
|
||||
data->trans->inputs[i].status = SPA_RESULT_NEED_BUFFER;
|
||||
data->trans->inputs[i].buffer_id = SPA_ID_INVALID;
|
||||
data->trans->inputs[i] = SPA_PORT_IO_INIT;
|
||||
spa_graph_port_init(&data->in_ports[i].input,
|
||||
SPA_DIRECTION_INPUT,
|
||||
i,
|
||||
|
|
@ -1108,22 +1107,17 @@ static int impl_port_reuse_buffer(struct spa_node *node, uint32_t port_id, uint3
|
|||
|
||||
static int impl_process_input(struct spa_node *node)
|
||||
{
|
||||
#if 0
|
||||
struct node_data *data = SPA_CONTAINER_OF(node, struct node_data, out_node_impl);
|
||||
node_have_output(data);
|
||||
#endif
|
||||
pw_log_trace("node %p: process input", node);
|
||||
node_have_output(data);
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int impl_process_output(struct spa_node *node)
|
||||
{
|
||||
#if 0
|
||||
struct node_data *data = SPA_CONTAINER_OF(node, struct node_data, in_node_impl);
|
||||
node_need_input(data);
|
||||
pw_log_trace("node %p: need input", node);
|
||||
#endif
|
||||
pw_log_trace("node %p: process output", node);
|
||||
node_need_input(data);
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue