mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
Add user_data to callbacks
Add user data to callbacks, it's more flexible and natural
This commit is contained in:
parent
59ec32c039
commit
763bd1100e
27 changed files with 156 additions and 165 deletions
|
|
@ -61,6 +61,7 @@ struct impl {
|
|||
struct spa_loop *main_loop;
|
||||
|
||||
const struct spa_monitor_callbacks *callbacks;
|
||||
void *user_data;
|
||||
|
||||
struct udev *udev;
|
||||
struct udev_monitor *umonitor;
|
||||
|
|
@ -230,12 +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->callbacks, &this->monitor, event);
|
||||
this->callbacks->event(&this->monitor, event, this->user_data);
|
||||
}
|
||||
|
||||
static int
|
||||
impl_monitor_set_callbacks(struct spa_monitor *monitor,
|
||||
const struct spa_monitor_callbacks *callbacks)
|
||||
const struct spa_monitor_callbacks *callbacks,
|
||||
void *user_data)
|
||||
{
|
||||
int res;
|
||||
struct impl *this;
|
||||
|
|
@ -245,6 +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;
|
||||
if (callbacks) {
|
||||
if ((res = impl_udev_open(this)) < 0)
|
||||
return res;
|
||||
|
|
|
|||
|
|
@ -158,6 +158,7 @@ struct impl {
|
|||
struct props props;
|
||||
|
||||
const struct spa_node_callbacks *callbacks;
|
||||
void *user_data;
|
||||
|
||||
struct port out_ports[1];
|
||||
};
|
||||
|
|
@ -236,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->callbacks, &this->node, seq, res);
|
||||
this->callbacks->done(&this->node, seq, res, this->user_data);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -275,7 +276,7 @@ static int do_start_done(struct spa_loop *loop,
|
|||
struct impl *this = user_data;
|
||||
int res = *(int*)data;
|
||||
|
||||
this->callbacks->done(this->callbacks, &this->node, seq, res);
|
||||
this->callbacks->done(&this->node, seq, res, this->user_data);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -354,7 +355,8 @@ static int impl_node_send_command(struct spa_node *node, struct spa_command *com
|
|||
}
|
||||
|
||||
static int impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks)
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
void *user_data)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -363,6 +365,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;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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->callbacks, &this->node);
|
||||
this->callbacks->have_output(&this->node, this->user_data);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue