Only pass data to callbacks.
Rename some structs
Provide methods to access structs
This commit is contained in:
Wim Taymans 2017-08-06 06:42:26 +02:00
parent 1b79419554
commit 0602d76b9e
57 changed files with 716 additions and 422 deletions

View file

@ -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);

View file

@ -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;

View file

@ -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

View file

@ -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);

View file

@ -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);
};

View file

@ -59,7 +59,7 @@ struct impl {
struct spa_loop *main_loop;
const struct spa_monitor_callbacks *callbacks;
void *user_data;
void *callbacks_data;
struct udev *udev;
struct udev_monitor *umonitor;
@ -350,7 +350,7 @@ static void impl_on_fd_events(struct spa_source *source)
spa_pod_builder_object(&b, &f[0], 0, type, SPA_POD_TYPE_POD, this->item);
event = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_event);
this->callbacks->event(&this->monitor, event, this->user_data);
this->callbacks->event(this->callbacks_data, event);
}
close_card(this);
}
@ -358,7 +358,7 @@ static void impl_on_fd_events(struct spa_source *source)
static int
impl_monitor_set_callbacks(struct spa_monitor *monitor,
const struct spa_monitor_callbacks *callbacks,
void *user_data)
void *data)
{
int res;
struct impl *this;
@ -368,7 +368,7 @@ impl_monitor_set_callbacks(struct spa_monitor *monitor,
this = SPA_CONTAINER_OF(monitor, struct impl, monitor);
this->callbacks = callbacks;
this->user_data = user_data;
this->callbacks_data = data;
if (callbacks) {
if ((res = impl_udev_open(this)) < 0)

View file

@ -92,7 +92,7 @@ static int do_send_done(struct spa_loop *loop, bool async, uint32_t seq, size_t
{
struct state *this = user_data;
this->callbacks->done(&this->node, seq, *(int*)data, this->user_data);
this->callbacks->done(this->callbacks_data, seq, *(int*)data);
return SPA_RESULT_OK;
}
@ -153,7 +153,7 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
static int
impl_node_set_callbacks(struct spa_node *node,
const struct spa_node_callbacks *callbacks,
void *user_data)
void *data)
{
struct state *this;
@ -162,7 +162,7 @@ impl_node_set_callbacks(struct spa_node *node,
this = SPA_CONTAINER_OF(node, struct state, node);
this->callbacks = callbacks;
this->user_data = user_data;
this->callbacks_data = data;
return SPA_RESULT_OK;
}

View file

@ -94,7 +94,7 @@ static int do_send_done(struct spa_loop *loop, bool async, uint32_t seq, size_t
{
struct state *this = user_data;
this->callbacks->done(&this->node, seq, *(int*)data, this->user_data);
this->callbacks->done(this->callbacks_data, seq, *(int*)data);
return SPA_RESULT_OK;
}
@ -171,7 +171,7 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
static int
impl_node_set_callbacks(struct spa_node *node,
const struct spa_node_callbacks *callbacks,
void *user_data)
void *data)
{
struct state *this;
@ -180,7 +180,7 @@ impl_node_set_callbacks(struct spa_node *node,
this = SPA_CONTAINER_OF(node, struct state, node);
this->callbacks = callbacks;
this->user_data = user_data;
this->callbacks_data = data;
return SPA_RESULT_OK;
}

View file

@ -326,7 +326,7 @@ pull_frames(struct state *state,
io->range.offset = state->sample_count * state->frame_size;
io->range.min_size = state->threshold * state->frame_size;
io->range.max_size = frames * state->frame_size;
state->callbacks->need_input(&state->node, state->user_data);
state->callbacks->need_input(state->callbacks_data);
}
while (!spa_list_is_empty(&state->ready) && to_write > 0) {
uint8_t *src, *dst;
@ -373,10 +373,9 @@ pull_frames(struct state *state,
b->outstanding = true;
state->io->buffer_id = b->outbuf->id;
spa_log_trace(state->log, "alsa-util %p: reuse buffer %u", state, b->outbuf->id);
state->callbacks->reuse_buffer(&state->node,
state->callbacks->reuse_buffer(state->callbacks_data,
0,
b->outbuf->id,
state->user_data);
b->outbuf->id);
state->ready_offset = 0;
}
total_frames += n_frames;
@ -432,7 +431,7 @@ push_frames(struct state *state,
b->outstanding = true;
io->buffer_id = b->outbuf->id;
io->status = SPA_RESULT_HAVE_BUFFER;
state->callbacks->have_output(&state->node, state->user_data);
state->callbacks->have_output(state->callbacks_data);
}
}
return total_frames;

View file

@ -119,7 +119,7 @@ struct state {
snd_output_t *output;
const struct spa_node_callbacks *callbacks;
void *user_data;
void *callbacks_data;
uint8_t props_buffer[1024];
struct props props;

View file

@ -124,7 +124,7 @@ struct impl {
struct props props;
const struct spa_node_callbacks *callbacks;
void *user_data;
void *callbacks_data;
struct spa_source timer_source;
struct itimerspec timerspec;
@ -352,7 +352,7 @@ static void on_output(struct spa_source *source)
res = make_buffer(this);
if (res == SPA_RESULT_HAVE_BUFFER)
this->callbacks->have_output(&this->node, this->user_data);
this->callbacks->have_output(this->callbacks_data);
}
static int impl_node_send_command(struct spa_node *node, const struct spa_command *command)
@ -407,7 +407,7 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
static int
impl_node_set_callbacks(struct spa_node *node,
const struct spa_node_callbacks *callbacks,
void *user_data)
void *data)
{
struct impl *this;
@ -420,7 +420,7 @@ impl_node_set_callbacks(struct spa_node *node,
return SPA_RESULT_ERROR;
}
this->callbacks = callbacks;
this->user_data = user_data;
this->callbacks_data = data;
return SPA_RESULT_OK;
}

View file

@ -92,7 +92,7 @@ struct impl {
struct props props;
const struct spa_node_callbacks *callbacks;
void *user_data;
void *callbacks_data;
struct spa_source timer_source;
struct itimerspec timerspec;
@ -226,7 +226,7 @@ static int consume_buffer(struct impl *this)
if (spa_list_is_empty(&this->ready)) {
io->status = SPA_RESULT_NEED_BUFFER;
if (this->callbacks->need_input)
this->callbacks->need_input(&this->node, this->user_data);
this->callbacks->need_input(this->callbacks_data);
}
if (spa_list_is_empty(&this->ready)) {
spa_log_error(this->log, NAME " %p: no buffers", this);
@ -322,7 +322,7 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
static int
impl_node_set_callbacks(struct spa_node *node,
const struct spa_node_callbacks *callbacks,
void *user_data)
void *data)
{
struct impl *this;
@ -335,7 +335,7 @@ impl_node_set_callbacks(struct spa_node *node,
return SPA_RESULT_ERROR;
}
this->callbacks = callbacks;
this->user_data = user_data;
this->callbacks_data = data;
return SPA_RESULT_OK;
}

View file

@ -95,7 +95,7 @@ struct impl {
struct props props;
const struct spa_node_callbacks *callbacks;
void *user_data;
void *callbacks_data;
struct spa_source timer_source;
struct itimerspec timerspec;
@ -279,7 +279,7 @@ static void on_output(struct spa_source *source)
res = make_buffer(this);
if (res == SPA_RESULT_HAVE_BUFFER && this->callbacks && this->callbacks->have_output)
this->callbacks->have_output(&this->node, this->user_data);
this->callbacks->have_output(this->callbacks_data);
}
static int impl_node_send_command(struct spa_node *node, const struct spa_command *command)
@ -334,7 +334,7 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
static int
impl_node_set_callbacks(struct spa_node *node,
const struct spa_node_callbacks *callbacks,
void *user_data)
void *data)
{
struct impl *this;
@ -347,7 +347,7 @@ impl_node_set_callbacks(struct spa_node *node,
return SPA_RESULT_ERROR;
}
this->callbacks = callbacks;
this->user_data = user_data;
this->callbacks_data = data;
return SPA_RESULT_OK;
}

View file

@ -61,7 +61,7 @@ struct impl {
struct spa_loop *main_loop;
const struct spa_monitor_callbacks *callbacks;
void *user_data;
void *callbacks_data;
struct udev *udev;
struct udev_monitor *umonitor;
@ -231,13 +231,13 @@ static void impl_on_fd_events(struct spa_source *source)
spa_pod_builder_object(&b, &f[0], 0, type, SPA_POD_TYPE_POD, this->uitem.item);
event = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_event);
this->callbacks->event(&this->monitor, event, this->user_data);
this->callbacks->event(this->callbacks_data, event);
}
static int
impl_monitor_set_callbacks(struct spa_monitor *monitor,
const struct spa_monitor_callbacks *callbacks,
void *user_data)
void *data)
{
int res;
struct impl *this;
@ -247,7 +247,7 @@ impl_monitor_set_callbacks(struct spa_monitor *monitor,
this = SPA_CONTAINER_OF(monitor, struct impl, monitor);
this->callbacks = callbacks;
this->user_data = user_data;
this->callbacks_data = data;
if (callbacks) {
if ((res = impl_udev_open(this)) < 0)
return res;

View file

@ -158,7 +158,7 @@ struct impl {
struct props props;
const struct spa_node_callbacks *callbacks;
void *user_data;
void *callbacks_data;
struct port out_ports[1];
};
@ -237,7 +237,7 @@ static int do_pause_done(struct spa_loop *loop,
if (SPA_RESULT_IS_OK(res))
res = spa_v4l2_stream_off(this);
this->callbacks->done(&this->node, seq, res, this->user_data);
this->callbacks->done(this->callbacks_data, seq, res);
return SPA_RESULT_OK;
}
@ -277,7 +277,7 @@ static int do_start_done(struct spa_loop *loop,
struct impl *this = user_data;
int res = *(int*)data;
this->callbacks->done(&this->node, seq, res, this->user_data);
this->callbacks->done(this->callbacks_data, seq, res);
return SPA_RESULT_OK;
}
@ -360,7 +360,7 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
static int impl_node_set_callbacks(struct spa_node *node,
const struct spa_node_callbacks *callbacks,
void *user_data)
void *data)
{
struct impl *this;
@ -369,7 +369,7 @@ static int impl_node_set_callbacks(struct spa_node *node,
this = SPA_CONTAINER_OF(node, struct impl, node);
this->callbacks = callbacks;
this->user_data = user_data;
this->callbacks_data = data;
return SPA_RESULT_OK;
}

View file

@ -934,7 +934,7 @@ static int mmap_read(struct impl *this)
b->outstanding = true;
io->buffer_id = b->outbuf->id;
io->status = SPA_RESULT_HAVE_BUFFER;
this->callbacks->have_output(&this->node, this->user_data);
this->callbacks->have_output(this->callbacks_data);
return SPA_RESULT_OK;
}

View file

@ -114,7 +114,7 @@ struct impl {
struct props props;
const struct spa_node_callbacks *callbacks;
void *user_data;
void *callbacks_data;
struct spa_source timer_source;
struct itimerspec timerspec;
@ -303,7 +303,7 @@ static void on_output(struct spa_source *source)
res = make_buffer(this);
if (res == SPA_RESULT_HAVE_BUFFER)
this->callbacks->have_output(&this->node, this->user_data);
this->callbacks->have_output(this->callbacks_data);
}
static int impl_node_send_command(struct spa_node *node, const struct spa_command *command)
@ -358,7 +358,7 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
static int
impl_node_set_callbacks(struct spa_node *node,
const struct spa_node_callbacks *callbacks,
void *user_data)
void *data)
{
struct impl *this;
@ -371,7 +371,7 @@ impl_node_set_callbacks(struct spa_node *node,
return SPA_RESULT_ERROR;
}
this->callbacks = callbacks;
this->user_data = user_data;
this->callbacks_data = data;
return SPA_RESULT_OK;
}

View file

@ -110,7 +110,7 @@ struct impl {
struct props props;
const struct spa_node_callbacks *callbacks;
void *user_data;
void *callbacks_data;
uint8_t format_buffer[1024];
struct spa_audio_info current_format;
@ -210,7 +210,7 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
static int
impl_node_set_callbacks(struct spa_node *node,
const struct spa_node_callbacks *callbacks,
void *user_data)
void *data)
{
struct impl *this;
@ -219,7 +219,7 @@ impl_node_set_callbacks(struct spa_node *node,
this = SPA_CONTAINER_OF(node, struct impl, node);
this->callbacks = callbacks;
this->user_data = user_data;
this->callbacks_data = data;
return SPA_RESULT_OK;
}
@ -649,7 +649,7 @@ static struct spa_buffer *find_free_buffer(struct impl *this, struct port *port)
static inline void release_buffer(struct impl *this, struct spa_buffer *buffer)
{
if (this->callbacks && this->callbacks->reuse_buffer)
this->callbacks->reuse_buffer(&this->node, 0, buffer->id, this->user_data);
this->callbacks->reuse_buffer(this->callbacks_data, 0, buffer->id);
}
static void do_volume(struct impl *this, struct spa_buffer *dbuf, struct spa_buffer *sbuf)

View file

@ -217,19 +217,19 @@ 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(void *data, 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(void *data, 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(void *_data)
{
struct data *data = user_data;
struct data *data = _data;
spa_graph_scheduler_pull(&data->sched, &data->sink_node);
@ -237,20 +237,19 @@ 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(void *_data, uint32_t port_id, uint32_t buffer_id)
{
struct data *data = user_data;
struct data *data = _data;
data->volume_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,
NULL,
&on_sink_reuse_buffer
.done = on_sink_done,
.event = on_sink_event,
.need_input = on_sink_need_input,
.reuse_buffer = on_sink_reuse_buffer
};
static int do_add_source(struct spa_loop *loop, struct spa_source *source)
@ -341,13 +340,13 @@ static int make_nodes(struct data *data, const char *device)
spa_node_port_set_io(data->sink, SPA_DIRECTION_INPUT, 0, &data->volume_sink_io[0]);
spa_graph_node_init(&data->source_node);
spa_graph_node_set_methods(&data->source_node, &spa_graph_scheduler_default, data->source);
spa_graph_node_set_callbacks(&data->source_node, &spa_graph_scheduler_default, data->source);
spa_graph_node_add(&data->graph, &data->source_node);
spa_graph_port_init(&data->source_out, SPA_DIRECTION_OUTPUT, 0, 0, &data->source_volume_io[0]);
spa_graph_port_add(&data->source_node, &data->source_out);
spa_graph_node_init(&data->volume_node);
spa_graph_node_set_methods(&data->volume_node, &spa_graph_scheduler_default, data->volume);
spa_graph_node_set_callbacks(&data->volume_node, &spa_graph_scheduler_default, data->volume);
spa_graph_node_add(&data->graph, &data->volume_node);
spa_graph_port_init(&data->volume_in, SPA_DIRECTION_INPUT, 0, 0, &data->source_volume_io[0]);
spa_graph_port_add(&data->volume_node, &data->volume_in);
@ -358,7 +357,7 @@ static int make_nodes(struct data *data, const char *device)
spa_graph_port_add(&data->volume_node, &data->volume_out);
spa_graph_node_init(&data->sink_node);
spa_graph_node_set_methods(&data->sink_node, &spa_graph_scheduler_default, data->sink);
spa_graph_node_set_callbacks(&data->sink_node, &spa_graph_scheduler_default, data->sink);
spa_graph_node_add(&data->graph, &data->sink_node);
spa_graph_port_init(&data->sink_in, SPA_DIRECTION_INPUT, 0, 0, &data->volume_sink_io[0]);
spa_graph_port_add(&data->sink_node, &data->sink_in);

View file

@ -228,19 +228,19 @@ 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(void *data, 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(void *data, 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(void *_data)
{
struct data *data = user_data;
struct data *data = _data;
#ifdef USE_GRAPH
spa_graph_scheduler_pull(&data->sched, &data->sink_node);
while (spa_graph_scheduler_iterate(&data->sched));
@ -279,23 +279,20 @@ static void on_sink_need_input(struct spa_node *node, void *user_data)
}
static void
on_sink_reuse_buffer(struct spa_node *node,
on_sink_reuse_buffer(void *_data,
uint32_t port_id,
uint32_t buffer_id,
void *user_data)
uint32_t buffer_id)
{
struct data *data = user_data;
struct data *data = _data;
data->mix_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,
NULL,
&on_sink_reuse_buffer
.done = on_sink_done,
.event = on_sink_event,
.need_input = &on_sink_need_input,
.reuse_buffer = on_sink_reuse_buffer
};
static int do_add_source(struct spa_loop *loop, struct spa_source *source)
@ -419,19 +416,19 @@ static int make_nodes(struct data *data, const char *device)
#ifdef USE_GRAPH
spa_graph_node_init(&data->source1_node);
spa_graph_node_set_methods(&data->source1_node, &spa_graph_scheduler_default, data->source1);
spa_graph_node_set_callbacks(&data->source1_node, &spa_graph_scheduler_default, data->source1);
spa_graph_port_init(&data->source1_out, SPA_DIRECTION_OUTPUT, 0, 0, &data->source1_mix_io[0]);
spa_graph_port_add(&data->source1_node, &data->source1_out);
spa_graph_node_add(&data->graph, &data->source1_node);
spa_graph_node_init(&data->source2_node);
spa_graph_node_set_methods(&data->source2_node, &spa_graph_scheduler_default, data->source2);
spa_graph_node_set_callbacks(&data->source2_node, &spa_graph_scheduler_default, data->source2);
spa_graph_port_init(&data->source2_out, SPA_DIRECTION_OUTPUT, 0, 0, &data->source2_mix_io[0]);
spa_graph_port_add(&data->source2_node, &data->source2_out);
spa_graph_node_add(&data->graph, &data->source2_node);
spa_graph_node_init(&data->mix_node);
spa_graph_node_set_methods(&data->mix_node, &spa_graph_scheduler_default, data->mix);
spa_graph_node_set_callbacks(&data->mix_node, &spa_graph_scheduler_default, data->mix);
spa_graph_port_init(&data->mix_in[0], SPA_DIRECTION_INPUT,
data->mix_ports[0], 0, &data->source1_mix_io[0]);
spa_graph_port_add(&data->mix_node, &data->mix_in[0]);
@ -447,7 +444,7 @@ static int make_nodes(struct data *data, const char *device)
spa_graph_port_add(&data->mix_node, &data->mix_out);
spa_graph_node_init(&data->sink_node);
spa_graph_node_set_methods(&data->sink_node, &spa_graph_scheduler_default, data->sink);
spa_graph_node_set_callbacks(&data->sink_node, &spa_graph_scheduler_default, data->sink);
spa_graph_port_init(&data->sink_in, SPA_DIRECTION_INPUT, 0, 0, &data->mix_sink_io[0]);
spa_graph_port_add(&data->sink_node, &data->sink_in);
spa_graph_node_add(&data->graph, &data->sink_node);

View file

@ -242,21 +242,21 @@ static void on_source_push(struct data *data)
}
}
static void on_sink_done(struct spa_node *node, int seq, int res, void *user_data)
static void on_sink_done(void *_data, int seq, int res)
{
struct data *data = user_data;
struct data *data = _data;
spa_log_trace(data->log, "got sink done %d %d", seq, res);
}
static void on_sink_event(struct spa_node *node, struct spa_event *event, void *user_data)
static void on_sink_event(void *_data, struct spa_event *event)
{
struct data *data = user_data;
struct data *data = _data;
spa_log_trace(data->log, "got sink event %d", SPA_EVENT_TYPE(event));
}
static void on_sink_need_input(struct spa_node *node, void *user_data)
static void on_sink_need_input(void *_data)
{
struct data *data = user_data;
struct data *data = _data;
spa_log_trace(data->log, "need input");
on_sink_pull(data);
if (--data->iterations == 0)
@ -264,37 +264,36 @@ 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(void *_data, uint32_t port_id, uint32_t buffer_id)
{
struct data *data = user_data;
struct data *data = _data;
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,
NULL,
&on_sink_reuse_buffer
.done = on_sink_done,
.event = on_sink_event,
.need_input = on_sink_need_input,
.reuse_buffer = on_sink_reuse_buffer
};
static void on_source_done(struct spa_node *node, int seq, int res, void *user_data)
static void on_source_done(void *_data, int seq, int res)
{
struct data *data = user_data;
struct data *data = _data;
spa_log_trace(data->log, "got source done %d %d", seq, res);
}
static void on_source_event(struct spa_node *node, struct spa_event *event, void *user_data)
static void on_source_event(void *_data, struct spa_event *event)
{
struct data *data = user_data;
struct data *data = _data;
spa_log_trace(data->log, "got source event %d", SPA_EVENT_TYPE(event));
}
static void on_source_have_output(struct spa_node *node, void *user_data)
static void on_source_have_output(void *_data)
{
struct data *data = user_data;
struct data *data = _data;
spa_log_trace(data->log, "have_output");
on_source_push(data);
if (--data->iterations == 0)
@ -303,11 +302,9 @@ static void on_source_have_output(struct spa_node *node, void *user_data)
static const struct spa_node_callbacks source_callbacks = {
SPA_VERSION_NODE_CALLBACKS,
&on_source_done,
&on_source_event,
NULL,
&on_source_have_output,
NULL
.done = on_source_done,
.event = on_source_event,
.have_output = on_source_have_output
};
@ -367,7 +364,7 @@ static int make_nodes(struct data *data)
spa_node_port_set_io(data->sink, SPA_DIRECTION_INPUT, 0, &data->source_sink_io[0]);
spa_graph_node_init(&data->source_node);
spa_graph_node_set_methods(&data->source_node, &spa_graph_scheduler_default, data->source);
spa_graph_node_set_callbacks(&data->source_node, &spa_graph_scheduler_default, data->source);
spa_graph_node_add(&data->graph, &data->source_node);
data->source_node.flags = (data->mode & MODE_ASYNC_PUSH) ? SPA_GRAPH_NODE_FLAG_ASYNC : 0;
@ -375,7 +372,7 @@ static int make_nodes(struct data *data)
spa_graph_port_add(&data->source_node, &data->source_out);
spa_graph_node_init(&data->sink_node);
spa_graph_node_set_methods(&data->sink_node, &spa_graph_scheduler_default, data->sink);
spa_graph_node_set_callbacks(&data->sink_node, &spa_graph_scheduler_default, data->sink);
spa_graph_node_add(&data->graph, &data->sink_node);
data->sink_node.flags = (data->mode & MODE_ASYNC_PULL) ? SPA_GRAPH_NODE_FLAG_ASYNC : 0;

View file

@ -205,19 +205,19 @@ 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(void *data, 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(void *data, 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(void *_data)
{
struct data *data = user_data;
struct data *data = _data;
int res;
res = spa_node_process_output(data->source);
@ -229,22 +229,20 @@ static void on_sink_need_input(struct spa_node *node, void *user_data)
}
static void
on_sink_reuse_buffer(struct spa_node *node,
on_sink_reuse_buffer(void *_data,
uint32_t port_id,
uint32_t buffer_id,
void *user_data)
uint32_t buffer_id)
{
struct data *data = user_data;
struct data *data = _data;
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,
NULL,
&on_sink_reuse_buffer
.done = on_sink_done,
.event = on_sink_event,
.need_input = on_sink_need_input,
.reuse_buffer = on_sink_reuse_buffer
};
static int do_add_source(struct spa_loop *loop, struct spa_source *source)

View file

@ -176,23 +176,23 @@ static void handle_events(struct data *data)
}
}
static void on_source_done(struct spa_node *node, int seq, int res, void *user_data)
static void on_source_done(void *data, int seq, int res)
{
printf("got done %d %d\n", seq, res);
}
static void on_source_event(struct spa_node *node, struct spa_event *event, void *user_data)
static void on_source_event(void *_data, struct spa_event *event)
{
struct data *data = user_data;
struct data *data = _data;
handle_events(data);
printf("got event %d\n", SPA_EVENT_TYPE(event));
}
static void on_source_have_output(struct spa_node *node, void *user_data)
static void on_source_have_output(void *_data)
{
struct data *data = user_data;
struct data *data = _data;
int res;
struct spa_buffer *b;
void *sdata, *ddata;
@ -262,11 +262,9 @@ static void on_source_have_output(struct spa_node *node, void *user_data)
static const struct spa_node_callbacks source_callbacks = {
SPA_VERSION_NODE_CALLBACKS,
&on_source_done,
&on_source_event,
NULL,
&on_source_have_output,
NULL
.done = on_source_done,
.event = on_source_event,
.have_output = on_source_have_output
};
static int do_add_source(struct spa_loop *loop, struct spa_source *source)

View file

@ -63,10 +63,9 @@ static void inspect_item(struct data *data, struct spa_monitor_item *item)
spa_debug_pod(&item->object.pod);
}
static void on_monitor_event(struct spa_monitor *monitor,
struct spa_event *event, void *user_data)
static void on_monitor_event(void *_data, struct spa_event *event)
{
struct data *data = user_data;
struct data *data = _data;
if (SPA_EVENT_TYPE(event) == data->type.monitor.Added) {
fprintf(stderr, "added:\n");
@ -102,7 +101,7 @@ static void do_remove_source(struct spa_source *source)
static const struct spa_monitor_callbacks impl_callbacks = {
SPA_VERSION_MONITOR_CALLBACKS,
on_monitor_event,
.event = on_monitor_event,
};
static void handle_monitor(struct data *data, struct spa_monitor *monitor)

View file

@ -66,15 +66,15 @@ struct pw_protocol_native_ext {
};
#define pw_protocol_native_begin_proxy(p,...) pw_protocol_ext((p)->remote->conn->protocol,struct pw_protocol_native_ext,begin_proxy,p,__VA_ARGS__)
#define pw_protocol_native_add_proxy_fd(p,...) pw_protocol_ext((p)->remote->conn->protocol,struct pw_protocol_native_ext,add_proxy_fd,p,__VA_ARGS__)
#define pw_protocol_native_get_proxy_fd(p,...) pw_protocol_ext((p)->remote->conn->protocol,struct pw_protocol_native_ext,get_proxy_fd,p,__VA_ARGS__)
#define pw_protocol_native_end_proxy(p,...) pw_protocol_ext((p)->remote->conn->protocol,struct pw_protocol_native_ext,end_proxy,p,__VA_ARGS__)
#define pw_protocol_native_begin_proxy(p,...) pw_protocol_ext(pw_proxy_get_protocol(p),struct pw_protocol_native_ext,begin_proxy,p,__VA_ARGS__)
#define pw_protocol_native_add_proxy_fd(p,...) pw_protocol_ext(pw_proxy_get_protocol(p),struct pw_protocol_native_ext,add_proxy_fd,p,__VA_ARGS__)
#define pw_protocol_native_get_proxy_fd(p,...) pw_protocol_ext(pw_proxy_get_protocol(p),struct pw_protocol_native_ext,get_proxy_fd,p,__VA_ARGS__)
#define pw_protocol_native_end_proxy(p,...) pw_protocol_ext(pw_proxy_get_protocol(p),struct pw_protocol_native_ext,end_proxy,p,__VA_ARGS__)
#define pw_protocol_native_begin_resource(r,...) pw_protocol_ext((r)->client->protocol,struct pw_protocol_native_ext,begin_resource,r,__VA_ARGS__)
#define pw_protocol_native_add_resource_fd(r,...) pw_protocol_ext((r)->client->protocol,struct pw_protocol_native_ext,add_resource_fd,r,__VA_ARGS__)
#define pw_protocol_native_get_resource_fd(r,...) pw_protocol_ext((r)->client->protocol,struct pw_protocol_native_ext,get_resource_fd,r,__VA_ARGS__)
#define pw_protocol_native_end_resource(r,...) pw_protocol_ext((r)->client->protocol,struct pw_protocol_native_ext,end_resource,r,__VA_ARGS__)
#define pw_protocol_native_begin_resource(r,...) pw_protocol_ext(pw_resource_get_protocol(r),struct pw_protocol_native_ext,begin_resource,r,__VA_ARGS__)
#define pw_protocol_native_add_resource_fd(r,...) pw_protocol_ext(pw_resource_get_protocol(r),struct pw_protocol_native_ext,add_resource_fd,r,__VA_ARGS__)
#define pw_protocol_native_get_resource_fd(r,...) pw_protocol_ext(pw_resource_get_protocol(r),struct pw_protocol_native_ext,get_resource_fd,r,__VA_ARGS__)
#define pw_protocol_native_end_resource(r,...) pw_protocol_ext(pw_resource_get_protocol(r),struct pw_protocol_native_ext,end_resource,r,__VA_ARGS__)
#ifdef __cplusplus
} /* extern "C" */

View file

@ -509,7 +509,7 @@ on_state_changed (void *data,
}
static void
parse_stream_properties (GstPipeWireSrc *pwsrc, struct pw_properties *props)
parse_stream_properties (GstPipeWireSrc *pwsrc, const struct pw_properties *props)
{
const gchar *var;
gboolean is_live;

View file

@ -24,12 +24,12 @@
#include "config.h"
#include "pipewire/interfaces.h"
#include "pipewire/private.h"
#include "pipewire/core.h"
#include "pipewire/module.h"
struct impl {
struct pw_core *core;
struct pw_type *t;
struct pw_module *module;
struct pw_properties *properties;
@ -76,10 +76,12 @@ link_port_unlinked(void *data, struct pw_port *port)
struct node_info *info = data;
struct pw_link *link = info->link;
struct impl *impl = info->impl;
struct pw_port *input = pw_link_get_input(link);
pw_log_debug("module %p: link %p: port %p unlinked", impl, link, port);
if (port->direction == PW_DIRECTION_OUTPUT && link->input)
try_link_port(link->input->node, link->input, info);
if (pw_port_get_direction(port) == PW_DIRECTION_OUTPUT && input)
try_link_port(pw_port_get_node(input), input, info);
}
static void
@ -91,23 +93,8 @@ link_state_changed(void *data, enum pw_link_state old, enum pw_link_state state,
switch (state) {
case PW_LINK_STATE_ERROR:
{
struct pw_resource *resource;
pw_log_debug("module %p: link %p: state error: %s", impl, link, error);
spa_list_for_each(resource, &link->resource_list, link) {
pw_core_resource_error(resource->client->core_resource,
resource->id, SPA_RESULT_ERROR, error);
}
if (info->node->owner) {
pw_core_resource_error(info->node->owner->client->core_resource,
info->node->owner->id,
SPA_RESULT_ERROR, error);
}
break;
}
pw_log_debug("module %p: link %p: state error: %s", impl, link, error);
break;
case PW_LINK_STATE_UNLINKED:
pw_log_debug("module %p: link %p: unlinked", impl, link);
@ -151,7 +138,7 @@ static void try_link_port(struct pw_node *node, struct pw_port *port, struct nod
struct pw_link *link;
struct pw_port *target;
props = node->properties;
props = pw_node_get_properties(node);
if (props == NULL) {
pw_log_debug("module %p: node has no properties", impl);
return;
@ -175,11 +162,13 @@ static void try_link_port(struct pw_node *node, struct pw_port *port, struct nod
if (target == NULL)
goto error;
if (port->direction == PW_DIRECTION_OUTPUT)
link = pw_link_new(impl->core, impl->module->global, port, target, NULL, NULL, &error);
else
link = pw_link_new(impl->core, impl->module->global, target, port, NULL, NULL, &error);
if (pw_port_get_direction(port) == PW_DIRECTION_INPUT) {
struct pw_port *tmp = target;
target = port;
port = tmp;
}
link = pw_link_new(impl->core, pw_module_get_global(impl->module), port, target, NULL, NULL, &error);
if (link == NULL)
goto error;
@ -192,9 +181,10 @@ static void try_link_port(struct pw_node *node, struct pw_port *port, struct nod
error:
pw_log_error("module %p: can't link node '%s'", impl, error);
if (info->node->owner && info->node->owner->client->core_resource) {
pw_core_resource_error(info->node->owner->client->core_resource,
info->node->owner->id, SPA_RESULT_ERROR, error);
{
struct pw_resource *owner = pw_node_get_owner(info->node);
if (owner)
pw_resource_error(owner, SPA_RESULT_ERROR, error);
}
free(error);
return;
@ -210,15 +200,16 @@ static void node_port_removed(void *data, struct pw_port *port)
{
}
static bool on_node_port_added(void *data, struct pw_port *port)
{
node_port_added(data, port);
return true;
}
static void on_node_created(struct pw_node *node, struct node_info *info)
{
struct pw_port *port;
spa_list_for_each(port, &node->input_ports, link)
node_port_added(info, port);
spa_list_for_each(port, &node->output_ports, link)
node_port_added(info, port);
pw_node_for_each_port(node, PW_DIRECTION_INPUT, on_node_port_added, info);
pw_node_for_each_port(node, PW_DIRECTION_OUTPUT, on_node_port_added, info);
}
static void
@ -242,8 +233,8 @@ core_global_added(void *data, struct pw_global *global)
{
struct impl *impl = data;
if (global->type == impl->core->type.node) {
struct pw_node *node = global->object;
if (pw_global_get_type(global) == impl->t->node) {
struct pw_node *node = pw_global_get_object(global);
struct node_info *ninfo;
ninfo = calloc(1, sizeof(struct node_info));
@ -257,7 +248,7 @@ core_global_added(void *data, struct pw_global *global)
pw_log_debug("module %p: node %p added", impl, node);
if (node->info.state > PW_NODE_STATE_CREATING)
if (pw_node_get_info(node)->state > PW_NODE_STATE_CREATING)
on_node_created(node, ninfo);
}
}
@ -267,8 +258,8 @@ core_global_removed(void *data, struct pw_global *global)
{
struct impl *impl = data;
if (global->type == impl->core->type.node) {
struct pw_node *node = global->object;
if (pw_global_get_type(global) == impl->t->node) {
struct pw_node *node = pw_global_get_object(global);
struct node_info *ninfo;
if ((ninfo = find_node_info(impl, node)))
@ -296,13 +287,14 @@ const struct pw_core_events core_events = {
*/
static bool module_init(struct pw_module *module, struct pw_properties *properties)
{
struct pw_core *core = module->core;
struct pw_core *core = pw_module_get_core(module);
struct impl *impl;
impl = calloc(1, sizeof(struct impl));
pw_log_debug("module %p: new", impl);
impl->core = core;
impl->t = pw_core_get_type(core);
impl->module = module;
impl->properties = properties;

View file

@ -25,7 +25,6 @@
#include "config.h"
#include "pipewire/interfaces.h"
#include "pipewire/private.h"
#include "pipewire/core.h"
#include "pipewire/module.h"
@ -53,8 +52,7 @@ static struct pw_node *create_node(void *_data,
no_mem:
pw_log_error("can't create node");
pw_core_resource_error(resource->client->core_resource,
resource->client->core_resource->id, SPA_RESULT_NO_MEMORY, "no memory");
pw_resource_error(resource, SPA_RESULT_NO_MEMORY, "no memory");
if (properties)
pw_properties_free(properties);
return NULL;
@ -67,7 +65,7 @@ static const struct pw_node_factory_implementation impl_factory = {
static bool module_init(struct pw_module *module, struct pw_properties *properties)
{
struct pw_core *core = module->core;
struct pw_core *core = pw_module_get_core(module);
struct pw_node_factory *factory;
struct factory_data *data;
@ -87,7 +85,7 @@ static bool module_init(struct pw_module *module, struct pw_properties *properti
pw_protocol_native_ext_client_node_init(core);
pw_node_factory_export(factory, NULL, module->global);
pw_node_factory_export(factory, NULL, pw_module_get_global(module));
return true;
}

View file

@ -94,7 +94,7 @@ struct proxy {
struct spa_loop *data_loop;
const struct spa_node_callbacks *callbacks;
void *user_data;
void *callbacks_data;
struct pw_resource *resource;
@ -116,6 +116,7 @@ struct impl {
struct pw_client_node this;
struct pw_core *core;
struct pw_type *t;
struct proxy proxy;
@ -161,7 +162,7 @@ static int spa_proxy_node_send_command(struct spa_node *node, const struct spa_c
{
struct proxy *this;
int res = SPA_RESULT_OK;
struct pw_core *core;
struct pw_type *t;
if (node == NULL || command == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
@ -171,9 +172,9 @@ static int spa_proxy_node_send_command(struct spa_node *node, const struct spa_c
if (this->resource == NULL)
return SPA_RESULT_OK;
core = this->impl->core;
t = this->impl->t;
if (SPA_COMMAND_TYPE(command) == core->type.command_node.ClockUpdate) {
if (SPA_COMMAND_TYPE(command) == t->command_node.ClockUpdate) {
pw_client_node_resource_node_command(this->resource, this->seq++, command);
} else {
/* send start */
@ -186,7 +187,7 @@ static int spa_proxy_node_send_command(struct spa_node *node, const struct spa_c
static int
spa_proxy_node_set_callbacks(struct spa_node *node,
const struct spa_node_callbacks *callbacks,
void *user_data)
void *data)
{
struct proxy *this;
@ -195,7 +196,7 @@ spa_proxy_node_set_callbacks(struct spa_node *node,
this = SPA_CONTAINER_OF(node, struct proxy, node);
this->callbacks = callbacks;
this->user_data = user_data;
this->callbacks_data = data;
return SPA_RESULT_OK;
}
@ -577,11 +578,14 @@ spa_proxy_node_port_use_buffers(struct spa_node *node,
size_t n_mem;
struct pw_client_node_buffer *mb;
struct spa_meta_shared *msh;
struct pw_type *t;
this = SPA_CONTAINER_OF(node, struct proxy, node);
impl = this->impl;
spa_log_info(this->log, "proxy %p: use buffers %p %u", this, buffers, n_buffers);
t = impl->t;
if (!CHECK_PORT(this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
@ -608,7 +612,7 @@ spa_proxy_node_port_use_buffers(struct spa_node *node,
for (i = 0; i < n_buffers; i++) {
struct proxy_buffer *b = &port->buffers[i];
msh = spa_buffer_find_meta(buffers[i], impl->core->type.meta.Shared);
msh = spa_buffer_find_meta(buffers[i], t->meta.Shared);
if (msh == NULL) {
spa_log_error(this->log, "missing shared metadata on buffer %d", i);
return SPA_RESULT_ERROR;
@ -628,7 +632,7 @@ spa_proxy_node_port_use_buffers(struct spa_node *node,
direction,
port_id,
mb[i].mem_id,
impl->core->type.data.MemFd,
t->data.MemFd,
msh->fd, msh->flags, msh->offset, msh->size);
for (j = 0; j < buffers[i]->n_metas; j++) {
@ -640,8 +644,8 @@ spa_proxy_node_port_use_buffers(struct spa_node *node,
memcpy(&b->buffer.datas[j], d, sizeof(struct spa_data));
if (d->type == impl->core->type.data.DmaBuf ||
d->type == impl->core->type.data.MemFd) {
if (d->type == t->data.DmaBuf ||
d->type == t->data.MemFd) {
pw_client_node_resource_add_mem(this->resource,
direction,
port_id,
@ -649,10 +653,10 @@ spa_proxy_node_port_use_buffers(struct spa_node *node,
d->type,
d->fd,
d->flags, d->mapoffset, d->maxsize);
b->buffer.datas[j].type = impl->core->type.data.Id;
b->buffer.datas[j].type = t->data.Id;
b->buffer.datas[j].data = SPA_UINT32_TO_PTR(n_mem);
n_mem++;
} else if (d->type == impl->core->type.data.MemPtr) {
} else if (d->type == t->data.MemPtr) {
b->buffer.datas[j].data = SPA_INT_TO_PTR(b->size);
b->size += d->maxsize;
} else {
@ -716,7 +720,7 @@ spa_proxy_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32
spa_log_trace(this->log, "reuse buffer %d", buffer_id);
{
struct pw_event_transport_reuse_buffer rb = PW_EVENT_TRANSPORT_REUSE_BUFFER_INIT
(impl->core->type.event_transport.ReuseBuffer, port_id, buffer_id);
(impl->t->event_transport.ReuseBuffer, port_id, buffer_id);
pw_transport_add_event(impl->transport, (struct spa_event *) &rb);
}
@ -763,7 +767,7 @@ static int spa_proxy_node_process_input(struct spa_node *node)
io->status = SPA_RESULT_NEED_BUFFER;
}
pw_transport_add_event(impl->transport,
&SPA_EVENT_INIT(impl->core->type.event_transport.ProcessInput));
&SPA_EVENT_INIT(impl->t->event_transport.ProcessInput));
do_flush(this);
if (this->callbacks->need_input)
@ -797,7 +801,7 @@ static int spa_proxy_node_process_output(struct spa_node *node)
pw_log_trace("%d %d %d", io->status, io->buffer_id, io->status);
}
pw_transport_add_event(impl->transport,
&SPA_EVENT_INIT(impl->core->type.event_transport.ProcessOutput));
&SPA_EVENT_INIT(impl->t->event_transport.ProcessOutput));
do_flush(this);
return res;
@ -808,7 +812,7 @@ static int handle_node_event(struct proxy *this, struct spa_event *event)
struct impl *impl = SPA_CONTAINER_OF(this, struct impl, proxy);
int i;
if (SPA_EVENT_TYPE(event) == impl->core->type.event_transport.HaveOutput) {
if (SPA_EVENT_TYPE(event) == impl->t->event_transport.HaveOutput) {
for (i = 0; i < MAX_OUTPUTS; i++) {
struct spa_port_io *io = this->out_ports[i].io;
@ -818,14 +822,14 @@ static int handle_node_event(struct proxy *this, struct spa_event *event)
*io = impl->transport->outputs[i];
pw_log_trace("%d %d", io->status, io->buffer_id);
}
this->callbacks->have_output(&this->node, this->user_data);
} else if (SPA_EVENT_TYPE(event) == impl->core->type.event_transport.NeedInput) {
this->callbacks->need_input(&this->node, this->user_data);
} else if (SPA_EVENT_TYPE(event) == impl->core->type.event_transport.ReuseBuffer) {
this->callbacks->have_output(this->callbacks_data);
} else if (SPA_EVENT_TYPE(event) == impl->t->event_transport.NeedInput) {
this->callbacks->need_input(this->callbacks_data);
} else if (SPA_EVENT_TYPE(event) == impl->t->event_transport.ReuseBuffer) {
struct pw_event_transport_reuse_buffer *p =
(struct pw_event_transport_reuse_buffer *) event;
this->callbacks->reuse_buffer(&this->node, p->body.port_id.value,
p->body.buffer_id.value, this->user_data);
this->callbacks->reuse_buffer(this->callbacks_data, p->body.port_id.value,
p->body.buffer_id.value);
}
return SPA_RESULT_OK;
}
@ -836,7 +840,7 @@ client_node_done(void *data, int seq, int res)
struct impl *impl = data;
struct proxy *this = &impl->proxy;
this->callbacks->done(&this->node, seq, res, this->user_data);
this->callbacks->done(this->callbacks_data, seq, res);
}
@ -895,7 +899,7 @@ static void client_node_event(void *data, struct spa_event *event)
{
struct impl *impl = data;
struct proxy *this = &impl->proxy;
this->callbacks->event(&this->node, event, this->user_data);
this->callbacks->event(this->callbacks_data, event);
}
static void client_node_destroy(void *data)
@ -1033,18 +1037,19 @@ static void node_initialized(void *data)
struct pw_node *node = this->node;
struct pw_transport_info info;
int readfd, writefd;
const struct pw_node_info *i = pw_node_get_info(node);
if (this->resource == NULL)
return;
impl->transport = pw_transport_new(node->info.max_input_ports, node->info.max_output_ports, 0);
impl->transport->area->n_input_ports = node->info.n_input_ports;
impl->transport->area->n_output_ports = node->info.n_output_ports;
impl->transport = pw_transport_new(i->max_input_ports, i->max_output_ports, 0);
impl->transport->area->n_input_ports = i->n_input_ports;
impl->transport->area->n_output_ports = i->n_output_ports;
client_node_get_fds(this, &readfd, &writefd);
pw_transport_get_info(impl->transport, &info);
pw_client_node_resource_transport(this->resource, node->global->id,
pw_client_node_resource_transport(this->resource, pw_global_get_id(pw_node_get_global(node)),
readfd, writefd, info.memfd, info.offset, info.size);
}
@ -1136,6 +1141,7 @@ struct pw_client_node *pw_client_node_new(struct pw_resource *resource,
this = &impl->this;
impl->core = core;
impl->t = pw_core_get_type(core);
impl->fds[0] = impl->fds[1] = -1;
pw_log_debug("client-node %p: new", impl);

View file

@ -54,6 +54,7 @@ struct client_info {
struct spa_list link;
struct pw_client *client;
bool is_sandboxed;
bool in_override;
const struct pw_core_proxy_methods *old_methods;
struct pw_core_proxy_methods core_methods;
struct spa_list async_pending;
@ -438,9 +439,20 @@ static void client_resource_impl(void *data, struct pw_resource *resource)
struct pw_client *client = cinfo->client;
if (resource->type == client->core->type.core) {
cinfo->old_methods = resource->implementation;
struct pw_listener *impl = pw_resource_get_implementation(resource);
if (cinfo->in_override)
return;
cinfo->old_methods = impl->events;
cinfo->core_methods = *cinfo->old_methods;
resource->implementation = &cinfo->core_methods;
cinfo->in_override = true;
pw_resource_set_implementation(resource,
&cinfo->core_methods,
impl->data);
cinfo->in_override = false;
resource->access_private = cinfo;
cinfo->core_methods.create_node = do_create_node;
cinfo->core_methods.create_link = do_create_link;

View file

@ -35,7 +35,6 @@
#include "config.h"
#include "pipewire/pipewire.h"
#include "pipewire/private.h"
#include "pipewire/log.h"
#include "pipewire/interfaces.h"
@ -79,6 +78,7 @@ struct socket {
struct impl {
struct pw_core *core;
struct pw_type *t;
struct pw_module *module;
struct spa_list link;
@ -107,7 +107,7 @@ static void client_destroy(void *data)
{
struct client *this = data;
pw_loop_destroy_source(this->impl->core->main_loop, this->source);
pw_loop_destroy_source(pw_core_get_main_loop(this->impl->core), this->source);
spa_list_remove(&this->link);
close(this->fd);
@ -224,6 +224,7 @@ handle_client_open(struct client *client)
char name[JACK_CLIENT_NAME_SIZE+1];
int result, ref_num, shared_engine, shared_client, shared_graph;
struct jack_client *jc;
const struct ucred *ucred;
CheckSize(kClientOpen_size);
CheckRead(&PID, sizeof(int));
@ -250,7 +251,9 @@ handle_client_open(struct client *client)
goto reply;
}
jc->control = jack_client_control_alloc(name, client->client->ucred.pid, ref_num, -1);
ucred = pw_client_get_ucred(client->client);
jc->control = jack_client_control_alloc(name, ucred ? ucred->pid : 0, ref_num, -1);
if (jc->control == NULL) {
result = -1;
goto reply;
@ -407,7 +410,7 @@ client_busy_changed(void *data, bool busy)
if (!busy)
mask |= SPA_IO_IN;
pw_loop_update_io(c->impl->core->main_loop, c->source, mask);
pw_loop_update_io(pw_core_get_main_loop(c->impl->core), c->source, mask);
if (!busy)
process_messages(c);
@ -450,14 +453,15 @@ static struct client *client_new(struct impl *impl, int fd)
ucredp = &ucred;
}
client = pw_client_new(impl->core, impl->module->global, ucredp, NULL, sizeof(struct client));
client = pw_client_new(impl->core, pw_module_get_global(impl->module),
ucredp, NULL, sizeof(struct client));
if (client == NULL)
goto no_client;
this = client->user_data;
this = pw_client_get_user_data(client);
this->impl = impl;
this->fd = fd;
this->source = pw_loop_add_io(impl->core->main_loop,
this->source = pw_loop_add_io(pw_core_get_main_loop(impl->core),
this->fd,
SPA_IO_ERR | SPA_IO_HUP, false, connection_data, this);
if (this->source == NULL)
@ -526,28 +530,35 @@ make_int_client(struct impl *impl, struct pw_node *node)
return 0;
}
static bool on_global(void *data, struct pw_global *global)
{
struct impl *impl = data;
struct pw_node *node;
struct pw_properties *properties;
const char *str;
if (pw_global_get_type(global) != impl->t->node)
return true;
node = pw_global_get_object(global);
properties = pw_node_get_properties(node);
if ((str = pw_properties_get(properties, "media.class")) == NULL)
return true;
if (strcmp(str, "Audio/Sink") != 0)
return true;
make_int_client(impl, node);
return true;
}
static bool init_nodes(struct impl *impl)
{
struct pw_core *core = impl->core;
struct pw_node *n;
spa_list_for_each(n, &core->node_list, link) {
const char *str;
if (n->global == NULL)
continue;
if (n->properties == NULL)
continue;
if ((str = pw_properties_get(n->properties, "media.class")) == NULL)
continue;
if (strcmp(str, "Audio/Sink") != 0)
continue;
make_int_client(impl, n);
}
pw_core_for_each_global(core, on_global, impl);
return true;
}
@ -626,7 +637,7 @@ socket_data(struct spa_loop_utils *utils,
return;
}
pw_loop_update_io(impl->core->main_loop,
pw_loop_update_io(pw_core_get_main_loop(impl->core),
client->source, SPA_IO_IN | SPA_IO_ERR | SPA_IO_HUP);
}
@ -648,7 +659,7 @@ static bool add_socket(struct impl *impl, struct socket *s)
return false;
}
s->loop = impl->core->main_loop;
s->loop = pw_core_get_main_loop(impl->core);
s->source = pw_loop_add_io(s->loop, s->fd, SPA_IO_IN, false, socket_data, impl);
if (s->source == NULL)
return false;
@ -701,7 +712,7 @@ static int init_server(struct impl *impl, const char *name, bool promiscuous)
static struct impl *module_init(struct pw_module *module, struct pw_properties *properties)
{
struct pw_core *core = module->core;
struct pw_core *core = pw_module_get_core(module);
struct impl *impl;
const char *name, *str;
bool promiscuous;
@ -710,6 +721,7 @@ static struct impl *module_init(struct pw_module *module, struct pw_properties *
pw_log_debug("protocol-jack %p: new", impl);
impl->core = core;
impl->t = pw_core_get_type(core);
impl->module = module;
impl->properties = properties;

View file

@ -25,7 +25,6 @@
#include "config.h"
#include "pipewire/core.h"
#include "pipewire/private.h"
#include "pipewire/module.h"
#include "modules/spa/spa-node.h"
@ -33,6 +32,7 @@
struct impl {
struct pw_core *core;
struct pw_type *t;
struct pw_module *module;
struct pw_properties *properties;
@ -92,26 +92,30 @@ static struct pw_node *make_node(struct impl *impl)
struct spa_node *spa_node;
struct spa_clock *spa_clock;
struct pw_node *node;
const struct spa_support *support;
uint32_t n_support;
support = pw_core_get_support(impl->core, &n_support);
handle = calloc(1, impl->factory->size);
if ((res = spa_handle_factory_init(impl->factory,
handle,
NULL, impl->core->support, impl->core->n_support)) < 0) {
NULL, support, n_support)) < 0) {
pw_log_error("can't make factory instance: %d", res);
goto init_failed;
}
if ((res = spa_handle_get_interface(handle, impl->core->type.spa_node, &iface)) < 0) {
if ((res = spa_handle_get_interface(handle, impl->t->spa_node, &iface)) < 0) {
pw_log_error("can't get interface %d", res);
goto interface_failed;
}
spa_node = iface;
if ((res = spa_handle_get_interface(handle, impl->core->type.spa_clock, &iface)) < 0) {
if ((res = spa_handle_get_interface(handle, impl->t->spa_clock, &iface)) < 0) {
iface = NULL;
}
spa_clock = iface;
node = pw_spa_node_new(impl->core, NULL, impl->module->global,
node = pw_spa_node_new(impl->core, NULL, pw_module_get_global(impl->module),
"audiomixer", false, spa_node, spa_clock, NULL);
return node;
@ -123,53 +127,60 @@ static struct pw_node *make_node(struct impl *impl)
return NULL;
}
static bool on_global(void *data, struct pw_global *global)
{
struct impl *impl = data;
struct pw_node *n, *node;
struct pw_properties *properties;
const char *str;
char *error;
struct pw_port *ip, *op;
struct pw_link *link;
if (pw_global_get_type(global) != impl->t->node)
return true;
n = pw_global_get_object(global);
properties = pw_node_get_properties(n);
if ((str = pw_properties_get(properties, "media.class")) == NULL)
return true;
if (strcmp(str, "Audio/Sink") != 0)
return true;
if ((ip = pw_node_get_free_port(n, PW_DIRECTION_INPUT)) == NULL)
return true;
node = make_node(impl);
op = pw_node_get_free_port(node, PW_DIRECTION_OUTPUT);
if (op == NULL)
return true;
link = pw_link_new(impl->core, pw_module_get_global(impl->module), op, ip, NULL, NULL, &error);
pw_link_inc_idle(link);
return true;
}
static bool module_init(struct pw_module *module, struct pw_properties *properties)
{
struct pw_core *core = module->core;
struct pw_core *core = pw_module_get_core(module);
struct impl *impl;
struct pw_node *n;
impl = calloc(1, sizeof(struct impl));
pw_log_debug("module %p: new", impl);
impl->core = core;
impl->t = pw_core_get_type(core);
impl->module = module;
impl->properties = properties;
impl->factory = find_factory(impl);
spa_list_for_each(n, &core->node_list, link) {
const char *str;
char *error;
struct pw_node *node;
struct pw_port *ip, *op;
pw_core_for_each_global(core, on_global, impl);
if (n->global == NULL)
continue;
if (n->properties == NULL)
continue;
if ((str = pw_properties_get(n->properties, "media.class")) == NULL)
continue;
if (strcmp(str, "Audio/Sink") != 0)
continue;
if ((ip = pw_node_get_free_port(n, PW_DIRECTION_INPUT)) == NULL)
continue;
node = make_node(impl);
op = pw_node_get_free_port(node, PW_DIRECTION_OUTPUT);
if (op == NULL)
continue;
n->idle_used_input_links++;
node->idle_used_output_links++;
pw_link_new(core, module->global, op, ip, NULL, NULL, &error);
}
return impl;
return true;
}
#if 0

View file

@ -23,7 +23,6 @@
#include "spa/pod-iter.h"
#include "pipewire/pipewire.h"
#include "pipewire/private.h"
#include "pipewire/protocol.h"
#include "pipewire/interfaces.h"
#include "pipewire/resource.h"

View file

@ -25,7 +25,6 @@
#include "config.h"
#include "pipewire/interfaces.h"
#include "pipewire/private.h"
#include "pipewire/core.h"
#include "pipewire/module.h"
@ -70,17 +69,13 @@ static struct pw_node *create_node(void *_data,
no_properties:
pw_log_error("missing properties");
if (resource) {
pw_core_resource_error(resource->client->core_resource,
resource->client->core_resource->id,
SPA_RESULT_INVALID_ARGUMENTS, "missing properties");
pw_resource_error(resource, SPA_RESULT_INVALID_ARGUMENTS, "missing properties");
}
return NULL;
no_mem:
pw_log_error("can't create node");
if (resource) {
pw_core_resource_error(resource->client->core_resource,
resource->client->core_resource->id,
SPA_RESULT_NO_MEMORY, "no memory");
pw_resource_error(resource, SPA_RESULT_NO_MEMORY, "no memory");
}
return NULL;
}
@ -92,7 +87,7 @@ static const struct pw_node_factory_implementation impl_factory = {
static bool module_init(struct pw_module *module, struct pw_properties *properties)
{
struct pw_core *core = module->core;
struct pw_core *core = pw_module_get_core(module);
struct pw_node_factory *factory;
struct factory_data *data;
@ -110,7 +105,7 @@ static bool module_init(struct pw_module *module, struct pw_properties *properti
&impl_factory,
data);
pw_node_factory_export(factory, NULL, module->global);
pw_node_factory_export(factory, NULL, pw_module_get_global(module));
return true;
}

View file

@ -162,9 +162,9 @@ static void remove_item(struct pw_spa_monitor *this, struct spa_monitor_item *it
destroy_item(mitem);
}
static void on_monitor_event(struct spa_monitor *monitor, struct spa_event *event, void *user_data)
static void on_monitor_event(void *data, struct spa_event *event)
{
struct impl *impl = user_data;
struct impl *impl = data;
struct pw_spa_monitor *this = &impl->this;
struct pw_type *t = pw_core_get_type(impl->core);
@ -213,7 +213,7 @@ static void update_monitor(struct pw_core *core, const char *name)
static const struct spa_monitor_callbacks callbacks = {
SPA_VERSION_MONITOR_CALLBACKS,
on_monitor_event,
.event = on_monitor_event,
};
struct pw_spa_monitor *pw_spa_monitor_load(struct pw_core *core,

View file

@ -326,9 +326,9 @@ static void complete_init(struct impl *impl)
pw_node_register(this);
}
static void on_node_done(struct spa_node *node, int seq, int res, void *user_data)
static void on_node_done(void *data, int seq, int res)
{
struct impl *impl = user_data;
struct impl *impl = data;
struct pw_node *this = impl->this;
if (impl->async_init) {
@ -340,32 +340,32 @@ static void on_node_done(struct spa_node *node, int seq, int res, void *user_dat
pw_listener_list_emit(&this->listener_list, struct pw_node_events, async_complete, seq, res);
}
static void on_node_event(struct spa_node *node, struct spa_event *event, void *user_data)
static void on_node_event(void *data, struct spa_event *event)
{
struct impl *impl = user_data;
struct impl *impl = data;
struct pw_node *this = impl->this;
pw_listener_list_emit(&this->listener_list, struct pw_node_events, event, event);
}
static void on_node_need_input(struct spa_node *node, void *user_data)
static void on_node_need_input(void *data)
{
struct impl *impl = user_data;
struct impl *impl = data;
struct pw_node *this = impl->this;
pw_listener_list_emit_na(&this->listener_list, struct pw_node_events, need_input);
}
static void on_node_have_output(struct spa_node *node, void *user_data)
static void on_node_have_output(void *data)
{
struct impl *impl = user_data;
struct impl *impl = data;
struct pw_node *this = impl->this;
pw_listener_list_emit_na(&this->listener_list, struct pw_node_events, have_output);
}
static void
on_node_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id, void *user_data)
on_node_reuse_buffer(void *data, uint32_t port_id, uint32_t buffer_id)
{
struct impl *impl = user_data;
struct impl *impl = data;
struct pw_node *this = impl->this;
struct spa_graph_port *p, *pp;
@ -374,8 +374,8 @@ on_node_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id
continue;
pp = p->peer;
if (pp && pp->methods->reuse_buffer)
pp->methods->reuse_buffer(pp, buffer_id, pp->user_data);
if (pp && pp->callbacks->reuse_buffer)
pp->callbacks->reuse_buffer(pp->callbacks_data, buffer_id);
break;
}

View file

@ -130,6 +130,29 @@ struct pw_client *pw_client_new(struct pw_core *core,
return this;
}
struct pw_core *pw_client_get_core(struct pw_client *client)
{
return client->core;
}
struct pw_global *pw_client_get_global(struct pw_client *client)
{
return client->global;
}
const struct pw_properties *pw_client_get_properties(struct pw_client *client)
{
return client->properties;
}
const struct ucred *pw_client_get_ucred(struct pw_client *client)
{
if (!client->ucred_valid)
return NULL;
return &client->ucred;
}
void *pw_client_get_user_data(struct pw_client *client)
{
return client->user_data;

View file

@ -109,6 +109,14 @@ pw_client_new(struct pw_core *core,
void pw_client_destroy(struct pw_client *client);
struct pw_core *pw_client_get_core(struct pw_client *client);
struct pw_global *pw_client_get_global(struct pw_client *client);
const struct pw_properties *pw_client_get_properties(struct pw_client *client);
const struct ucred *pw_client_get_ucred(struct pw_client *client);
void *pw_client_get_user_data(struct pw_client *client);
void pw_client_add_listener(struct pw_client *client,

View file

@ -500,6 +500,16 @@ pw_core_add_global(struct pw_core *core,
return this;
}
struct pw_core *pw_global_get_core(struct pw_global *global)
{
return global->core;
}
const struct pw_core_info *pw_core_get_info(struct pw_core *core)
{
return &core->info;
}
uint32_t pw_global_get_type(struct pw_global *global)
{
return global->type;
@ -515,6 +525,11 @@ void * pw_global_get_object(struct pw_global *global)
return global->object;
}
uint32_t pw_global_get_id(struct pw_global *global)
{
return global->id;
}
/** Bind to a global
*
* \param global the global to bind to
@ -651,6 +666,23 @@ void pw_core_update_properties(struct pw_core *core, const struct spa_dict *dict
core->info.change_mask = 0;
}
bool pw_core_for_each_global(struct pw_core *core,
bool (*callback) (void *data, struct pw_global *global),
void *data)
{
struct pw_global *g, *t;
spa_list_for_each_safe(g, t, &core->global_list, link)
if (!callback(data, g))
return false;
return true;
}
struct pw_global *pw_core_find_global(struct pw_core *core, uint32_t id)
{
return pw_map_lookup(&core->globals, id);
}
/** Find a port to link with
*
* \param core a core

View file

@ -164,6 +164,8 @@ void pw_core_add_listener(struct pw_core *core,
struct pw_type *pw_core_get_type(struct pw_core *core);
const struct pw_core_info *pw_core_get_info(struct pw_core *core);
const struct spa_dict *pw_core_get_properties(struct pw_core *core);
const struct spa_support *pw_core_get_support(struct pw_core *core, uint32_t *n_support);
@ -172,6 +174,11 @@ struct pw_loop *pw_core_get_main_loop(struct pw_core *core);
void pw_core_update_properties(struct pw_core *core, const struct spa_dict *dict);
/** iterate the globals */
bool pw_core_for_each_global(struct pw_core *core,
bool (*callback) (void *data, struct pw_global *global),
void *data);
struct pw_global *
pw_core_add_global(struct pw_core *core,
struct pw_client *owner,
@ -181,15 +188,22 @@ pw_core_add_global(struct pw_core *core,
pw_bind_func_t bind,
void *object);
struct pw_client * pw_global_get_owner(struct pw_global *global);
struct pw_global *pw_core_find_global(struct pw_core *core, uint32_t id);
struct pw_global * pw_global_get_parent(struct pw_global *global);
struct pw_core *pw_global_get_core(struct pw_global *global);
struct pw_client *pw_global_get_owner(struct pw_global *global);
struct pw_global *pw_global_get_parent(struct pw_global *global);
uint32_t pw_global_get_type(struct pw_global *global);
uint32_t pw_global_get_version(struct pw_global *global);
void * pw_global_get_object(struct pw_global *global);
void *pw_global_get_object(struct pw_global *global);
uint32_t pw_global_get_id(struct pw_global *global);
int
pw_global_bind(struct pw_global *global,

View file

@ -1170,3 +1170,34 @@ struct pw_link *pw_link_find(struct pw_port *output_port, struct pw_port *input_
}
return NULL;
}
struct pw_core *pw_link_get_core(struct pw_link *link)
{
return link->core;
}
const struct pw_link_info *pw_link_get_info(struct pw_link *link)
{
return &link->info;
}
struct pw_global *pw_link_get_global(struct pw_link *link)
{
return link->global;
}
struct pw_port *pw_link_get_output(struct pw_link *link)
{
return link->output;
}
struct pw_port *pw_link_get_input(struct pw_link *link)
{
return link->input;
}
void pw_link_inc_idle(struct pw_link *link)
{
link->input->node->idle_used_input_links++;
link->output->node->idle_used_output_links++;
}

View file

@ -87,8 +87,24 @@ void pw_link_add_listener(struct pw_link *link,
const struct pw_link_events *events,
void *data);
struct pw_core *pw_link_get_core(struct pw_link *link);
const struct pw_link_info *pw_link_get_info(struct pw_link *link);
/** Get the global of the link */
struct pw_global *pw_link_get_global(struct pw_link *link);
/** Get the output port of the link */
struct pw_port *pw_link_get_output(struct pw_link *link);
/** Get the input port of the link */
struct pw_port *pw_link_get_input(struct pw_link *link);
/** Find the link between 2 ports \memberof pw_link */
struct pw_link * pw_link_find(struct pw_port *output, struct pw_port *input);
struct pw_link *pw_link_find(struct pw_port *output, struct pw_port *input);
void pw_link_inc_idle(struct pw_link *link);
/** Activate a link \memberof pw_link
* Starts the negotiation of formats and buffers on \a link and then

View file

@ -65,8 +65,7 @@ struct pw_core * pw_module_get_core(struct pw_module *module);
struct pw_global * pw_module_get_global(struct pw_module *module);
const struct pw_module_info *
pw_module_get_info(struct pw_module *module);
const struct pw_module_info *pw_module_get_info(struct pw_module *module);
void pw_module_add_listener(struct pw_module *module,
struct pw_listener *listener,

View file

@ -321,9 +321,9 @@ void pw_node_register(struct pw_node *this)
}
static int
graph_impl_process_input(struct spa_graph_node *node, void *user_data)
graph_impl_process_input(void *data)
{
struct pw_node *this = user_data;
struct pw_node *this = data;
int res;
if (this->implementation->process_input)
res = this->implementation->process_input(this->implementation_data);
@ -333,9 +333,9 @@ graph_impl_process_input(struct spa_graph_node *node, void *user_data)
}
static int
graph_impl_process_output(struct spa_graph_node *node, void *user_data)
graph_impl_process_output(void *data)
{
struct pw_node *this = user_data;
struct pw_node *this = data;
int res;
if (this->implementation->process_output)
res = this->implementation->process_output(this->implementation_data);
@ -344,8 +344,8 @@ graph_impl_process_output(struct spa_graph_node *node, void *user_data)
return res;
}
static const struct spa_graph_node_methods graph_methods = {
SPA_VERSION_GRAPH_NODE_METHODS,
static const struct spa_graph_node_callbacks graph_callbacks = {
SPA_VERSION_GRAPH_NODE_CALLBACKS,
.process_input = graph_impl_process_input,
.process_output = graph_impl_process_output,
};
@ -409,9 +409,9 @@ struct pw_node *pw_node_new(struct pw_core *core,
pw_map_init(&this->output_port_map, 64, 64);
spa_graph_node_init(&this->rt.node);
spa_graph_node_set_methods(&this->rt.node,
&graph_methods,
this);
spa_graph_node_set_callbacks(&this->rt.node,
&graph_callbacks,
this);
return this;
@ -420,6 +420,11 @@ struct pw_node *pw_node_new(struct pw_core *core,
return NULL;
}
const struct pw_node_info *pw_node_get_info(struct pw_node *node)
{
return &node->info;
}
void * pw_node_get_user_data(struct pw_node *node)
{
return node->user_data;
@ -430,6 +435,21 @@ struct pw_core * pw_node_get_core(struct pw_node *node)
return node->core;
}
struct pw_resource *pw_node_get_owner(struct pw_node *node)
{
return node->owner;
}
struct pw_global *pw_node_get_global(struct pw_node *node)
{
return node->global;
}
struct pw_properties *pw_node_get_properties(struct pw_node *node)
{
return node->properties;
}
void pw_node_set_implementation(struct pw_node *node,
const struct pw_node_implementation *implementation,
void *data)
@ -514,6 +534,25 @@ void pw_node_destroy(struct pw_node *node)
free(impl);
}
bool pw_node_for_each_port(struct pw_node *node,
enum pw_direction direction,
bool (*callback) (void *data, struct pw_port *port),
void *data)
{
struct spa_list *ports;
struct pw_port *p, *t;
if (direction == PW_DIRECTION_INPUT)
ports = &node->input_ports;
else
ports = &node->output_ports;
spa_list_for_each_safe(p, t, ports, link)
if (!callback(data, p))
return false;
return true;
}
struct pw_port *
pw_node_find_port(struct pw_node *node, enum pw_direction direction, uint32_t port_id)
{

View file

@ -127,9 +127,17 @@ void pw_node_register(struct pw_node *node);
/** Destroy a node */
void pw_node_destroy(struct pw_node *node);
const struct pw_node_info *pw_node_get_info(struct pw_node *node);
void * pw_node_get_user_data(struct pw_node *node);
struct pw_core * pw_node_get_core(struct pw_node *node);
struct pw_core *pw_node_get_core(struct pw_node *node);
struct pw_resource *pw_node_get_owner(struct pw_node *node);
struct pw_global *pw_node_get_global(struct pw_node *node);
struct pw_properties *pw_node_get_properties(struct pw_node *node);
void pw_node_set_implementation(struct pw_node *node,
const struct pw_node_implementation *implementation,
@ -140,6 +148,13 @@ void pw_node_add_listener(struct pw_node *node,
const struct pw_node_events *events,
void *data);
/** iterate the ports in the given direction */
bool pw_node_for_each_port(struct pw_node *node,
enum pw_direction direction,
bool (*callback) (void *data, struct pw_port *port),
void *data);
/** Find the port with direction and port_id or NULL when not found */
struct pw_port *
pw_node_find_port(struct pw_node *node, enum pw_direction direction, uint32_t port_id);

View file

@ -41,12 +41,13 @@ static void port_update_state(struct pw_port *port, enum pw_port_state state)
}
}
static int schedule_tee_input(struct spa_graph_node *node, void *user_data)
static int schedule_tee_input(void *data)
{
int res;
struct pw_port *this = user_data;
struct pw_port *this = data;
struct spa_graph_node *node = &this->rt.mix_node;
struct spa_graph_port *p;
struct spa_port_io *io = this->rt.mix_port.io;
int res;
if (spa_list_is_empty(&node->ports[SPA_DIRECTION_OUTPUT])) {
io->status = SPA_RESULT_NEED_BUFFER;
@ -62,9 +63,10 @@ static int schedule_tee_input(struct spa_graph_node *node, void *user_data)
}
return res;
}
static int schedule_tee_output(struct spa_graph_node *node, void *user_data)
static int schedule_tee_output(void *data)
{
struct pw_port *this = user_data;
struct pw_port *this = data;
struct spa_graph_node *node = &this->rt.mix_node;
struct spa_graph_port *p;
struct spa_port_io *io = this->rt.mix_port.io;
@ -75,25 +77,26 @@ static int schedule_tee_output(struct spa_graph_node *node, void *user_data)
return SPA_RESULT_NEED_BUFFER;
}
static const struct spa_graph_node_methods schedule_tee_node = {
SPA_VERSION_GRAPH_NODE_METHODS,
static const struct spa_graph_node_callbacks schedule_tee_node = {
SPA_VERSION_GRAPH_NODE_CALLBACKS,
schedule_tee_input,
schedule_tee_output,
};
static int schedule_tee_reuse_buffer(struct spa_graph_port *port, uint32_t buffer_id, void *user_data)
static int schedule_tee_reuse_buffer(void *data, uint32_t buffer_id)
{
return SPA_RESULT_OK;
}
static const struct spa_graph_port_methods schedule_tee_port = {
SPA_VERSION_GRAPH_PORT_METHODS,
static const struct spa_graph_port_callbacks schedule_tee_port = {
SPA_VERSION_GRAPH_PORT_CALLBACKS,
schedule_tee_reuse_buffer,
};
static int schedule_mix_input(struct spa_graph_node *node, void *user_data)
static int schedule_mix_input(void *data)
{
struct pw_port *this = user_data;
struct pw_port *this = data;
struct spa_graph_node *node = &this->rt.mix_node;
struct spa_graph_port *p;
struct spa_port_io *io = this->rt.mix_port.io;
@ -106,9 +109,10 @@ static int schedule_mix_input(struct spa_graph_node *node, void *user_data)
return SPA_RESULT_HAVE_BUFFER;
}
static int schedule_mix_output(struct spa_graph_node *node, void *user_data)
static int schedule_mix_output(void *data)
{
struct pw_port *this = user_data;
struct pw_port *this = data;
struct spa_graph_node *node = &this->rt.mix_node;
struct spa_graph_port *p;
struct spa_port_io *io = this->rt.mix_port.io;
@ -120,18 +124,18 @@ static int schedule_mix_output(struct spa_graph_node *node, void *user_data)
return SPA_RESULT_NEED_BUFFER;
}
static const struct spa_graph_node_methods schedule_mix_node = {
SPA_VERSION_GRAPH_NODE_METHODS,
static const struct spa_graph_node_callbacks schedule_mix_node = {
SPA_VERSION_GRAPH_NODE_CALLBACKS,
schedule_mix_input,
schedule_mix_output,
};
static int schedule_mix_reuse_buffer(struct spa_graph_port *port, uint32_t buffer_id, void *user_data)
static int schedule_mix_reuse_buffer(void *data, uint32_t buffer_id)
{
return SPA_RESULT_OK;
}
static const struct spa_graph_port_methods schedule_mix_port = {
SPA_VERSION_GRAPH_PORT_METHODS,
static const struct spa_graph_port_callbacks schedule_mix_port = {
SPA_VERSION_GRAPH_PORT_CALLBACKS,
schedule_mix_reuse_buffer,
};
@ -168,24 +172,39 @@ struct pw_port *pw_port_new(enum pw_direction direction,
0,
&this->io);
spa_graph_node_init(&this->rt.mix_node);
spa_graph_node_set_methods(&this->rt.mix_node,
this->direction == PW_DIRECTION_INPUT ?
spa_graph_node_set_callbacks(&this->rt.mix_node,
this->direction == PW_DIRECTION_INPUT ?
&schedule_mix_node :
&schedule_tee_node,
this);
this);
spa_graph_port_init(&this->rt.mix_port,
pw_direction_reverse(this->direction),
0,
0,
&this->io);
spa_graph_port_set_methods(&this->rt.mix_port,
this->direction == PW_DIRECTION_INPUT ?
spa_graph_port_set_callbacks(&this->rt.mix_port,
this->direction == PW_DIRECTION_INPUT ?
&schedule_mix_port :
&schedule_tee_port,
this);
this);
return this;
}
enum pw_direction pw_port_get_direction(struct pw_port *port)
{
return port->direction;
}
uint32_t pw_port_get_id(struct pw_port *port)
{
return port->port_id;
}
struct pw_node *pw_port_get_node(struct pw_port *port)
{
return port->node;
}
void pw_port_set_implementation(struct pw_port *port,
const struct pw_port_implementation *implementation,
void *data)

View file

@ -105,6 +105,15 @@ pw_port_new(enum pw_direction direction,
uint32_t port_id,
size_t user_data_size);
/** Get the port direction */
enum pw_direction pw_port_get_direction(struct pw_port *port);
/** Get the port id */
uint32_t pw_port_get_id(struct pw_port *port);
/** Get the port parent node or NULL when not yet set */
struct pw_node *pw_port_get_node(struct pw_port *port);
/** Add a port to a node \memberof pw_port */
void pw_port_add(struct pw_port *port, struct pw_node *node);

View file

@ -59,7 +59,6 @@ struct pw_client {
struct pw_protocol *protocol; /**< protocol in use */
struct spa_list protocol_link; /**< link in the protocol client_list */
void *protocol_private; /**< private data for the protocol */
void *user_data; /**< extra user data */
};
@ -104,6 +103,7 @@ struct pw_core {
struct spa_list node_list; /**< list of nodes */
struct spa_list node_factory_list; /**< list of node factories */
struct spa_list link_list; /**< list of links */
struct pw_listener_list listener_list;
struct pw_loop *main_loop; /**< main loop for control */
@ -269,8 +269,7 @@ struct pw_resource {
uint32_t type; /**< type of the client interface */
uint32_t version; /**< version of the client interface */
const void *implementation;
void *implementation_data;
struct pw_listener implementation;
struct pw_listener_list listener_list;

View file

@ -49,7 +49,7 @@ static void clear_item(struct spa_dict_item *item)
free((char *) item->value);
}
static int find_index(struct pw_properties *this, const char *key)
static int find_index(const struct pw_properties *this, const char *key)
{
struct properties *impl = SPA_CONTAINER_OF(this, struct properties, this);
int i, len = pw_array_get_len(&impl->items, struct spa_dict_item);
@ -125,7 +125,7 @@ struct pw_properties *pw_properties_new_dict(const struct spa_dict *dict)
*
* \memberof pw_properties
*/
struct pw_properties *pw_properties_copy(struct pw_properties *properties)
struct pw_properties *pw_properties_copy(const struct pw_properties *properties)
{
struct properties *impl = SPA_CONTAINER_OF(properties, struct properties, this);
struct pw_properties *copy;
@ -152,7 +152,7 @@ struct pw_properties *pw_properties_copy(struct pw_properties *properties)
*
* \memberof pw_properties
*/
struct pw_properties *pw_properties_merge(struct pw_properties *oldprops,
struct pw_properties *pw_properties_merge(const struct pw_properties *oldprops,
struct pw_properties *newprops)
{
struct pw_properties *res = NULL;
@ -277,7 +277,7 @@ void pw_properties_setf(struct pw_properties *properties, const char *key, const
*
* \memberof pw_properties
*/
const char *pw_properties_get(struct pw_properties *properties, const char *key)
const char *pw_properties_get(const struct pw_properties *properties, const char *key)
{
struct properties *impl = SPA_CONTAINER_OF(properties, struct properties, this);
int index = find_index(properties, key);
@ -301,7 +301,7 @@ const char *pw_properties_get(struct pw_properties *properties, const char *key)
*
* \memberof pw_properties
*/
const char *pw_properties_iterate(struct pw_properties *properties, void **state)
const char *pw_properties_iterate(const struct pw_properties *properties, void **state)
{
struct properties *impl = SPA_CONTAINER_OF(properties, struct properties, this);
uint32_t index;

View file

@ -46,10 +46,10 @@ struct pw_properties *
pw_properties_new_dict(const struct spa_dict *dict);
struct pw_properties *
pw_properties_copy(struct pw_properties *properties);
pw_properties_copy(const struct pw_properties *properties);
struct pw_properties *
pw_properties_merge(struct pw_properties *oldprops,
pw_properties_merge(const struct pw_properties *oldprops,
struct pw_properties *newprops);
void
@ -62,10 +62,10 @@ void
pw_properties_setf(struct pw_properties *properties,
const char *key, const char *format, ...) SPA_PRINTF_FUNC(3, 4);
const char *
pw_properties_get(struct pw_properties *properties, const char *key);
pw_properties_get(const struct pw_properties *properties, const char *key);
const char *
pw_properties_iterate(struct pw_properties *properties, void **state);
pw_properties_iterate(const struct pw_properties *properties, void **state);
#ifdef __cplusplus
}

View file

@ -85,6 +85,11 @@ uint32_t pw_proxy_get_id(struct pw_proxy *proxy)
return proxy->id;
}
struct pw_protocol *pw_proxy_get_protocol(struct pw_proxy *proxy)
{
return proxy->remote->conn->protocol;
}
void pw_proxy_add_listener(struct pw_proxy *proxy,
struct pw_listener *listener,
const struct pw_proxy_events *events,

View file

@ -121,6 +121,8 @@ void *pw_proxy_get_user_data(struct pw_proxy *proxy);
uint32_t pw_proxy_get_id(struct pw_proxy *proxy);
struct pw_protocol *pw_proxy_get_protocol(struct pw_proxy *proxy);
struct pw_listener_list *pw_proxy_get_proxy_listeners(struct pw_proxy *proxy);
const void *pw_proxy_get_proxy_implementation(struct pw_proxy *proxy);

View file

@ -423,7 +423,7 @@ static void handle_rtnode_event(struct pw_proxy *proxy, struct spa_event *event)
spa_graph_scheduler_chain(data->node->rt.sched, &ready);
}
else if (SPA_EVENT_TYPE(event) == remote->core->type.event_transport.ProcessOutput) {
n->methods->process_output(n, n->user_data);
n->callbacks->process_output(n->callbacks_data);
}
else if (SPA_EVENT_TYPE(event) == remote->core->type.event_transport.ReuseBuffer) {
}

View file

@ -76,6 +76,26 @@ struct pw_resource *pw_resource_new(struct pw_client *client,
return NULL;
}
struct pw_client *pw_resource_get_client(struct pw_resource *resource)
{
return resource->client;
}
uint32_t pw_resource_get_id(struct pw_resource *resource)
{
return resource->id;
}
uint32_t pw_resource_get_permissions(struct pw_resource *resource)
{
return resource->permissions;
}
struct pw_protocol *pw_resource_get_protocol(struct pw_resource *resource)
{
return resource->client->protocol;
}
void *pw_resource_get_user_data(struct pw_resource *resource)
{
return resource->user_data;
@ -94,11 +114,29 @@ void pw_resource_set_implementation(struct pw_resource *resource,
void *data)
{
struct pw_client *client = resource->client;
resource->implementation = implementation;
resource->implementation_data = data;
resource->implementation.events = implementation;
resource->implementation.data = data;
pw_listener_list_emit(&client->listener_list, struct pw_client_events, resource_impl, resource);
}
struct pw_listener *pw_resource_get_implementation(struct pw_resource *resource)
{
return &resource->implementation;
}
const void *pw_resource_get_proxy_notify(struct pw_resource *resource)
{
return resource->marshal->event_marshal;
}
void pw_resource_error(struct pw_resource *resource, int result, const char *error)
{
if (resource->client->core_resource)
pw_core_resource_error(resource->client->core_resource, resource->id, result, error);
}
void pw_resource_destroy(struct pw_resource *resource)
{
struct pw_client *client = resource->client;

View file

@ -76,6 +76,16 @@ pw_resource_new(struct pw_client *client, /**< the client owning the resource */
uint32_t version, /**< requested interface version */
size_t user_data_size /**< extra user data size */);
void pw_resource_destroy(struct pw_resource *resource);
struct pw_client *pw_resource_get_client(struct pw_resource *resource);
uint32_t pw_resource_get_id(struct pw_resource *resource);
uint32_t pw_resource_get_permissions(struct pw_resource *resource);
struct pw_protocol *pw_resource_get_protocol(struct pw_resource *resource);
void *pw_resource_get_user_data(struct pw_resource *resource);
void pw_resource_add_listener(struct pw_resource *resource,
@ -87,12 +97,27 @@ void pw_resource_set_implementation(struct pw_resource *resource,
const void *implementation,
void *data);
void
pw_resource_destroy(struct pw_resource *resource);
void pw_resource_error(struct pw_resource *resource, int result, const char *error);
#define pw_resource_do(r,type,method,...) ((type*) r->implementation)->method(r->implementation_data, __VA_ARGS__)
#define pw_resource_do_na(r,type,method) ((type*) r->implementation)->method(r->implementation_data)
#define pw_resource_notify(r,type,event,...) ((type*) r->marshal->event_marshal)->event(r, __VA_ARGS__)
struct pw_listener *pw_resource_get_implementation(struct pw_resource *resource);
const void *pw_resource_get_proxy_notify(struct pw_resource *resource);
#define pw_resource_do(r,type,method,...) ({ \
struct pw_listener *l = pw_resource_get_implementation(r); \
const type *cb = l->events; \
if (cb->method) \
cb->method(l->data, __VA_ARGS__); \
});
#define pw_resource_do_na(r,type,method) ({ \
struct pw_listener *l = pw_resource_get_implementation(r); \
const type *cb = l->events; \
if (cb->method) \
cb->method(l->data); \
});
#define pw_resource_notify(r,type,event,...) ((type*) pw_resource_get_proxy_notify(r))->event(r, __VA_ARGS__)
#define pw_resource_notify_na(r,type,event) ((type*) r->marshal->event_marshal)->event(r)
#ifdef __cplusplus

View file

@ -236,7 +236,12 @@ enum pw_stream_state pw_stream_get_state(struct pw_stream *stream, const char **
return stream->state;
}
struct pw_properties *pw_stream_get_properties(struct pw_stream *stream)
const char *pw_stream_get_name(struct pw_stream *stream)
{
return stream->name;
}
const struct pw_properties *pw_stream_get_properties(struct pw_stream *stream)
{
return stream->properties;
}

View file

@ -245,7 +245,9 @@ void pw_stream_add_listener(struct pw_stream *stream,
enum pw_stream_state pw_stream_get_state(struct pw_stream *stream, const char **error);
struct pw_properties *pw_stream_get_properties(struct pw_stream *stream);
const char *pw_stream_get_name(struct pw_stream *stream);
const struct pw_properties *pw_stream_get_properties(struct pw_stream *stream);
/** Connect a stream for input or output on \a port_path. \memberof pw_stream
* \return true on success.