diff --git a/src/gst/gstpipewiredeviceprovider.c b/src/gst/gstpipewiredeviceprovider.c index 3645204a0..73f6d015f 100644 --- a/src/gst/gstpipewiredeviceprovider.c +++ b/src/gst/gstpipewiredeviceprovider.c @@ -412,7 +412,7 @@ gst_pipewire_device_provider_probe (GstDeviceProvider * provider) reg = pw_proxy_new(r, SPA_ID_INVALID, c->type.registry, 0); pw_proxy_set_implementation(reg, self, PW_VERSION_REGISTRY, ®istry_events, NULL); - pw_core_do_get_registry(r->core_proxy, reg->id); + pw_core_do_get_registry(r->core_proxy, PW_VERSION_REGISTRY, reg->id); pw_core_do_sync(r->core_proxy, 1); for (;;) { @@ -517,7 +517,7 @@ gst_pipewire_device_provider_start (GstDeviceProvider * provider) self->registry = pw_proxy_new(self->remote, SPA_ID_INVALID, self->core->type.registry, 0); pw_proxy_set_implementation(self->registry, self, PW_VERSION_REGISTRY, ®istry_events, NULL); - pw_core_do_get_registry(self->remote->core_proxy, self->registry->id); + pw_core_do_get_registry(self->remote->core_proxy, PW_VERSION_REGISTRY, self->registry->id); pw_core_do_sync(self->remote->core_proxy, 1); pw_thread_loop_unlock (self->main_loop); diff --git a/src/modules/module-flatpak.c b/src/modules/module-flatpak.c index 86d7f7de8..396bc58b1 100644 --- a/src/modules/module-flatpak.c +++ b/src/modules/module-flatpak.c @@ -70,6 +70,7 @@ struct async_pending { char *factory_name; char *name; struct pw_properties *properties; + uint32_t version; uint32_t new_id; }; @@ -268,6 +269,7 @@ portal_response(DBusConnection *connection, DBusMessage *msg, void *user_data) p->factory_name, p->name, &p->properties->dict, + p->version, p->new_id); } else { pw_core_notify_error(cinfo->client->core_resource, @@ -287,6 +289,7 @@ static void do_create_node(void *object, const char *factory_name, const char *name, const struct spa_dict *props, + uint32_t version, uint32_t new_id) { struct pw_resource *resource = object; @@ -303,7 +306,7 @@ static void do_create_node(void *object, struct async_pending *p; if (!cinfo->is_sandboxed) { - cinfo->old_methods->create_node (object, factory_name, name, props, new_id); + cinfo->old_methods->create_node (object, factory_name, name, props, version, new_id); return; } if (strcmp(factory_name, "client-node") != 0) { @@ -360,6 +363,7 @@ static void do_create_node(void *object, p->factory_name = strdup(factory_name); p->name = strdup(name); p->properties = props ? pw_properties_new_dict(props) : NULL; + p->version = version; p->new_id = new_id; pw_client_set_busy(client, true); diff --git a/src/modules/module-protocol-native/protocol-native.c b/src/modules/module-protocol-native/protocol-native.c index 5eba1ee26..a8a950bc9 100644 --- a/src/modules/module-protocol-native/protocol-native.c +++ b/src/modules/module-protocol-native/protocol-native.c @@ -72,7 +72,7 @@ static void core_marshal_sync(void *object, uint32_t seq) pw_connection_end_write(connection, b); } -static void core_marshal_get_registry(void *object, uint32_t new_id) +static void core_marshal_get_registry(void *object, uint32_t version, uint32_t new_id) { struct pw_proxy *proxy = object; struct pw_connection *connection = proxy->remote->protocol_private; @@ -81,7 +81,9 @@ static void core_marshal_get_registry(void *object, uint32_t new_id) b = pw_connection_begin_write_proxy(connection, proxy, PW_CORE_METHOD_GET_REGISTRY); - spa_pod_builder_struct(b, &f, SPA_POD_TYPE_INT, new_id); + spa_pod_builder_struct(b, &f, + SPA_POD_TYPE_INT, version, + SPA_POD_TYPE_INT, new_id); pw_connection_end_write(connection, b); } @@ -89,7 +91,8 @@ static void core_marshal_get_registry(void *object, uint32_t new_id) static void core_marshal_create_node(void *object, const char *factory_name, - const char *name, const struct spa_dict *props, uint32_t new_id) + const char *name, const struct spa_dict *props, + uint32_t version, uint32_t new_id) { struct pw_proxy *proxy = object; struct pw_connection *connection = proxy->remote->protocol_private; @@ -111,7 +114,10 @@ core_marshal_create_node(void *object, SPA_POD_TYPE_STRING, props->items[i].key, SPA_POD_TYPE_STRING, props->items[i].value, 0); } - spa_pod_builder_add(b, SPA_POD_TYPE_INT, new_id, -SPA_POD_TYPE_STRUCT, &f, 0); + spa_pod_builder_add(b, + SPA_POD_TYPE_INT, version, + SPA_POD_TYPE_INT, new_id, + -SPA_POD_TYPE_STRUCT, &f, 0); pw_connection_end_write(connection, b); } @@ -340,7 +346,8 @@ static void core_marshal_error(void *object, uint32_t id, int res, const char *e spa_pod_builder_struct(b, &f, SPA_POD_TYPE_INT, id, - SPA_POD_TYPE_INT, res, SPA_POD_TYPE_STRING, buffer); + SPA_POD_TYPE_INT, res, + SPA_POD_TYPE_STRING, buffer); pw_connection_end_write(connection, b); } @@ -422,13 +429,16 @@ static bool core_demarshal_get_registry(void *object, void *data, size_t size) { struct pw_resource *resource = object; struct spa_pod_iter it; - int32_t new_id; + int32_t version, new_id; if (!spa_pod_iter_struct(&it, data, size) || - !spa_pod_iter_get(&it, SPA_POD_TYPE_INT, &new_id, 0)) + !spa_pod_iter_get(&it, + SPA_POD_TYPE_INT, &version, + SPA_POD_TYPE_INT, &new_id, 0)) + return false; - pw_resource_do(resource, struct pw_core_methods, get_registry, new_id); + pw_resource_do(resource, struct pw_core_methods, get_registry, version, new_id); return true; } @@ -436,7 +446,7 @@ static bool core_demarshal_create_node(void *object, void *data, size_t size) { struct pw_resource *resource = object; struct spa_pod_iter it; - uint32_t new_id, i; + uint32_t version, new_id, i; const char *factory_name, *name; struct spa_dict props; @@ -453,11 +463,13 @@ static bool core_demarshal_create_node(void *object, void *data, size_t size) SPA_POD_TYPE_STRING, &props.items[i].value, 0)) return false; } - if (!spa_pod_iter_get(&it, SPA_POD_TYPE_INT, &new_id, 0)) + if (!spa_pod_iter_get(&it, + SPA_POD_TYPE_INT, &version, + SPA_POD_TYPE_INT, &new_id, 0)) return false; pw_resource_do(resource, struct pw_core_methods, create_node, factory_name, - name, &props, new_id); + name, &props, version, new_id); return true; } diff --git a/src/pipewire/client.c b/src/pipewire/client.c index 3a509d3b2..52e603f97 100644 --- a/src/pipewire/client.c +++ b/src/pipewire/client.c @@ -43,7 +43,7 @@ client_bind_func(struct pw_global *global, struct pw_client *client, uint32_t ve struct pw_client *this = global->object; struct pw_resource *resource; - resource = pw_resource_new(client, id, global->type, 0); + resource = pw_resource_new(client, id, global->type, version, 0); if (resource == NULL) goto no_mem; @@ -110,7 +110,8 @@ struct pw_client *pw_client_new(struct pw_core *core, spa_list_insert(core->client_list.prev, &this->link); - pw_core_add_global(core, NULL, core->type.client, 0, this, client_bind_func, &this->global); + pw_core_add_global(core, NULL, core->type.client, PW_VERSION_CLIENT, + this, client_bind_func, &this->global); this->info.id = this->global->id; this->info.props = this->properties ? &this->properties->dict : NULL; diff --git a/src/pipewire/core.c b/src/pipewire/core.c index c8f49e96b..0fc1ad7dd 100644 --- a/src/pipewire/core.c +++ b/src/pipewire/core.c @@ -106,7 +106,7 @@ static void core_sync(void *object, uint32_t seq) pw_core_notify_done(resource, seq); } -static void core_get_registry(void *object, uint32_t new_id) +static void core_get_registry(void *object, uint32_t version, uint32_t new_id) { struct pw_resource *resource = object; struct pw_client *client = resource->client; @@ -117,6 +117,7 @@ static void core_get_registry(void *object, uint32_t new_id) registry_resource = pw_resource_new(client, new_id, this->type.registry, + version, 0); if (registry_resource == NULL) goto no_mem; @@ -150,6 +151,7 @@ core_create_node(void *object, const char *factory_name, const char *name, const struct spa_dict *props, + uint32_t version, uint32_t new_id) { struct pw_resource *resource = object; @@ -165,6 +167,7 @@ core_create_node(void *object, node_resource = pw_resource_new(client, new_id, factory->type, + version, 0); if (node_resource == NULL) goto no_resource; @@ -256,7 +259,7 @@ core_bind_func(struct pw_global *global, struct pw_client *client, uint32_t vers struct pw_core *this = global->object; struct pw_resource *resource; - resource = pw_resource_new(client, id, global->type, 0); + resource = pw_resource_new(client, id, global->type, version, 0); if (resource == NULL) goto no_mem; @@ -334,7 +337,8 @@ struct pw_core *pw_core_new(struct pw_loop *main_loop, struct pw_properties *pro pw_signal_init(&this->global_added); pw_signal_init(&this->global_removed); - pw_core_add_global(this, NULL, this->type.core, 0, this, core_bind_func, &this->global); + pw_core_add_global(this, NULL, this->type.core, PW_VERSION_CORE, + this, core_bind_func, &this->global); this->info.id = this->global->id; this->info.change_mask = 0; diff --git a/src/pipewire/interfaces.h b/src/pipewire/interfaces.h index 452a1fa96..8f472a0ca 100644 --- a/src/pipewire/interfaces.h +++ b/src/pipewire/interfaces.h @@ -95,9 +95,10 @@ struct pw_core_methods { * * Create a registry object that allows the client to list and bind * the global objects available from the PipeWire server + * \param version the client proxy id * \param id the client proxy id */ - void (*get_registry) (void *object, uint32_t new_id); + void (*get_registry) (void *object, uint32_t version, uint32_t new_id); /** * Update the client properties * \param props the new client properties @@ -111,12 +112,14 @@ struct pw_core_methods { * \param factory_name the factory name to use * \param name the node name * \param props extra properties + * \param version the version of the interface * \param new_id the client proxy id */ void (*create_node) (void *object, const char *factory_name, const char *name, const struct spa_dict *props, + uint32_t version, uint32_t new_id); /** * Create a new link between two node ports diff --git a/src/pipewire/link.c b/src/pipewire/link.c index 8ac6ab2ae..ab3cfb8a9 100644 --- a/src/pipewire/link.c +++ b/src/pipewire/link.c @@ -943,7 +943,7 @@ link_bind_func(struct pw_global *global, struct pw_client *client, uint32_t vers struct pw_link *this = global->object; struct pw_resource *resource; - resource = pw_resource_new(client, id, global->type, 0); + resource = pw_resource_new(client, id, global->type, version, 0); if (resource == NULL) goto no_mem; @@ -1052,7 +1052,8 @@ struct pw_link *pw_link_new(struct pw_core *core, spa_list_insert(core->link_list.prev, &this->link); - pw_core_add_global(core, NULL, core->type.link, 0, this, link_bind_func, &this->global); + pw_core_add_global(core, NULL, core->type.link, PW_VERSION_LINK, + this, link_bind_func, &this->global); this->info.id = this->global->id; this->info.output_node_id = output ? output_node->global->id : -1; diff --git a/src/pipewire/module.c b/src/pipewire/module.c index c3d156b6a..68edf52fb 100644 --- a/src/pipewire/module.c +++ b/src/pipewire/module.c @@ -92,7 +92,7 @@ module_bind_func(struct pw_global *global, struct pw_client *client, uint32_t ve struct pw_module *this = global->object; struct pw_resource *resource; - resource = pw_resource_new(client, id, global->type, 0); + resource = pw_resource_new(client, id, global->type, version, 0); if (resource == NULL) goto no_mem; @@ -179,7 +179,8 @@ struct pw_module *pw_module_load(struct pw_core *core, if (!init_func(this, (char *) args)) goto init_failed; - pw_core_add_global(core, NULL, core->type.module, 0, impl, module_bind_func, &this->global); + pw_core_add_global(core, NULL, core->type.module, PW_VERSION_MODULE, + impl, module_bind_func, &this->global); this->info.id = this->global->id; this->info.name = name ? strdup(name) : NULL; diff --git a/src/pipewire/node.c b/src/pipewire/node.c index 0a573a006..f8e2b1ce7 100644 --- a/src/pipewire/node.c +++ b/src/pipewire/node.c @@ -215,7 +215,7 @@ node_bind_func(struct pw_global *global, struct pw_client *client, uint32_t vers struct pw_node *this = global->object; struct pw_resource *resource; - resource = pw_resource_new(client, id, global->type, 0); + resource = pw_resource_new(client, id, global->type, version, 0); if (resource == NULL) goto no_mem; @@ -257,9 +257,8 @@ void pw_node_export(struct pw_node *this) spa_list_insert(this->core->node_list.prev, &this->link); - pw_core_add_global(this->core, - this->owner, - this->core->type.node, 0, this, node_bind_func, &this->global); + pw_core_add_global(this->core, this->owner, this->core->type.node, PW_VERSION_NODE, + this, node_bind_func, &this->global); pw_loop_invoke(this->data_loop, do_node_add, 1, 0, NULL, false, this); diff --git a/src/pipewire/resource.c b/src/pipewire/resource.c index f808b6cbd..0afce099b 100644 --- a/src/pipewire/resource.c +++ b/src/pipewire/resource.c @@ -32,6 +32,7 @@ struct impl { struct pw_resource *pw_resource_new(struct pw_client *client, uint32_t id, uint32_t type, + uint32_t client_version, size_t user_data_size) { struct impl *impl; @@ -45,6 +46,7 @@ struct pw_resource *pw_resource_new(struct pw_client *client, this->core = client->core; this->client = client; this->type = type; + this->client_version = client_version; pw_signal_init(&this->destroy_signal); diff --git a/src/pipewire/resource.h b/src/pipewire/resource.h index 38cf6ea5a..3acc35e6a 100644 --- a/src/pipewire/resource.h +++ b/src/pipewire/resource.h @@ -65,6 +65,7 @@ struct pw_resource { uint32_t id; /**< per client unique id, index in client objects */ uint32_t type; /**< type id of the object */ + uint32_t client_version; /**< version of the client interface */ const struct pw_interface *iface; /**< protocol specific interface functions */ void *object; /**< pointer to the object */ @@ -83,6 +84,7 @@ struct pw_resource * pw_resource_new(struct pw_client *client, uint32_t id, uint32_t type, + uint32_t client_version, size_t user_data_size); int diff --git a/src/pipewire/stream.c b/src/pipewire/stream.c index e7f5dcde7..502bb2020 100644 --- a/src/pipewire/stream.c +++ b/src/pipewire/stream.c @@ -931,6 +931,7 @@ pw_stream_connect(struct pw_stream *stream, "client-node", "client-node", &stream->properties->dict, + PW_VERSION_CLIENT_NODE, impl->node_proxy->id); do_node_init(stream); diff --git a/src/tools/pipewire-monitor.c b/src/tools/pipewire-monitor.c index b796479da..14415ba38 100644 --- a/src/tools/pipewire-monitor.c +++ b/src/tools/pipewire-monitor.c @@ -315,7 +315,7 @@ static void on_state_changed(struct pw_listener *listener, struct pw_remote *rem pw_proxy_set_implementation(data->registry_proxy, data, PW_VERSION_REGISTRY, ®istry_events, NULL); - pw_core_do_get_registry(data->remote->core_proxy, + pw_core_do_get_registry(data->remote->core_proxy, PW_VERSION_REGISTRY, data->registry_proxy->id); break;