mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
Cleanups
Only pass data to callbacks. Rename some structs Provide methods to access structs
This commit is contained in:
parent
1b79419554
commit
0602d76b9e
57 changed files with 716 additions and 422 deletions
|
|
@ -42,20 +42,20 @@ static inline void spa_graph_scheduler_init(struct spa_graph_scheduler *sched,
|
|||
sched->node = NULL;
|
||||
}
|
||||
|
||||
static inline int spa_graph_scheduler_input(struct spa_graph_node *node, void *user_data)
|
||||
static inline int spa_graph_scheduler_input(void *data)
|
||||
{
|
||||
struct spa_node *n = node->user_data;
|
||||
struct spa_node *n = data;
|
||||
return spa_node_process_input(n);
|
||||
}
|
||||
|
||||
static inline int spa_graph_scheduler_output(struct spa_graph_node *node, void *user_data)
|
||||
static inline int spa_graph_scheduler_output(void *data)
|
||||
{
|
||||
struct spa_node *n = node->user_data;
|
||||
struct spa_node *n = data;
|
||||
return spa_node_process_output(n);
|
||||
}
|
||||
|
||||
static const struct spa_graph_node_methods spa_graph_scheduler_default = {
|
||||
SPA_VERSION_GRAPH_NODE_METHODS,
|
||||
static const struct spa_graph_node_callbacks spa_graph_scheduler_default = {
|
||||
SPA_VERSION_GRAPH_NODE_CALLBACKS,
|
||||
spa_graph_scheduler_input,
|
||||
spa_graph_scheduler_output,
|
||||
};
|
||||
|
|
@ -96,7 +96,7 @@ static inline bool spa_graph_scheduler_iterate(struct spa_graph_scheduler *sched
|
|||
|
||||
switch (n->action) {
|
||||
case SPA_GRAPH_ACTION_IN:
|
||||
n->state = n->methods->process_input(n, n->user_data);
|
||||
n->state = n->callbacks->process_input(n->callbacks_data);
|
||||
debug("node %p processed input state %d\n", n, n->state);
|
||||
if (n == sched->node)
|
||||
break;
|
||||
|
|
@ -105,7 +105,7 @@ static inline bool spa_graph_scheduler_iterate(struct spa_graph_scheduler *sched
|
|||
break;
|
||||
|
||||
case SPA_GRAPH_ACTION_OUT:
|
||||
n->state = n->methods->process_output(n, n->user_data);
|
||||
n->state = n->callbacks->process_output(n->callbacks_data);
|
||||
debug("node %p processed output state %d\n", n, n->state);
|
||||
n->action = SPA_GRAPH_ACTION_CHECK;
|
||||
spa_list_insert(sched->ready.prev, &n->ready_link);
|
||||
|
|
|
|||
|
|
@ -38,35 +38,36 @@ static inline void spa_graph_scheduler_init(struct spa_graph_scheduler *sched,
|
|||
sched->node = NULL;
|
||||
}
|
||||
|
||||
static inline int spa_graph_node_scheduler_input(struct spa_graph_node *node, void *user_data)
|
||||
static inline int spa_graph_node_scheduler_input(void *data)
|
||||
{
|
||||
struct spa_node *n = node->user_data;
|
||||
struct spa_node *n = data;
|
||||
return spa_node_process_input(n);
|
||||
}
|
||||
|
||||
static inline int spa_graph_node_scheduler_output(struct spa_graph_node *node, void *user_data)
|
||||
static inline int spa_graph_node_scheduler_output(void *data)
|
||||
{
|
||||
struct spa_node *n = node->user_data;
|
||||
struct spa_node *n = data;
|
||||
return spa_node_process_output(n);
|
||||
}
|
||||
|
||||
|
||||
static const struct spa_graph_node_methods spa_graph_node_scheduler_default = {
|
||||
SPA_VERSION_GRAPH_NODE_METHODS,
|
||||
static const struct spa_graph_node_callbacks spa_graph_node_scheduler_default = {
|
||||
SPA_VERSION_GRAPH_NODE_CALLBACKS,
|
||||
spa_graph_node_scheduler_input,
|
||||
spa_graph_node_scheduler_output,
|
||||
};
|
||||
|
||||
static inline int spa_graph_port_scheduler_reuse_buffer(struct spa_graph_port *port,
|
||||
uint32_t buffer_id, void *user_data)
|
||||
static inline int spa_graph_port_scheduler_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);
|
||||
struct spa_node *node = port->node->user_data;
|
||||
return spa_node_port_reuse_buffer(node, port->port_id, buffer_id);
|
||||
}
|
||||
|
||||
static const struct spa_graph_port_methods spa_graph_port_scheduler_default = {
|
||||
SPA_VERSION_GRAPH_PORT_METHODS,
|
||||
static const struct spa_graph_port_callbacks spa_graph_port_scheduler_default = {
|
||||
SPA_VERSION_GRAPH_PORT_CALLBACKS,
|
||||
spa_graph_port_scheduler_reuse_buffer,
|
||||
};
|
||||
|
||||
|
|
@ -96,7 +97,7 @@ static inline void spa_graph_scheduler_pull(struct spa_graph_scheduler *sched, s
|
|||
}
|
||||
|
||||
spa_list_for_each_safe(n, t, &ready, ready_link) {
|
||||
n->state = n->methods->process_output(n, n->user_data);
|
||||
n->state = n->callbacks->process_output(n->callbacks_data);
|
||||
debug("peer %p processed out %d\n", n, n->state);
|
||||
if (n->state == SPA_RESULT_NEED_BUFFER)
|
||||
spa_graph_scheduler_pull(sched, n);
|
||||
|
|
@ -113,7 +114,7 @@ static inline void spa_graph_scheduler_pull(struct spa_graph_scheduler *sched, s
|
|||
debug("node %p %d %d\n", node, node->ready_in, node->required_in);
|
||||
|
||||
if (node->required_in > 0 && node->ready_in == node->required_in) {
|
||||
node->state = node->methods->process_input(node, node->user_data);
|
||||
node->state = node->callbacks->process_input(node->callbacks_data);
|
||||
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) {
|
||||
|
|
@ -140,7 +141,7 @@ static inline void spa_graph_scheduler_chain(struct spa_graph_scheduler *sched,
|
|||
|
||||
|
||||
spa_list_for_each_safe(n, t, ready, ready_link) {
|
||||
n->state = n->methods->process_input(n, n->user_data);
|
||||
n->state = n->callbacks->process_input(n->callbacks_data);
|
||||
debug("node %p chain processed in %d\n", n, n->state);
|
||||
if (n->state == SPA_RESULT_HAVE_BUFFER)
|
||||
spa_graph_scheduler_push(sched, n);
|
||||
|
|
@ -183,7 +184,7 @@ static inline void spa_graph_scheduler_push(struct spa_graph_scheduler *sched, s
|
|||
|
||||
spa_graph_scheduler_chain(sched, &ready);
|
||||
|
||||
node->state = node->methods->process_output(node, node->user_data);
|
||||
node->state = node->callbacks->process_output(node->callbacks_data);
|
||||
debug("node %p processed out %d\n", node, node->state);
|
||||
if (node->state == SPA_RESULT_NEED_BUFFER) {
|
||||
node->ready_in = 0;
|
||||
|
|
|
|||
|
|
@ -44,19 +44,19 @@ struct spa_graph {
|
|||
struct spa_list nodes;
|
||||
};
|
||||
|
||||
struct spa_graph_node_methods {
|
||||
#define SPA_VERSION_GRAPH_NODE_METHODS 0
|
||||
struct spa_graph_node_callbacks {
|
||||
#define SPA_VERSION_GRAPH_NODE_CALLBACKS 0
|
||||
uint32_t version;
|
||||
|
||||
int (*process_input) (struct spa_graph_node *node, void *user_data);
|
||||
int (*process_output) (struct spa_graph_node *node, void *user_data);
|
||||
int (*process_input) (void *data);
|
||||
int (*process_output) (void *data);
|
||||
};
|
||||
|
||||
struct spa_graph_port_methods {
|
||||
#define SPA_VERSION_GRAPH_PORT_METHODS 0
|
||||
struct spa_graph_port_callbacks {
|
||||
#define SPA_VERSION_GRAPH_PORT_CALLBACKS 0
|
||||
uint32_t version;
|
||||
|
||||
int (*reuse_buffer) (struct spa_graph_port *port, uint32_t buffer_id, void *user_data);
|
||||
int (*reuse_buffer) (void *data, uint32_t buffer_id);
|
||||
};
|
||||
|
||||
struct spa_graph_node {
|
||||
|
|
@ -73,8 +73,8 @@ struct spa_graph_node {
|
|||
uint32_t max_in;
|
||||
uint32_t required_in;
|
||||
uint32_t ready_in;
|
||||
const struct spa_graph_node_methods *methods;
|
||||
void *user_data;
|
||||
const struct spa_graph_node_callbacks *callbacks;
|
||||
void *callbacks_data;
|
||||
};
|
||||
|
||||
struct spa_graph_port {
|
||||
|
|
@ -85,8 +85,8 @@ struct spa_graph_port {
|
|||
uint32_t flags;
|
||||
struct spa_port_io *io;
|
||||
struct spa_graph_port *peer;
|
||||
const struct spa_graph_port_methods *methods;
|
||||
void *user_data;
|
||||
const struct spa_graph_port_callbacks *callbacks;
|
||||
void *callbacks_data;
|
||||
};
|
||||
|
||||
static inline void spa_graph_init(struct spa_graph *graph)
|
||||
|
|
@ -105,12 +105,12 @@ spa_graph_node_init(struct spa_graph_node *node)
|
|||
}
|
||||
|
||||
static inline void
|
||||
spa_graph_node_set_methods(struct spa_graph_node *node,
|
||||
const struct spa_graph_node_methods *methods,
|
||||
void *user_data)
|
||||
spa_graph_node_set_callbacks(struct spa_graph_node *node,
|
||||
const struct spa_graph_node_callbacks *callbacks,
|
||||
void *data)
|
||||
{
|
||||
node->methods = methods;
|
||||
node->user_data = user_data;
|
||||
node->callbacks = callbacks;
|
||||
node->callbacks_data = data;
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
|
@ -139,12 +139,12 @@ spa_graph_port_init(struct spa_graph_port *port,
|
|||
}
|
||||
|
||||
static inline void
|
||||
spa_graph_port_set_methods(struct spa_graph_port *port,
|
||||
const struct spa_graph_port_methods *methods,
|
||||
void *user_data)
|
||||
spa_graph_port_set_callbacks(struct spa_graph_port *port,
|
||||
const struct spa_graph_port_callbacks *callbacks,
|
||||
void *data)
|
||||
{
|
||||
port->methods = methods;
|
||||
port->user_data = user_data;
|
||||
port->callbacks = callbacks;
|
||||
port->callbacks_data = data;
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ struct spa_monitor_callbacks {
|
|||
#define SPA_VERSION_MONITOR_CALLBACKS 0
|
||||
uint32_t version;
|
||||
|
||||
void (*event) (struct spa_monitor *monitor, struct spa_event *event, void *user_data);
|
||||
void (*event) (void *data, struct spa_event *event);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -145,7 +145,7 @@ struct spa_monitor {
|
|||
*/
|
||||
int (*set_callbacks) (struct spa_monitor *monitor,
|
||||
const struct spa_monitor_callbacks *callbacks,
|
||||
void *user_data);
|
||||
void *data);
|
||||
|
||||
int (*enum_items) (struct spa_monitor *monitor,
|
||||
struct spa_monitor_item **item, uint32_t index);
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ struct spa_node_callbacks {
|
|||
uint32_t version; /**< version of this structure */
|
||||
|
||||
/** Emited when an async operation completed */
|
||||
void (*done) (struct spa_node *node, int seq, int res, void *user_data);
|
||||
void (*done) (void *data, int seq, int res);
|
||||
/**
|
||||
* struct spa_node_callbacks::event:
|
||||
* @node: a #struct spa_node
|
||||
|
|
@ -93,7 +93,7 @@ struct spa_node_callbacks {
|
|||
* This will be called when an out-of-bound event is notified
|
||||
* on @node. the callback can be called from any thread.
|
||||
*/
|
||||
void (*event) (struct spa_node *node, struct spa_event *event, void *user_data);
|
||||
void (*event) (void *data, struct spa_event *event);
|
||||
/**
|
||||
* struct spa_node_callbacks::need_input:
|
||||
* @node: a #struct spa_node
|
||||
|
|
@ -104,7 +104,7 @@ struct spa_node_callbacks {
|
|||
* When this function is NULL, synchronous operation is requested
|
||||
* on the input ports.
|
||||
*/
|
||||
void (*need_input) (struct spa_node *node, void *user_data);
|
||||
void (*need_input) (void *data);
|
||||
/**
|
||||
* struct spa_node_callbacks::have_output:
|
||||
* @node: a #struct spa_node
|
||||
|
|
@ -115,7 +115,7 @@ struct spa_node_callbacks {
|
|||
* When this function is NULL, synchronous operation is requested
|
||||
* on the output ports.
|
||||
*/
|
||||
void (*have_output) (struct spa_node *node, void *user_data);
|
||||
void (*have_output) (void *data);
|
||||
/**
|
||||
* struct spa_node_callbacks::reuse_buffer:
|
||||
* @node: a #struct spa_node
|
||||
|
|
@ -128,9 +128,9 @@ struct spa_node_callbacks {
|
|||
* When this function is NULL, the buffers to reuse will be set in
|
||||
* the io area or the input ports.
|
||||
*/
|
||||
void (*reuse_buffer) (struct spa_node *node,
|
||||
void (*reuse_buffer) (void *data,
|
||||
uint32_t port_id,
|
||||
uint32_t buffer_id, void *user_data);
|
||||
uint32_t buffer_id);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue