mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-11 13:30:07 -05:00
graph: use spa_node as implementation
Always use a spa_node as the graph implementation, implementing the methods is just as easy. Plug some mem leaks in remote
This commit is contained in:
parent
6953642ed5
commit
577f86be0d
16 changed files with 167 additions and 206 deletions
|
|
@ -45,24 +45,6 @@ static inline void spa_graph_data_init(struct spa_graph_data *data,
|
|||
data->node = NULL;
|
||||
}
|
||||
|
||||
static inline int spa_graph_node_impl_input(void *data)
|
||||
{
|
||||
struct spa_node *n = data;
|
||||
return spa_node_process_input(n);
|
||||
}
|
||||
|
||||
static inline int spa_graph_node_impl_output(void *data)
|
||||
{
|
||||
struct spa_node *n = data;
|
||||
return spa_node_process_output(n);
|
||||
}
|
||||
|
||||
static const struct spa_graph_node_callbacks spa_graph_node_impl_default = {
|
||||
SPA_VERSION_GRAPH_NODE_CALLBACKS,
|
||||
spa_graph_node_impl_input,
|
||||
spa_graph_node_impl_output,
|
||||
};
|
||||
|
||||
static inline void spa_graph_data_port_check(struct spa_graph_data *data, struct spa_graph_port *port)
|
||||
{
|
||||
struct spa_graph_node *node = port->node;
|
||||
|
|
@ -70,7 +52,8 @@ static inline void spa_graph_data_port_check(struct spa_graph_data *data, struct
|
|||
if (port->io->status == SPA_RESULT_HAVE_BUFFER)
|
||||
node->ready_in++;
|
||||
|
||||
debug("port %p node %p check %d %d %d\n", port, node, port->io->status, node->ready_in, node->required_in);
|
||||
debug("port %p node %p check %d %d %d\n", port, node,
|
||||
port->io->status, node->ready_in, node->required_in);
|
||||
|
||||
if (node->required_in > 0 && node->ready_in == node->required_in) {
|
||||
node->state = SPA_GRAPH_STATE_IN;
|
||||
|
|
@ -100,7 +83,7 @@ static inline bool spa_graph_data_iterate(struct spa_graph_data *data)
|
|||
|
||||
switch (n->state) {
|
||||
case SPA_GRAPH_STATE_IN:
|
||||
state = n->callbacks->process_input(n->callbacks_data);
|
||||
state = spa_node_process_input(n->implementation);
|
||||
if (state == SPA_RESULT_NEED_BUFFER)
|
||||
n->state = SPA_GRAPH_STATE_CHECK_IN;
|
||||
else if (state == SPA_RESULT_HAVE_BUFFER)
|
||||
|
|
@ -112,7 +95,7 @@ static inline bool spa_graph_data_iterate(struct spa_graph_data *data)
|
|||
break;
|
||||
|
||||
case SPA_GRAPH_STATE_OUT:
|
||||
state = n->callbacks->process_output(n->callbacks_data);
|
||||
state = spa_node_process_output(n->implementation);
|
||||
if (state == SPA_RESULT_NEED_BUFFER)
|
||||
n->state = SPA_GRAPH_STATE_CHECK_IN;
|
||||
else if (state == SPA_RESULT_HAVE_BUFFER)
|
||||
|
|
|
|||
|
|
@ -26,38 +26,6 @@ extern "C" {
|
|||
|
||||
#include <spa/graph.h>
|
||||
|
||||
static inline int spa_graph_node_impl_input(void *data)
|
||||
{
|
||||
struct spa_node *n = data;
|
||||
return spa_node_process_input(n);
|
||||
}
|
||||
|
||||
static inline int spa_graph_node_impl_output(void *data)
|
||||
{
|
||||
struct spa_node *n = data;
|
||||
return spa_node_process_output(n);
|
||||
}
|
||||
|
||||
static const struct spa_graph_node_callbacks spa_graph_node_impl_default = {
|
||||
SPA_VERSION_GRAPH_NODE_CALLBACKS,
|
||||
spa_graph_node_impl_input,
|
||||
spa_graph_node_impl_output,
|
||||
};
|
||||
|
||||
static inline int spa_graph_port_impl_reuse_buffer(void *data,
|
||||
uint32_t buffer_id)
|
||||
{
|
||||
struct spa_graph_port *port = data;
|
||||
struct spa_node *node = port->node->callbacks_data;
|
||||
debug("port %p reuse buffer %d\n", port, buffer_id);
|
||||
return spa_node_port_reuse_buffer(node, port->port_id, buffer_id);
|
||||
}
|
||||
|
||||
static const struct spa_graph_port_callbacks spa_graph_port_impl_default = {
|
||||
SPA_VERSION_GRAPH_PORT_CALLBACKS,
|
||||
spa_graph_port_impl_reuse_buffer,
|
||||
};
|
||||
|
||||
static inline int spa_graph_impl_need_input(void *data, struct spa_graph_node *node)
|
||||
{
|
||||
struct spa_graph_port *p;
|
||||
|
|
@ -85,7 +53,7 @@ static inline int spa_graph_impl_need_input(void *data, struct spa_graph_node *n
|
|||
}
|
||||
|
||||
spa_list_for_each_safe(n, t, &ready, ready_link) {
|
||||
n->state = n->callbacks->process_output(n->callbacks_data);
|
||||
n->state = spa_node_process_output(n->implementation);
|
||||
debug("peer %p processed out %d\n", n, n->state);
|
||||
if (n->state == SPA_RESULT_NEED_BUFFER)
|
||||
spa_graph_need_input(n->graph, n);
|
||||
|
|
@ -102,7 +70,7 @@ static inline int spa_graph_impl_need_input(void *data, struct spa_graph_node *n
|
|||
debug("node %p ready_in:%d required_in:%d\n", node, node->ready_in, node->required_in);
|
||||
|
||||
if (node->required_in > 0 && node->ready_in == node->required_in) {
|
||||
node->state = node->callbacks->process_input(node->callbacks_data);
|
||||
node->state = spa_node_process_input(node->implementation);
|
||||
debug("node %p processed in %d\n", node, node->state);
|
||||
if (node->state == SPA_RESULT_HAVE_BUFFER) {
|
||||
spa_list_for_each(p, &node->ports[SPA_DIRECTION_OUTPUT], link) {
|
||||
|
|
@ -143,7 +111,7 @@ static inline int spa_graph_impl_have_output(void *data, struct spa_graph_node *
|
|||
}
|
||||
|
||||
spa_list_for_each_safe(n, t, &ready, ready_link) {
|
||||
n->state = n->callbacks->process_input(n->callbacks_data);
|
||||
n->state = spa_node_process_input(n->implementation);
|
||||
debug("node %p chain processed in %d\n", n, n->state);
|
||||
if (n->state == SPA_RESULT_HAVE_BUFFER)
|
||||
spa_graph_have_output(n->graph, n);
|
||||
|
|
@ -159,7 +127,7 @@ static inline int spa_graph_impl_have_output(void *data, struct spa_graph_node *
|
|||
n->ready_link.next = NULL;
|
||||
}
|
||||
|
||||
node->state = node->callbacks->process_output(node->callbacks_data);
|
||||
node->state = spa_node_process_output(node->implementation);
|
||||
debug("node %p processed out %d\n", node, node->state);
|
||||
if (node->state == SPA_RESULT_NEED_BUFFER) {
|
||||
node->ready_in = 0;
|
||||
|
|
|
|||
|
|
@ -56,21 +56,7 @@ struct spa_graph {
|
|||
|
||||
#define spa_graph_need_input(g,n) ((g)->callbacks->need_input((g)->callbacks_data, (n)))
|
||||
#define spa_graph_have_output(g,n) ((g)->callbacks->have_output((g)->callbacks_data, (n)))
|
||||
|
||||
struct spa_graph_node_callbacks {
|
||||
#define SPA_VERSION_GRAPH_NODE_CALLBACKS 0
|
||||
uint32_t version;
|
||||
|
||||
int (*process_input) (void *data);
|
||||
int (*process_output) (void *data);
|
||||
};
|
||||
|
||||
struct spa_graph_port_callbacks {
|
||||
#define SPA_VERSION_GRAPH_PORT_CALLBACKS 0
|
||||
uint32_t version;
|
||||
|
||||
int (*reuse_buffer) (void *data, uint32_t buffer_id);
|
||||
};
|
||||
#define spa_graph_reuse_buffer(g,n,p,i) ((g)->callbacks->reuse_buffer((g)->callbacks_data, (n),(p),(i)))
|
||||
|
||||
struct spa_graph_node {
|
||||
struct spa_list link; /**< link in graph nodes list */
|
||||
|
|
@ -82,9 +68,7 @@ struct spa_graph_node {
|
|||
uint32_t required_in; /**< required number of ports */
|
||||
uint32_t ready_in; /**< number of ports with data */
|
||||
int state; /**< state of the node */
|
||||
/** callbacks and data */
|
||||
const struct spa_graph_node_callbacks *callbacks;
|
||||
void *callbacks_data;
|
||||
struct spa_node *implementation;/**< node implementation */
|
||||
void *scheduler_data; /**< scheduler private data */
|
||||
};
|
||||
|
||||
|
|
@ -96,9 +80,6 @@ struct spa_graph_port {
|
|||
uint32_t flags; /**< port flags */
|
||||
struct spa_port_io *io; /**< io area of the port */
|
||||
struct spa_graph_port *peer; /**< peer */
|
||||
/** callbacks and data */
|
||||
const struct spa_graph_port_callbacks *callbacks;
|
||||
void *callbacks_data;
|
||||
void *scheduler_data; /**< scheduler private data */
|
||||
};
|
||||
|
||||
|
|
@ -127,12 +108,10 @@ spa_graph_node_init(struct spa_graph_node *node)
|
|||
}
|
||||
|
||||
static inline void
|
||||
spa_graph_node_set_callbacks(struct spa_graph_node *node,
|
||||
const struct spa_graph_node_callbacks *callbacks,
|
||||
void *data)
|
||||
spa_graph_node_set_implementation(struct spa_graph_node *node,
|
||||
struct spa_node *implementation)
|
||||
{
|
||||
node->callbacks = callbacks;
|
||||
node->callbacks_data = data;
|
||||
node->implementation = implementation;
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
|
@ -160,15 +139,6 @@ spa_graph_port_init(struct spa_graph_port *port,
|
|||
port->io = io;
|
||||
}
|
||||
|
||||
static inline void
|
||||
spa_graph_port_set_callbacks(struct spa_graph_port *port,
|
||||
const struct spa_graph_port_callbacks *callbacks,
|
||||
void *data)
|
||||
{
|
||||
port->callbacks = callbacks;
|
||||
port->callbacks_data = data;
|
||||
}
|
||||
|
||||
static inline void
|
||||
spa_graph_port_add(struct spa_graph_node *node,
|
||||
struct spa_graph_port *port)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue