mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04: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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue