mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-08 13:30:08 -05:00
node: make add_listener method
Make struct spa_node_events for events emited from the main thread and keep the spa_node_callbacks for the data thread callbacks. The add_listener method installs the events and it's possible to install multiple handles. Adding a listener first emits the info and port_info events when installed, similar to how the PipeWire proxy bind works. This removes the need for the spa_pending_queue and makes it easier to implement the _sync versions. Add some helpers to make it easier for plugins to emit all the info to new listeners. Use the listeners for devices as well.
This commit is contained in:
parent
61ce4e77f6
commit
0390969228
53 changed files with 1774 additions and 1307 deletions
|
|
@ -170,17 +170,6 @@ void *pw_spa_node_get_user_data(struct pw_node *node)
|
|||
return impl->user_data;
|
||||
}
|
||||
|
||||
static int on_node_result(void *data, int seq, int res, const void *result)
|
||||
{
|
||||
struct spa_pending_queue *pending = data;
|
||||
return spa_pending_queue_complete(pending, seq, res, result);
|
||||
}
|
||||
|
||||
static const struct spa_node_callbacks node_callbacks = {
|
||||
SPA_VERSION_NODE_CALLBACKS,
|
||||
.result = on_node_result,
|
||||
};
|
||||
|
||||
static int
|
||||
setup_props(struct pw_core *core, struct spa_node *spa_node, struct pw_properties *pw_props)
|
||||
{
|
||||
|
|
@ -192,15 +181,11 @@ setup_props(struct pw_core *core, struct spa_node *spa_node, struct pw_propertie
|
|||
uint8_t buf[2048];
|
||||
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buf, sizeof(buf));
|
||||
const struct spa_pod_prop *prop = NULL;
|
||||
struct spa_pending_queue pending;
|
||||
|
||||
spa_pending_queue_init(&pending);
|
||||
|
||||
spa_node_set_callbacks(spa_node, &node_callbacks, &pending);
|
||||
|
||||
if ((res = spa_node_enum_params_sync(spa_node,
|
||||
res = spa_node_enum_params_sync(spa_node,
|
||||
SPA_PARAM_Props, &index, NULL, &props,
|
||||
&b, &pending)) != 1) {
|
||||
&b);
|
||||
if (res != 1) {
|
||||
if (res < 0)
|
||||
pw_log_debug("spa_node_get_props failed: %d", res);
|
||||
return res;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue