mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-18 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
|
|
@ -92,8 +92,7 @@ struct impl {
|
|||
struct spa_loop *data_loop;
|
||||
|
||||
struct spa_hook_list hooks;
|
||||
const struct spa_node_callbacks *callbacks;
|
||||
void *callbacks_data;
|
||||
struct spa_hook callbacks;
|
||||
|
||||
uint64_t info_all;
|
||||
struct spa_node_info info;
|
||||
|
|
@ -571,7 +570,8 @@ static int flush_data(struct impl *this, uint64_t now_time)
|
|||
spa_list_remove(&b->link);
|
||||
b->outstanding = true;
|
||||
spa_log_trace(this->log, "a2dp-sink %p: reuse buffer %u", this, b->id);
|
||||
this->callbacks->reuse_buffer(this->callbacks_data, 0, b->id);
|
||||
|
||||
spa_node_call_reuse_buffer(&this->callbacks, 0, b->id);
|
||||
port->ready_offset = 0;
|
||||
}
|
||||
total_frames += n_frames;
|
||||
|
|
@ -699,7 +699,7 @@ static void a2dp_on_timeout(struct spa_source *source)
|
|||
port->range->min_size = this->threshold * port->frame_size;
|
||||
port->range->max_size = this->write_samples * port->frame_size;
|
||||
}
|
||||
this->callbacks->ready(this->callbacks_data, SPA_STATUS_NEED_BUFFER);
|
||||
spa_node_call_ready(&this->callbacks, SPA_STATUS_NEED_BUFFER);
|
||||
}
|
||||
flush_data(this, now_time);
|
||||
}
|
||||
|
|
@ -974,8 +974,7 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
this->callbacks = callbacks;
|
||||
this->callbacks_data = data;
|
||||
this->callbacks = SPA_HOOK_INIT(callbacks, data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,8 +92,7 @@ struct impl {
|
|||
struct spa_loop *data_loop;
|
||||
|
||||
struct spa_hook_list hooks;
|
||||
const struct spa_node_callbacks *callbacks;
|
||||
void *callbacks_data;
|
||||
struct spa_hook callbacks;
|
||||
|
||||
uint64_t info_all;
|
||||
struct spa_node_info info;
|
||||
|
|
@ -379,7 +378,7 @@ static void decode_sbc_data(struct impl *this, uint8_t *src, size_t src_size)
|
|||
spa_log_debug(this->log, "data decoded successfully for buffer_id=%d", buffer->id);
|
||||
spa_list_append(&port->ready, &buffer->link);
|
||||
|
||||
this->callbacks->ready(this->callbacks_data, SPA_STATUS_HAVE_BUFFER);
|
||||
spa_node_call_ready(&this->callbacks, SPA_STATUS_HAVE_BUFFER);
|
||||
}
|
||||
|
||||
static void a2dp_on_ready_read(struct spa_source *source)
|
||||
|
|
@ -608,8 +607,7 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
this->callbacks = callbacks;
|
||||
this->callbacks_data = data;
|
||||
this->callbacks = SPA_HOOK_INIT(callbacks, data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,8 +60,7 @@ struct spa_bt_monitor {
|
|||
struct spa_dbus_connection *dbus_connection;
|
||||
DBusConnection *conn;
|
||||
|
||||
const struct spa_monitor_callbacks *callbacks;
|
||||
void *callbacks_data;
|
||||
struct spa_hook callbacks;
|
||||
|
||||
uint32_t count;
|
||||
|
||||
|
|
@ -532,7 +531,7 @@ static int device_add(struct spa_bt_monitor *monitor, struct spa_bt_device *devi
|
|||
fill_item(monitor, device, &item, &b);
|
||||
|
||||
device->added = true;
|
||||
monitor->callbacks->event(monitor->callbacks_data, event);
|
||||
spa_monitor_call_event(&monitor->callbacks, event);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -552,7 +551,7 @@ static int device_remove(struct spa_bt_monitor *monitor, struct spa_bt_device *d
|
|||
fill_item(monitor, device, &item, &b);
|
||||
|
||||
device->added = false;
|
||||
monitor->callbacks->event(monitor->callbacks_data, event);
|
||||
spa_monitor_call_event(&monitor->callbacks, event);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -2051,8 +2050,7 @@ impl_monitor_set_callbacks(struct spa_monitor *monitor,
|
|||
|
||||
this = SPA_CONTAINER_OF(monitor, struct spa_bt_monitor, monitor);
|
||||
|
||||
this->callbacks = callbacks;
|
||||
this->callbacks_data = data;
|
||||
this->callbacks = SPA_HOOK_INIT(callbacks, data);
|
||||
|
||||
if (callbacks) {
|
||||
get_managed_objects(this);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue