mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-16 08:56:45 -05:00
hooks: use hook to implement the callbacks
This way we get the version check implemented and save some code.
This commit is contained in:
parent
a78617c6a8
commit
6ee192dff5
26 changed files with 121 additions and 111 deletions
|
|
@ -48,8 +48,7 @@ struct impl {
|
|||
struct spa_log *log;
|
||||
struct spa_loop *main_loop;
|
||||
|
||||
const struct spa_monitor_callbacks *callbacks;
|
||||
void *callbacks_data;
|
||||
struct spa_hook callbacks;
|
||||
|
||||
struct udev *udev;
|
||||
struct udev_monitor *umonitor;
|
||||
|
|
@ -175,7 +174,7 @@ static int emit_device(struct impl *this, uint32_t id, struct udev_device *dev)
|
|||
event = spa_pod_builder_add_object(&b, SPA_TYPE_EVENT_Monitor, id);
|
||||
fill_item(this, dev, &item, &b);
|
||||
|
||||
this->callbacks->event(this->callbacks_data, event);
|
||||
spa_monitor_call_event(&this->callbacks, event);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -284,8 +283,8 @@ impl_monitor_set_callbacks(struct spa_monitor *monitor,
|
|||
|
||||
this = SPA_CONTAINER_OF(monitor, struct impl, monitor);
|
||||
|
||||
this->callbacks = callbacks;
|
||||
this->callbacks_data = data;
|
||||
this->callbacks = SPA_HOOK_INIT(callbacks, data);
|
||||
|
||||
if (callbacks) {
|
||||
if ((res = impl_udev_open(this)) < 0)
|
||||
return res;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue