mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-17 08:56:49 -05:00
Add versions to structures
Use versions instead of size Remove user_data from callbacks, we can simply pass the callback struct.
This commit is contained in:
parent
4a219e81dd
commit
c3b73ba47d
45 changed files with 344 additions and 303 deletions
|
|
@ -98,6 +98,7 @@ struct data {
|
|||
uint32_t n_support;
|
||||
|
||||
struct spa_node *sink;
|
||||
struct spa_node_callbacks sink_callbacks;
|
||||
struct spa_port_io source_sink_io[1];
|
||||
|
||||
struct spa_node *source;
|
||||
|
|
@ -205,19 +206,22 @@ static int make_node(struct data *data, struct spa_node **node, const char *lib,
|
|||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
|
||||
static void on_sink_done(struct spa_node *node, int seq, int res, void *user_data)
|
||||
static void on_sink_done(const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node, int seq, int res)
|
||||
{
|
||||
printf("got done %d %d\n", seq, res);
|
||||
}
|
||||
|
||||
static void on_sink_event(struct spa_node *node, struct spa_event *event, void *user_data)
|
||||
static void on_sink_event(const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node, struct spa_event *event)
|
||||
{
|
||||
printf("got event %d\n", SPA_EVENT_TYPE(event));
|
||||
}
|
||||
|
||||
static void on_sink_need_input(struct spa_node *node, void *user_data)
|
||||
static void on_sink_need_input(const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node)
|
||||
{
|
||||
struct data *data = user_data;
|
||||
struct data *data = SPA_CONTAINER_OF(callbacks, struct data, sink_callbacks);
|
||||
int res;
|
||||
|
||||
res = spa_node_process_output(data->source);
|
||||
|
|
@ -229,13 +233,17 @@ static void on_sink_need_input(struct spa_node *node, void *user_data)
|
|||
}
|
||||
|
||||
static void
|
||||
on_sink_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id, void *user_data)
|
||||
on_sink_reuse_buffer(const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node,
|
||||
uint32_t port_id,
|
||||
uint32_t buffer_id)
|
||||
{
|
||||
struct data *data = user_data;
|
||||
struct data *data = SPA_CONTAINER_OF(callbacks, struct data, sink_callbacks);
|
||||
data->source_sink_io[0].buffer_id = buffer_id;
|
||||
}
|
||||
|
||||
static const struct spa_node_callbacks sink_callbacks = {
|
||||
SPA_VERSION_NODE_CALLBACKS,
|
||||
&on_sink_done,
|
||||
&on_sink_event,
|
||||
&on_sink_need_input,
|
||||
|
|
@ -283,7 +291,8 @@ static int make_nodes(struct data *data, const char *device)
|
|||
printf("can't create alsa-sink: %d\n", res);
|
||||
return res;
|
||||
}
|
||||
spa_node_set_callbacks(data->sink, &sink_callbacks, sizeof(sink_callbacks), data);
|
||||
data->sink_callbacks = sink_callbacks;
|
||||
spa_node_set_callbacks(data->sink, &data->sink_callbacks);
|
||||
|
||||
spa_pod_builder_init(&b, buffer, sizeof(buffer));
|
||||
spa_pod_builder_props(&b, &f[0], data->type.props,
|
||||
|
|
@ -465,7 +474,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
data.map = &default_map.map;
|
||||
data.log = &default_log.log;
|
||||
data.data_loop.size = sizeof(struct spa_loop);
|
||||
data.data_loop.version = SPA_VERSION_LOOP;
|
||||
data.data_loop.add_source = do_add_source;
|
||||
data.data_loop.update_source = do_update_source;
|
||||
data.data_loop.remove_source = do_remove_source;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue