diff --git a/src/pipewire/core.c b/src/pipewire/core.c index 554ea86ba..7495952e5 100644 --- a/src/pipewire/core.c +++ b/src/pipewire/core.c @@ -174,8 +174,7 @@ static int destroy_resource(void *object, void *data) if (resource && resource != client->core_resource) { - resource->removed = true; - pw_resource_destroy(resource); + pw_resource_remove(resource); } return 0; } diff --git a/src/pipewire/private.h b/src/pipewire/private.h index 1f939def0..bd55c3374 100644 --- a/src/pipewire/private.h +++ b/src/pipewire/private.h @@ -901,7 +901,10 @@ pw_core_find_port(struct pw_core *core, const struct pw_export_type *pw_core_find_export_type(struct pw_core *core, uint32_t type); int pw_proxy_install_marshal(struct pw_proxy *proxy, bool implementor); +void pw_proxy_remove(struct pw_proxy *proxy); + int pw_resource_install_marshal(struct pw_resource *resource, bool implementor); +void pw_resource_remove(struct pw_resource *resource); int pw_core_recalc_graph(struct pw_core *core); diff --git a/src/pipewire/proxy.c b/src/pipewire/proxy.c index b6a3f5c6c..79a734eb1 100644 --- a/src/pipewire/proxy.c +++ b/src/pipewire/proxy.c @@ -210,6 +210,12 @@ void pw_proxy_destroy(struct pw_proxy *proxy) } } +void pw_proxy_remove(struct pw_proxy *proxy) +{ + proxy->removed = true; + pw_proxy_destroy(proxy); +} + SPA_EXPORT void pw_proxy_unref(struct pw_proxy *proxy) { diff --git a/src/pipewire/remote.c b/src/pipewire/remote.c index d9c539771..1e369362b 100644 --- a/src/pipewire/remote.c +++ b/src/pipewire/remote.c @@ -139,10 +139,8 @@ static void core_event_remove_id(void *data, uint32_t id) struct pw_proxy *proxy; pw_log_debug(NAME" %p: object remove %u", this, id); - if ((proxy = pw_map_lookup(&this->objects, id)) != NULL) { - proxy->removed = true; - pw_proxy_destroy(proxy); - } + if ((proxy = pw_map_lookup(&this->objects, id)) != NULL) + pw_proxy_remove(proxy); } static void core_event_bound_id(void *data, uint32_t id, uint32_t global_id) @@ -425,8 +423,7 @@ do_connect(struct spa_loop *loop, return 0; error_clean_core_proxy: - ((struct pw_proxy*)remote->core_proxy)->removed = true; - pw_proxy_destroy((struct pw_proxy*)remote->core_proxy); + pw_proxy_remove((struct pw_proxy*)remote->core_proxy); error_disconnect: pw_protocol_client_disconnect(remote->conn); pw_remote_update_state(remote, PW_REMOTE_STATE_ERROR, "can't connect: %s", spa_strerror(res)); diff --git a/src/pipewire/resource.c b/src/pipewire/resource.c index 87a9ca67a..55af22ed9 100644 --- a/src/pipewire/resource.c +++ b/src/pipewire/resource.c @@ -259,3 +259,9 @@ void pw_resource_destroy(struct pw_resource *resource) free(resource); } + +void pw_resource_remove(struct pw_resource *resource) +{ + resource->removed = true; + pw_resource_destroy(resource); +}